braze_ruby 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8cd9bb68fd35c0ccd7a9ecae5c5231696f2a48e906cea65f4436d7383167916
4
- data.tar.gz: 54c80de739f86eaf92321a6ff2a2fae377e17c2915427ea614e242547debd32a
3
+ metadata.gz: 9ef227d9be43770703ff994bcda610a34666b8057c5846f270391ee2a0dfd957
4
+ data.tar.gz: 866befd357481f0cef4a18b761bb69ce66bfa098af871ee768ef4a8b575c944d
5
5
  SHA512:
6
- metadata.gz: 8862330d38a1b209bcb0afcb4ad11140e91c76cb3d4070010ed39f8272c3a21834412e5d41945e2e5a0e1ed8bc162e6ef75d92933e5e16b7cb1960e7bf1ff0ed
7
- data.tar.gz: 6df0f44bc9e59531234a465384eb2ad7996abf43329f84aa0efff5714c980269277e83f464e0b6e33a54fc2ef6753e66d48110f34dbda8e4fa0bb203c024de39
6
+ metadata.gz: 5bd262c112d84b59dcefe528def47fd7a299715500e032ce0bbb8d3e6cb45fb226aad2c4f2a2f94c202b18efeae0f608c9984e999bb06549b720fedddba0d533
7
+ data.tar.gz: 050c09bd0ea3d5b3d5bb7b34f869f9053e628e28e6f192e4b072eb7f3242ed1980f8484dce32708ab1b7cf21fc045318c962b75bc5ac5ae9a75b136b1e3a2b78
data/README.md CHANGED
@@ -187,7 +187,20 @@ api.subscription_status_set(
187
187
  )
188
188
  ```
189
189
 
190
- ### User Identification
190
+ ### User Alias
191
+
192
+ #### Create an alias-only user
193
+
194
+ ```ruby
195
+ api.create_user_aliases(
196
+ user_aliases: [{
197
+ user_alias: {
198
+ alias_name: "device123",
199
+ alias_label: "my_device_identifier",
200
+ }
201
+ }]
202
+ )
203
+ ```
191
204
 
192
205
  #### Identify an alias-only user
193
206
  ```ruby
@@ -202,6 +215,18 @@ api.identify_users(
202
215
  )
203
216
  ```
204
217
 
218
+ ### Email Sync
219
+
220
+ #### Get List of or Query Email Unsubscribes
221
+ ```ruby
222
+ api.email_unsubscribes(email: ['jdoe@example.com'])
223
+ ```
224
+
225
+ #### Get List of or Query Hard Bounced Emails
226
+ ```ruby
227
+ api.email_hard_bounces(email: ['jdoe@example.com'])
228
+ ```
229
+
205
230
  ## Debugging
206
231
 
207
232
  The BRAZE_RUBY_DEBUG environment variable will trigger full printouts of the Faraday gem's HTTP requests and responses.
@@ -25,6 +25,7 @@ module BrazeRuby
25
25
  include BrazeRuby::Endpoints::Canvas
26
26
  include BrazeRuby::Endpoints::Subscription
27
27
  include BrazeRuby::Endpoints::IdentifyUsers
28
+ include BrazeRuby::Endpoints::CreateUserAliases
28
29
 
29
30
  def export_users(**payload)
30
31
  BrazeRuby::REST::ExportUsers.new(api_key, braze_url, options).perform(**payload)
@@ -7,3 +7,4 @@ require 'braze_ruby/endpoints/send_messages'
7
7
  require 'braze_ruby/endpoints/track_users'
8
8
  require 'braze_ruby/endpoints/delete_users'
9
9
  require 'braze_ruby/endpoints/identify_users'
10
+ require 'braze_ruby/endpoints/create_user_aliases'
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module Endpoints
5
+ module CreateUserAliases
6
+ attr_writer :create_user_aliases_service
7
+
8
+ def create_user_aliases(**payload)
9
+ create_user_aliases_service.perform(**payload)
10
+ end
11
+
12
+ private
13
+
14
+ def create_user_aliases_service
15
+ @create_user_aliases_service ||= BrazeRuby::REST::CreateUserAliases.new(api_key, braze_url, options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -17,3 +17,4 @@ require 'braze_ruby/rest/subscription_status_set'
17
17
  require 'braze_ruby/rest/subscription_status_get'
18
18
  require 'braze_ruby/rest/subscription_user_status'
19
19
  require 'braze_ruby/rest/identify_users'
20
+ require 'braze_ruby/rest/create_user_aliases'
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module REST
5
+ class CreateUserAliases < Base
6
+ def perform(user_aliases: [])
7
+ http.post '/users/alias/new', {
8
+ 'user_aliases': user_aliases
9
+ }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrazeRuby
4
- VERSION = '0.4.0'.freeze
4
+ VERSION = '0.4.1'.freeze
5
5
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe BrazeRuby::REST::CreateUserAliases do
6
+ let(:http) { double(:http) }
7
+
8
+ let(:payload) { {user_aliases: [user]} }
9
+ let(:user) { { user_alias: { alias_name: 'abc', alias_label: 'foo' } } }
10
+
11
+ let(:api_key) { :api_key }
12
+
13
+ subject { described_class.new :api_key, :rest_url, {}}
14
+
15
+ before { subject.http = http }
16
+
17
+ it 'makes an http call to the user aliases endpoint' do
18
+ expect(http).to receive(:post).with '/users/alias/new',
19
+ payload
20
+
21
+ subject.perform(**payload)
22
+ end
23
+ end
@@ -0,0 +1,67 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/alias/new"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"user_aliases":[{"user_alias":{"alias_name":"abc","alias_label":"foo"}}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.4.0
16
+ Authorization:
17
+ - Bearer non-existent
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ Connection:
26
+ - keep-alive
27
+ Content-Type:
28
+ - application/json
29
+ Server:
30
+ - nginx
31
+ X-Ratelimit-Limit:
32
+ - ''
33
+ X-Ratelimit-Remaining:
34
+ - ''
35
+ X-Ratelimit-Reset:
36
+ - ''
37
+ Cache-Control:
38
+ - no-cache
39
+ X-Request-Id:
40
+ - 238c0308-346b-4b59-9b2a-c91bfb3c9926
41
+ X-Runtime:
42
+ - '0.002100'
43
+ Strict-Transport-Security:
44
+ - max-age=0; includeSubDomains
45
+ Accept-Ranges:
46
+ - bytes
47
+ Date:
48
+ - Thu, 28 Jan 2021 10:04:42 GMT
49
+ Via:
50
+ - 1.1 varnish
51
+ X-Served-By:
52
+ - cache-fra19136-FRA
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1611828282.806343,VS0,VE395
59
+ Vary:
60
+ - Origin,Accept-Encoding
61
+ Transfer-Encoding:
62
+ - chunked
63
+ body:
64
+ encoding: ASCII-8BIT
65
+ string: '{"message":"Invalid API key: non-existent"}'
66
+ recorded_at: Thu, 28 Jan 2021 10:04:42 GMT
67
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/alias/new"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"user_aliases":[{"user_alias":{"alias_name":"abc","alias_label":"foo"}}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.3.3
16
+ Authorization:
17
+ - Bearer <BRAZE_REST_API_KEY>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Connection:
26
+ - keep-alive
27
+ Content-Length:
28
+ - '66'
29
+ Cache-Control:
30
+ - max-age=0, private, must-revalidate
31
+ Content-Type:
32
+ - application/json
33
+ Etag:
34
+ - W/"da612bda0a786bcb949da037e296a092"
35
+ Server:
36
+ - nginx
37
+ Strict-Transport-Security:
38
+ - max-age=0; includeSubDomains
39
+ - max-age=31536000; includeSubDomains
40
+ X-Ratelimit-Limit:
41
+ - '250000'
42
+ X-Ratelimit-Remaining:
43
+ - '249982'
44
+ X-Ratelimit-Reset:
45
+ - '1592427600'
46
+ X-Request-Id:
47
+ - d0f2ec14-ad20-4ec1-8c98-e082ba1a29a7
48
+ X-Runtime:
49
+ - '0.007261'
50
+ Accept-Ranges:
51
+ - bytes
52
+ Date:
53
+ - Wed, 17 Jun 2020 20:30:11 GMT
54
+ Via:
55
+ - 1.1 varnish
56
+ X-Served-By:
57
+ - cache-hhn4027-HHN
58
+ X-Cache:
59
+ - MISS
60
+ X-Cache-Hits:
61
+ - '0'
62
+ X-Timer:
63
+ - S1592425811.496339,VS0,VE10
64
+ Vary:
65
+ - Origin,Accept-Encoding
66
+ body:
67
+ encoding: ASCII-8BIT
68
+ string: '{"aliases_processed":1,"message":"success"}'
69
+ http_version:
70
+ recorded_at: Wed, 17 Jun 2020 20:30:11 GMT
71
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/alias/new"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"user_aliases":[{"user_alias":{"alias_name":"abc","alias_label":"foo"}}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.3.3
16
+ Authorization:
17
+ - Bearer <BRAZE_REST_API_KEY>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Connection:
26
+ - keep-alive
27
+ Content-Length:
28
+ - '66'
29
+ Cache-Control:
30
+ - max-age=0, private, must-revalidate
31
+ Content-Type:
32
+ - application/json
33
+ Etag:
34
+ - W/"da612bda0a786bcb949da037e296a092"
35
+ Server:
36
+ - nginx
37
+ Strict-Transport-Security:
38
+ - max-age=0; includeSubDomains
39
+ - max-age=31536000; includeSubDomains
40
+ X-Ratelimit-Limit:
41
+ - '250000'
42
+ X-Ratelimit-Remaining:
43
+ - '249981'
44
+ X-Ratelimit-Reset:
45
+ - '1592427600'
46
+ X-Request-Id:
47
+ - 3e3620bf-17ee-4cb6-9bcf-252339f664e2
48
+ X-Runtime:
49
+ - '0.005803'
50
+ Accept-Ranges:
51
+ - bytes
52
+ Date:
53
+ - Wed, 17 Jun 2020 20:30:16 GMT
54
+ Via:
55
+ - 1.1 varnish
56
+ X-Served-By:
57
+ - cache-hhn4021-HHN
58
+ X-Cache:
59
+ - MISS
60
+ X-Cache-Hits:
61
+ - '0'
62
+ X-Timer:
63
+ - S1592425816.221760,VS0,VE9
64
+ Vary:
65
+ - Origin,Accept-Encoding
66
+ body:
67
+ encoding: ASCII-8BIT
68
+ string: '{"aliases_processed":1,"message":"success"}'
69
+ http_version:
70
+ recorded_at: Wed, 17 Jun 2020 20:30:16 GMT
71
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'create user aliases' do
6
+ let(:user) { { user_alias: { alias_name: 'abc', alias_label: 'foo' } } }
7
+
8
+ subject(:create_user_aliases) do
9
+ api.create_user_aliases(user_aliases: [user])
10
+ end
11
+
12
+ context 'with success', vcr: true do
13
+ it 'responds with created' do
14
+ expect(create_user_aliases.status).to be 201
15
+ end
16
+
17
+ it 'responds with success message' do
18
+ expect(JSON.parse(create_user_aliases.body)).to eq(
19
+ 'aliases_processed' => 1,
20
+ 'message' => 'success'
21
+ )
22
+ end
23
+ end
24
+
25
+ context 'unauthorized', vcr: true do
26
+ let(:api_key) { 'non-existent' }
27
+
28
+ it 'responds with unauthorized' do
29
+ expect(create_user_aliases.status).to be 401
30
+ end
31
+ end
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braze_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nussbaum
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-06-18 00:00:00.000000000 Z
13
+ date: 2021-01-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -162,6 +162,7 @@ files:
162
162
  - lib/braze_ruby/endpoints.rb
163
163
  - lib/braze_ruby/endpoints/campaigns.rb
164
164
  - lib/braze_ruby/endpoints/canvas.rb
165
+ - lib/braze_ruby/endpoints/create_user_aliases.rb
165
166
  - lib/braze_ruby/endpoints/delete_users.rb
166
167
  - lib/braze_ruby/endpoints/email_status.rb
167
168
  - lib/braze_ruby/endpoints/email_sync.rb
@@ -174,6 +175,7 @@ files:
174
175
  - lib/braze_ruby/rest.rb
175
176
  - lib/braze_ruby/rest/base.rb
176
177
  - lib/braze_ruby/rest/canvas_details.rb
178
+ - lib/braze_ruby/rest/create_user_aliases.rb
177
179
  - lib/braze_ruby/rest/delete_users.rb
178
180
  - lib/braze_ruby/rest/email_hard_bounces.rb
179
181
  - lib/braze_ruby/rest/email_status.rb
@@ -194,6 +196,7 @@ files:
194
196
  - spec/braze_ruby/endpoints/delete_users_spec.rb
195
197
  - spec/braze_ruby/endpoints/track_users_spec.rb
196
198
  - spec/braze_ruby/http_spec.rb
199
+ - spec/braze_ruby/rest/create_user_aliases_spec.rb
197
200
  - spec/braze_ruby/rest/delete_users_spec.rb
198
201
  - spec/braze_ruby/rest/email_status_spec.rb
199
202
  - spec/braze_ruby/rest/export_users_spec.rb
@@ -205,6 +208,9 @@ files:
205
208
  - spec/fixtures/responses/campaigns/trigger_send/sends_an_email.yml
206
209
  - spec/fixtures/responses/canvas/details/returns_error_when_no_canvas.yml
207
210
  - spec/fixtures/responses/canvas/trigger_send/sends_a_canvas.yml
211
+ - spec/fixtures/responses/create_user_aliases/unauthorized/responds_with_unauthorized.yml
212
+ - spec/fixtures/responses/create_user_aliases/with_success/responds_with_created.yml
213
+ - spec/fixtures/responses/create_user_aliases/with_success/responds_with_success_message.yml
208
214
  - spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml
209
215
  - spec/fixtures/responses/delete_users/with_success/responds_with_created.yml
210
216
  - spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml
@@ -239,6 +245,7 @@ files:
239
245
  - spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml
240
246
  - spec/integrations/campaigns_spec.rb
241
247
  - spec/integrations/canvas_spec.rb
248
+ - spec/integrations/create_user_aliases_spec.rb
242
249
  - spec/integrations/delete_users_spec.rb
243
250
  - spec/integrations/email_status_spec.rb
244
251
  - spec/integrations/email_sync_spec.rb
@@ -274,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
281
  - !ruby/object:Gem::Version
275
282
  version: '0'
276
283
  requirements: []
277
- rubygems_version: 3.1.2
284
+ rubygems_version: 3.1.4
278
285
  signing_key:
279
286
  specification_version: 4
280
287
  summary: A wrapper for the Braze REST API forked from the appboy gem, track users/events/purchases,
@@ -284,6 +291,7 @@ test_files:
284
291
  - spec/braze_ruby/endpoints/delete_users_spec.rb
285
292
  - spec/braze_ruby/endpoints/track_users_spec.rb
286
293
  - spec/braze_ruby/http_spec.rb
294
+ - spec/braze_ruby/rest/create_user_aliases_spec.rb
287
295
  - spec/braze_ruby/rest/delete_users_spec.rb
288
296
  - spec/braze_ruby/rest/email_status_spec.rb
289
297
  - spec/braze_ruby/rest/export_users_spec.rb
@@ -295,6 +303,9 @@ test_files:
295
303
  - spec/fixtures/responses/campaigns/trigger_send/sends_an_email.yml
296
304
  - spec/fixtures/responses/canvas/details/returns_error_when_no_canvas.yml
297
305
  - spec/fixtures/responses/canvas/trigger_send/sends_a_canvas.yml
306
+ - spec/fixtures/responses/create_user_aliases/unauthorized/responds_with_unauthorized.yml
307
+ - spec/fixtures/responses/create_user_aliases/with_success/responds_with_created.yml
308
+ - spec/fixtures/responses/create_user_aliases/with_success/responds_with_success_message.yml
298
309
  - spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml
299
310
  - spec/fixtures/responses/delete_users/with_success/responds_with_created.yml
300
311
  - spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml
@@ -329,6 +340,7 @@ test_files:
329
340
  - spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml
330
341
  - spec/integrations/campaigns_spec.rb
331
342
  - spec/integrations/canvas_spec.rb
343
+ - spec/integrations/create_user_aliases_spec.rb
332
344
  - spec/integrations/delete_users_spec.rb
333
345
  - spec/integrations/email_status_spec.rb
334
346
  - spec/integrations/email_sync_spec.rb