Skip to content

Commit 194307f

Browse files
authored
Support GET requests in Base Client request_class (#118)
1 parent 3482b93 commit 194307f

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

lib/customerio/base_client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def request_class(method)
7676
Net::HTTP::Put
7777
when :delete
7878
Net::HTTP::Delete
79+
when :get
80+
Net::HTTP::Get
7981
else
8082
raise InvalidRequest, "Invalid request method #{method.inspect}"
8183
end

spec/base_client_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ def api_client_request_headers
4545
end
4646
end
4747

48+
describe "GET requests" do
49+
describe "with a site ID and API key" do
50+
it "sends a GET request with basic auth" do
51+
stub_request(:get, api_uri('/some/path')).
52+
with(headers: track_client_request_headers).
53+
to_return(status: 200, body: "", headers: {})
54+
55+
track_client.request(:get, '/some/path', "")
56+
end
57+
end
58+
59+
describe "with an app key" do
60+
it "sends a GET request with bearer token" do
61+
stub_request(:get, api_uri('/some/path')).
62+
with(headers: api_client_request_headers).
63+
to_return(status: 200, body: "", headers: {})
64+
65+
api_client.request(:get, '/some/path', "")
66+
end
67+
end
68+
end
69+
4870
describe "#verify_response" do
4971
it "throws an error when the response isn't between 200 and 300" do
5072
stub_request(:put, api_uri('/some/path')).

0 commit comments

Comments
 (0)