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.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Customerio
2
- VERSION = "5.5.1"
4
+ VERSION = "6.0.0"
3
5
  end
data/lib/customerio.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "customerio/version"
2
4
 
3
5
  module Customerio
@@ -8,6 +10,8 @@ module Customerio
8
10
  require "customerio/requests/send_push_request"
9
11
  require "customerio/requests/send_sms_request"
10
12
  require "customerio/requests/send_inbox_message_request"
13
+ require "customerio/requests/send_in_app_request"
14
+ require "customerio/requests/trigger_broadcast_request"
11
15
  require "customerio/api"
12
16
  require "customerio/param_encoder"
13
17
  end
metadata CHANGED
@@ -1,29 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customerio
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.1
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Allison
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-04-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: multi_json
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
12
  - !ruby/object:Gem::Dependency
28
13
  name: addressable
29
14
  requirement: !ruby/object:Gem::Requirement
@@ -44,70 +29,14 @@ dependencies:
44
29
  requirements:
45
30
  - - "~>"
46
31
  - !ruby/object:Gem::Version
47
- version: 0.3.0
32
+ version: '0.3'
48
33
  type: :runtime
49
34
  prerelease: false
50
35
  version_requirements: !ruby/object:Gem::Requirement
51
36
  requirements:
52
37
  - - "~>"
53
38
  - !ruby/object:Gem::Version
54
- version: 0.3.0
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '10.5'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '10.5'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.10'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.10'
83
- - !ruby/object:Gem::Dependency
84
- name: webmock
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 3.6.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 3.6.0
97
- - !ruby/object:Gem::Dependency
98
- name: json
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
39
+ version: '0.3'
111
40
  description: A ruby client for the Customer.io event API.
112
41
  email:
113
42
  - john@customer.io
@@ -115,15 +44,9 @@ executables: []
115
44
  extensions: []
116
45
  extra_rdoc_files: []
117
46
  files:
118
- - ".github/workflows/main.yml"
119
- - ".gitignore"
120
- - ".gitpod.yml"
121
47
  - CHANGELOG.markdown
122
- - Gemfile
123
48
  - LICENSE
124
49
  - README.md
125
- - Rakefile
126
- - customerio.gemspec
127
50
  - lib/customerio.rb
128
51
  - lib/customerio/api.rb
129
52
  - lib/customerio/base_client.rb
@@ -131,19 +54,21 @@ files:
131
54
  - lib/customerio/param_encoder.rb
132
55
  - lib/customerio/regions.rb
133
56
  - lib/customerio/requests/send_email_request.rb
57
+ - lib/customerio/requests/send_in_app_request.rb
134
58
  - lib/customerio/requests/send_inbox_message_request.rb
135
59
  - lib/customerio/requests/send_push_request.rb
136
60
  - lib/customerio/requests/send_sms_request.rb
61
+ - lib/customerio/requests/trigger_broadcast_request.rb
137
62
  - lib/customerio/version.rb
138
- - spec/api_client_spec.rb
139
- - spec/base_client_spec.rb
140
- - spec/client_spec.rb
141
- - spec/spec_helper.rb
142
63
  homepage: https://customer.io
143
64
  licenses:
144
65
  - MIT
145
- metadata: {}
146
- post_install_message:
66
+ metadata:
67
+ bug_tracker_uri: https://github.com/customerio/customerio-ruby/issues
68
+ changelog_uri: https://github.com/customerio/customerio-ruby/blob/main/CHANGELOG.markdown
69
+ homepage_uri: https://customer.io
70
+ rubygems_mfa_required: 'true'
71
+ source_code_uri: https://github.com/customerio/customerio-ruby
147
72
  rdoc_options: []
148
73
  require_paths:
149
74
  - lib
@@ -151,19 +76,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
76
  requirements:
152
77
  - - ">="
153
78
  - !ruby/object:Gem::Version
154
- version: '0'
79
+ version: '3.3'
155
80
  required_rubygems_version: !ruby/object:Gem::Requirement
156
81
  requirements:
157
82
  - - ">="
158
83
  - !ruby/object:Gem::Version
159
84
  version: '0'
160
85
  requirements: []
161
- rubygems_version: 3.0.3.1
162
- signing_key:
86
+ rubygems_version: 3.6.9
163
87
  specification_version: 4
164
88
  summary: A ruby client for the Customer.io event API.
165
- test_files:
166
- - spec/api_client_spec.rb
167
- - spec/base_client_spec.rb
168
- - spec/client_spec.rb
169
- - spec/spec_helper.rb
89
+ test_files: []
@@ -1,21 +0,0 @@
1
- name: ci
2
-
3
- on: [push,pull_request]
4
-
5
- jobs:
6
- test:
7
- strategy:
8
- matrix:
9
- ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
10
- runs-on: ubuntu-latest
11
- env:
12
- BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1.229.0
16
- with:
17
- ruby-version: ${{ matrix.ruby }}
18
- bundler-cache: true
19
-
20
- - name: Unit Test w/ RSpec
21
- run: bundle exec rspec
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- Gemfile.lock
6
- coverage
7
- InstalledFiles
8
- lib/bundler/man
9
- pkg
10
- rdoc
11
- spec/reports
12
- test/tmp
13
- test/version_tmp
14
- tmp
15
- vendor
16
-
17
- # YARD artifacts
18
- .yardoc
19
- _yardoc
20
- doc/
data/.gitpod.yml DELETED
@@ -1,10 +0,0 @@
1
- tasks:
2
- - init: |
3
- bundle config set --local path 'vendor/bundle'
4
- bundle install
5
-
6
- vscode:
7
- extensions:
8
- - connorshea.vscode-ruby-test-adapter
9
- - hbenl.vscode-test-explorer
10
- - hbenl.test-adapter-converter
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in customerio.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
- require "rspec/core"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task :default => :spec
data/customerio.gemspec DELETED
@@ -1,27 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/customerio/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["John Allison"]
6
- gem.email = ["john@customer.io"]
7
- gem.description = "A ruby client for the Customer.io event API."
8
- gem.summary = "A ruby client for the Customer.io event API."
9
- gem.homepage = "https://customer.io"
10
- gem.license = "MIT"
11
-
12
- gem.files = `git ls-files`.split($\)
13
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
- gem.name = "customerio"
16
- gem.require_paths = ["lib"]
17
- gem.version = Customerio::VERSION
18
-
19
- gem.add_dependency('multi_json', "~> 1.0")
20
- gem.add_dependency('addressable', '~> 2.9')
21
- gem.add_dependency('base64', '~> 0.3.0')
22
-
23
- gem.add_development_dependency('rake', '~> 10.5')
24
- gem.add_development_dependency('rspec', '~> 3.10')
25
- gem.add_development_dependency('webmock', '3.6.0')
26
- gem.add_development_dependency('json')
27
- end
@@ -1,373 +0,0 @@
1
- require 'spec_helper'
2
- require 'multi_json'
3
- require 'base64'
4
- require 'tempfile'
5
-
6
- describe Customerio::APIClient do
7
- let(:app_key) { "appkey" }
8
-
9
- let(:client) { Customerio::APIClient.new(app_key) }
10
- let(:response) { double("Response", code: 200) }
11
-
12
- def api_uri(path)
13
- "https://api.customer.io#{path}"
14
- end
15
-
16
- def request_headers
17
- { 'Authorization': "Bearer #{app_key}", 'Content-Type': 'application/json', 'User-Agent': 'Customer.io Ruby Client/' + Customerio::VERSION }
18
- end
19
-
20
- def json(data)
21
- MultiJson.dump(data)
22
- end
23
-
24
- it "the base client is initialised with the correct values when no region is passed in" do
25
- app_key = "appkey"
26
-
27
- expect(Customerio::BaseClient).to(
28
- receive(:new)
29
- .with(
30
- { app_key: app_key },
31
- {
32
- region: Customerio::Regions::US,
33
- url: Customerio::Regions::US.api_url
34
- }
35
- )
36
- )
37
-
38
- client = Customerio::APIClient.new(app_key)
39
- end
40
-
41
- it "raises an error when an incorrect region is passed in" do
42
- expect {
43
- Customerio::APIClient.new("appkey", region: :au)
44
- }.to raise_error /region must be an instance of Customerio::Regions::Region/
45
- end
46
-
47
- [Customerio::Regions::US, Customerio::Regions::EU].each do |region|
48
- it "the base client is initialised with the correct values when the region \"#{region}\" is passed in" do
49
- app_key = "appkey"
50
-
51
- expect(Customerio::BaseClient).to(
52
- receive(:new)
53
- .with(
54
- { app_key: app_key },
55
- {
56
- region: region,
57
- url: region.api_url
58
- }
59
- )
60
- )
61
-
62
- client = Customerio::APIClient.new(app_key, { region: region })
63
- end
64
- end
65
-
66
- describe "#send_email" do
67
- it "sends a POST request to the /api/send/email path" do
68
- req = Customerio::SendEmailRequest.new(
69
- identifiers: {
70
- id: 'c1',
71
- },
72
- transactional_message_id: 1,
73
- )
74
-
75
- stub_request(:post, api_uri('/v1/send/email'))
76
- .with(headers: request_headers, body: req.message)
77
- .to_return(status: 200, body: { delivery_id: 1 }.to_json, headers: {})
78
-
79
- client.send_email(req).should eq({ "delivery_id" => 1 })
80
- end
81
-
82
- it "handles validation failures (400)" do
83
- req = Customerio::SendEmailRequest.new(
84
- identifiers: {
85
- id: 'c1',
86
- },
87
- transactional_message_id: 1,
88
- )
89
-
90
- err_json = { meta: { error: "example error" } }.to_json
91
-
92
- stub_request(:post, api_uri('/v1/send/email'))
93
- .with(headers: request_headers, body: req.message)
94
- .to_return(status: 400, body: err_json, headers: {})
95
-
96
- lambda { client.send_email(req) }.should(
97
- raise_error(Customerio::InvalidResponse) { |error|
98
- error.message.should eq "example error"
99
- error.code.should eq "400"
100
- }
101
- )
102
- end
103
-
104
- it "handles other failures (5xx)" do
105
- req = Customerio::SendEmailRequest.new(
106
- identifiers: {
107
- id: 'c1',
108
- },
109
- transactional_message_id: 1,
110
- )
111
-
112
- stub_request(:post, api_uri('/v1/send/email'))
113
- .with(headers: request_headers, body: req.message)
114
- .to_return(status: 500, body: "Server unavailable", headers: {})
115
-
116
- lambda { client.send_email(req) }.should(
117
- raise_error(Customerio::InvalidResponse) { |error|
118
- error.message.should eq "Server unavailable"
119
- error.code.should eq "500"
120
- }
121
- )
122
- end
123
-
124
- it "allows attaching file content without encoding" do
125
- content = 'sample content'
126
-
127
- req = Customerio::SendEmailRequest.new(
128
- customer_id: 'c1',
129
- transactional_message_id: 1,
130
- )
131
-
132
- req.attach('test', content, encode: false)
133
- req.message[:attachments]['test'].should eq content
134
-
135
- stub_request(:post, api_uri('/v1/send/email'))
136
- .with(headers: request_headers, body: req.message)
137
- .to_return(status: 200, body: { delivery_id: 1 }.to_json, headers: {})
138
-
139
- client.send_email(req)
140
- end
141
-
142
- it "allows attaching files with encoding (default)" do
143
- content = 'sample content'
144
-
145
- req = Customerio::SendEmailRequest.new(
146
- customer_id: 'c1',
147
- transactional_message_id: 1,
148
- )
149
-
150
- req.attach('test', content)
151
- req.message[:attachments]['test'].should eq Base64.strict_encode64(content)
152
-
153
- stub_request(:post, api_uri('/v1/send/email'))
154
- .with(headers: request_headers, body: req.message)
155
- .to_return(status: 200, body: { delivery_id: 1 }.to_json, headers: {})
156
-
157
- client.send_email(req)
158
- end
159
-
160
- it "raises error when attaching the same key again" do
161
- req = Customerio::SendEmailRequest.new(
162
- customer_id: 'c1',
163
- transactional_message_id: 1,
164
- )
165
-
166
- req.attach('test', 'test-content')
167
-
168
- lambda { req.attach('test', '') }.should raise_error(/attachment test already exists/)
169
- req.message[:attachments].should eq({ "test" => Base64.strict_encode64("test-content") })
170
- end
171
- end
172
-
173
- describe "#send_push" do
174
- it "sends a POST request to the /api/send/push path" do
175
- req = Customerio::SendPushRequest.new(
176
- identifiers: {
177
- id: 'c1',
178
- },
179
- transactional_message_id: 1,
180
- )
181
-
182
- stub_request(:post, api_uri('/v1/send/push'))
183
- .with(headers: request_headers, body: req.message)
184
- .to_return(status: 200, body: { delivery_id: 1 }.to_json, headers: {})
185
-
186
- client.send_push(req).should eq({ "delivery_id" => 1 })
187
- end
188
-
189
- it "handles validation failures (400)" do
190
- req = Customerio::SendPushRequest.new(
191
- identifiers: {
192
- id: 'c1',
193
- },
194
- transactional_message_id: 1,
195
- )
196
-
197
- err_json = { meta: { error: "example error" } }.to_json
198
-
199
- stub_request(:post, api_uri('/v1/send/push'))
200
- .with(headers: request_headers, body: req.message)
201
- .to_return(status: 400, body: err_json, headers: {})
202
-
203
- lambda { client.send_push(req) }.should(
204
- raise_error(Customerio::InvalidResponse) { |error|
205
- error.message.should eq "example error"
206
- error.code.should eq "400"
207
- }
208
- )
209
- end
210
-
211
- it "handles other failures (5xx)" do
212
- req = Customerio::SendPushRequest.new(
213
- identifiers: {
214
- id: 'c1',
215
- },
216
- transactional_message_id: 1,
217
- )
218
-
219
- stub_request(:post, api_uri('/v1/send/push'))
220
- .with(headers: request_headers, body: req.message)
221
- .to_return(status: 500, body: "Server unavailable", headers: {})
222
-
223
- lambda { client.send_push(req) }.should(
224
- raise_error(Customerio::InvalidResponse) { |error|
225
- error.message.should eq "Server unavailable"
226
- error.code.should eq "500"
227
- }
228
- )
229
- end
230
-
231
- it "sets custom_device correctly if device present in req" do
232
- req = Customerio::SendPushRequest.new(
233
- identifiers: {
234
- id: 'c1',
235
- },
236
- transactional_message_id: 1,
237
- device: {
238
- platform: 'ios',
239
- token: 'sample-token',
240
- }
241
- )
242
-
243
- req.message[:custom_device].should eq({
244
- platform: 'ios',
245
- token: 'sample-token',
246
- })
247
-
248
- stub_request(:post, api_uri('/v1/send/push'))
249
- .with(headers: request_headers, body: req.message)
250
- .to_return(status: 200, body: { delivery_id: 2 }.to_json, headers: {})
251
-
252
- client.send_push(req).should eq({ "delivery_id" => 2 })
253
- end
254
- end
255
-
256
- describe "#send_sms" do
257
- it "sends a POST request to the /api/send/sms path" do
258
- req = Customerio::SendSMSRequest.new(
259
- identifiers: {
260
- id: 'c1',
261
- },
262
- transactional_message_id: 1,
263
- )
264
-
265
- stub_request(:post, api_uri('/v1/send/sms'))
266
- .with(headers: request_headers, body: req.message)
267
- .to_return(status: 200, body: { delivery_id: 1 }.to_json, headers: {})
268
-
269
- client.send_sms(req).should eq({ "delivery_id" => 1 })
270
- end
271
-
272
- it "handles validation failures (400)" do
273
- req = Customerio::SendSMSRequest.new(
274
- identifiers: {
275
- id: 'c1',
276
- },
277
- transactional_message_id: 1,
278
- )
279
-
280
- err_json = { meta: { error: "example error" } }.to_json
281
-
282
- stub_request(:post, api_uri('/v1/send/sms'))
283
- .with(headers: request_headers, body: req.message)
284
- .to_return(status: 400, body: err_json, headers: {})
285
-
286
- lambda { client.send_sms(req) }.should(
287
- raise_error(Customerio::InvalidResponse) { |error|
288
- error.message.should eq "example error"
289
- error.code.should eq "400"
290
- }
291
- )
292
- end
293
-
294
- it "handles other failures (5xx)" do
295
- req = Customerio::SendSMSRequest.new(
296
- identifiers: {
297
- id: 'c1',
298
- },
299
- transactional_message_id: 1,
300
- )
301
-
302
- stub_request(:post, api_uri('/v1/send/sms'))
303
- .with(headers: request_headers, body: req.message)
304
- .to_return(status: 500, body: "Server unavailable", headers: {})
305
-
306
- lambda { client.send_sms(req) }.should(
307
- raise_error(Customerio::InvalidResponse) { |error|
308
- error.message.should eq "Server unavailable"
309
- error.code.should eq "500"
310
- }
311
- )
312
- end
313
- end
314
-
315
- describe "#send_inbox_message" do
316
- it "sends a POST request to the /api/send/inbox_message path" do
317
- req = Customerio::SendInboxMessageRequest.new(
318
- identifiers: {
319
- id: 'c1',
320
- },
321
- transactional_message_id: 1,
322
- )
323
-
324
- stub_request(:post, api_uri('/v1/send/inbox_message'))
325
- .with(headers: request_headers, body: req.message)
326
- .to_return(status: 200, body: { delivery_id: 1 }.to_json, headers: {})
327
-
328
- client.send_inbox_message(req).should eq({ "delivery_id" => 1 })
329
- end
330
-
331
- it "handles validation failures (400)" do
332
- req = Customerio::SendInboxMessageRequest.new(
333
- identifiers: {
334
- id: 'c1',
335
- },
336
- transactional_message_id: 1,
337
- )
338
-
339
- err_json = { meta: { error: "example error" } }.to_json
340
-
341
- stub_request(:post, api_uri('/v1/send/inbox_message'))
342
- .with(headers: request_headers, body: req.message)
343
- .to_return(status: 400, body: err_json, headers: {})
344
-
345
- lambda { client.send_inbox_message(req) }.should(
346
- raise_error(Customerio::InvalidResponse) { |error|
347
- error.message.should eq "example error"
348
- error.code.should eq "400"
349
- }
350
- )
351
- end
352
-
353
- it "handles other failures (5xx)" do
354
- req = Customerio::SendInboxMessageRequest.new(
355
- identifiers: {
356
- id: 'c1',
357
- },
358
- transactional_message_id: 1,
359
- )
360
-
361
- stub_request(:post, api_uri('/v1/send/inbox_message'))
362
- .with(headers: request_headers, body: req.message)
363
- .to_return(status: 500, body: "Server unavailable", headers: {})
364
-
365
- lambda { client.send_inbox_message(req) }.should(
366
- raise_error(Customerio::InvalidResponse) { |error|
367
- error.message.should eq "Server unavailable"
368
- error.code.should eq "500"
369
- }
370
- )
371
- end
372
- end
373
- end