customerio 5.5.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +5 -0
- data/README.md +144 -12
- data/lib/customerio/api.rb +55 -46
- data/lib/customerio/base_client.rb +26 -20
- data/lib/customerio/client.rb +142 -75
- data/lib/customerio/param_encoder.rb +6 -11
- data/lib/customerio/regions.rb +3 -4
- data/lib/customerio/requests/send_email_request.rb +22 -23
- data/lib/customerio/requests/send_in_app_request.rb +27 -0
- data/lib/customerio/requests/send_inbox_message_request.rb +12 -16
- data/lib/customerio/requests/send_push_request.rb +16 -14
- data/lib/customerio/requests/send_sms_request.rb +21 -23
- data/lib/customerio/requests/trigger_broadcast_request.rb +28 -0
- data/lib/customerio/version.rb +3 -1
- data/lib/customerio.rb +4 -0
- metadata +15 -95
- data/.github/workflows/main.yml +0 -21
- data/.gitignore +0 -20
- data/.gitpod.yml +0 -10
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/customerio.gemspec +0 -27
- data/spec/api_client_spec.rb +0 -373
- data/spec/base_client_spec.rb +0 -67
- data/spec/client_spec.rb +0 -718
- data/spec/spec_helper.rb +0 -15
data/spec/base_client_spec.rb
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'multi_json'
|
|
3
|
-
require 'base64'
|
|
4
|
-
|
|
5
|
-
describe Customerio::BaseClient do
|
|
6
|
-
let(:url) { "https://test.customer.io" }
|
|
7
|
-
|
|
8
|
-
let(:site_id) { "SITE_ID" }
|
|
9
|
-
let(:api_key) { "API_KEY" }
|
|
10
|
-
let(:track_client) { Customerio::BaseClient.new({ site_id: site_id, api_key: api_key }, { url: url }) }
|
|
11
|
-
|
|
12
|
-
let(:app_key) { "APP_KEY" }
|
|
13
|
-
let(:api_client) { Customerio::BaseClient.new({ app_key: app_key }, { url: url }) }
|
|
14
|
-
|
|
15
|
-
def api_uri(path)
|
|
16
|
-
"#{url}#{path}"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def track_client_request_headers
|
|
20
|
-
token = Base64.strict_encode64("#{site_id}:#{api_key}")
|
|
21
|
-
{ 'Authorization': "Basic #{token}", 'Content-Type': 'application/json', 'User-Agent': 'Customer.io Ruby Client/' + Customerio::VERSION }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def api_client_request_headers
|
|
25
|
-
{ 'Authorization': "Bearer #{app_key}", 'Content-Type': 'application/json', 'User-Agent': 'Customer.io Ruby Client/' + Customerio::VERSION }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe "with a site ID and API key" do
|
|
29
|
-
it "uses the correct basic auth" do
|
|
30
|
-
stub_request(:put, api_uri('/some/path')).
|
|
31
|
-
with(headers: track_client_request_headers).
|
|
32
|
-
to_return(status: 200, body: "", headers: {})
|
|
33
|
-
|
|
34
|
-
track_client.request(:put, '/some/path', "")
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "with an app key" do
|
|
39
|
-
it "uses the correct bearer token" do
|
|
40
|
-
stub_request(:put, api_uri('/some/path')).
|
|
41
|
-
with(headers: api_client_request_headers).
|
|
42
|
-
to_return(status: 200, body: "", headers: {})
|
|
43
|
-
|
|
44
|
-
api_client.request(:put, '/some/path', "")
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe "#verify_response" do
|
|
49
|
-
it "throws an error when the response isn't between 200 and 300" do
|
|
50
|
-
stub_request(:put, api_uri('/some/path')).
|
|
51
|
-
with(headers: api_client_request_headers).
|
|
52
|
-
to_return(status: 400, body: "", headers: {})
|
|
53
|
-
|
|
54
|
-
lambda { api_client.request_and_verify_response(:put, '/some/path', "") }.should(
|
|
55
|
-
raise_error(Customerio::InvalidResponse)
|
|
56
|
-
)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "returns the response when the status is 200" do
|
|
60
|
-
stub_request(:put, api_uri('/some/path')).
|
|
61
|
-
with(headers: api_client_request_headers).
|
|
62
|
-
to_return(status: 200, body: "Test", headers: {})
|
|
63
|
-
|
|
64
|
-
api_client.request_and_verify_response(:put, '/some/path', "").body.should eq("Test")
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|