braze_ruby 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d13af3abbb4e98372a950bf22a32729721f50e061b5c4259a0ca8441ffc1b718
4
- data.tar.gz: 0ba7370dd8c8bf783643722ff0531a62128deb2361c4b7ce2cd0124659073c26
3
+ metadata.gz: 69312ed5aded0835cc1a47be5d8192b0055edef0c64acf05aca8eef6333e8ba1
4
+ data.tar.gz: aa86ae45bb15cce4fd1c4ac56f36cc9fe5fcc935e4015c07cd9f611e76b22bf5
5
5
  SHA512:
6
- metadata.gz: 12ce012904c603fa5c7d202f46bbbc3b5b0df057a07edb7f04ab18a820154eebba5628f23a3f43ace34b47a03a99415de1911429c6d9a3175b061522ca29025e
7
- data.tar.gz: acb859868636273fa6a8b07370e31805cc17760e8f40b392f0141a3ce963b1e0c902209297d7dea2750d69bed6fa86ab55629ae7d50f2a8997a6b31ffe276207
6
+ metadata.gz: ae746b58c45e1b24a8b5eae483cc9ec5d42a4669aa70803803a9fe49575ee1b17d58e644f3d95c37b7668e1fa967baa850d76423687689f68b7bf56b3c53ac2d
7
+ data.tar.gz: 57a527541dc22889bd4ffd015e52ca2d04c45c6e251539de5e6830a9a76ff4b9a01041b6dbbc3f836e98b23689565b652d263986e8200628a51d08c08de28b7e
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- braze_ruby (0.3.1)
5
- faraday (~> 0.17.1)
4
+ braze_ruby (0.3.2)
5
+ faraday
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -75,4 +75,4 @@ DEPENDENCIES
75
75
  webmock (~> 3.7.5)
76
76
 
77
77
  BUNDLED WITH
78
- 2.0.2
78
+ 2.1.1
data/README.md CHANGED
@@ -187,6 +187,21 @@ api.subscription_status_set(
187
187
  )
188
188
  ```
189
189
 
190
+ ### User Identification
191
+
192
+ #### Identify an alias-only user
193
+ ```ruby
194
+ api.identify_users(
195
+ aliases_to_identify: [{
196
+ external_id: 1234,
197
+ user_alias: {
198
+ alias_name: "device123",
199
+ alias_label: "my_device_identifier",
200
+ }
201
+ }]
202
+ )
203
+ ```
204
+
190
205
  ## Debugging
191
206
 
192
207
  The BRAZE_RUBY_DEBUG environment variable will trigger full printouts of the Faraday gem's HTTP requests and responses.
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ['lib']
26
26
  spec.required_ruby_version = '>= 2.0'
27
27
 
28
- spec.add_dependency 'faraday', '~> 0.17.1'
28
+ spec.add_dependency 'faraday'
29
29
 
30
30
  spec.add_development_dependency 'bundler', '>= 1.3'
31
31
  spec.add_development_dependency 'rake', '~> 12.3.3'
@@ -24,6 +24,7 @@ module BrazeRuby
24
24
  include BrazeRuby::Endpoints::Campaigns
25
25
  include BrazeRuby::Endpoints::Canvas
26
26
  include BrazeRuby::Endpoints::Subscription
27
+ include BrazeRuby::Endpoints::IdentifyUsers
27
28
 
28
29
  def export_users(**payload)
29
30
  BrazeRuby::REST::ExportUsers.new(braze_url).perform(api_key, payload)
@@ -6,3 +6,4 @@ require 'braze_ruby/endpoints/schedule_messages'
6
6
  require 'braze_ruby/endpoints/send_messages'
7
7
  require 'braze_ruby/endpoints/track_users'
8
8
  require 'braze_ruby/endpoints/delete_users'
9
+ require 'braze_ruby/endpoints/identify_users'
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module Endpoints
5
+ module IdentifyUsers
6
+ attr_writer :identify_users_service
7
+
8
+ def identify_users(**payload)
9
+ identify_users_service.perform(api_key, payload)
10
+ end
11
+
12
+ private
13
+
14
+ def identify_users_service
15
+ @identify_users_service ||= BrazeRuby::REST::IdentifyUsers.new(braze_url)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -16,3 +16,4 @@ require 'braze_ruby/rest/canvas_details'
16
16
  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
+ require 'braze_ruby/rest/identify_users'
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module REST
5
+ class IdentifyUsers < Base
6
+ def perform(api_key, aliases_to_identify: [])
7
+ http.post '/users/identify', {
8
+ 'api_key': api_key,
9
+ 'aliases_to_identify': aliases_to_identify,
10
+ }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrazeRuby
4
- VERSION = '0.3.1'.freeze
4
+ VERSION = '0.3.2'.freeze
5
5
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe BrazeRuby::REST::IdentifyUsers do
6
+ let(:http) { double(:http) }
7
+
8
+ let(:payload) { {aliases_to_identify: [user]} }
9
+ let(:user) { { external_id: 123, user_alias: { alias_name: 'abc', alias_label: 'foo' } } }
10
+
11
+ let(:api_key) { :api_key }
12
+
13
+ subject { described_class.new :rest_url}
14
+
15
+ before { subject.http = http }
16
+
17
+ it 'makes an http call to the identify users endpoint' do
18
+ expect(http).to receive(:post).with '/users/identify',
19
+ payload.merge({ api_key: :api_key })
20
+
21
+ subject.perform(api_key, payload)
22
+ end
23
+ end
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/identify"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"non-existent","aliases_to_identify":[{"external_id":400,"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.2
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 401
21
+ message: Unauthorized
22
+ headers:
23
+ Connection:
24
+ - keep-alive
25
+ Content-Length:
26
+ - '69'
27
+ Cache-Control:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Server:
32
+ - nginx
33
+ Strict-Transport-Security:
34
+ - max-age=0; includeSubDomains
35
+ X-Ratelimit-Limit:
36
+ - ''
37
+ X-Ratelimit-Remaining:
38
+ - ''
39
+ X-Ratelimit-Reset:
40
+ - ''
41
+ X-Request-Id:
42
+ - 8bd7f08e-2a28-4cac-af20-26dbf479eeb2
43
+ X-Runtime:
44
+ - '0.006500'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Date:
48
+ - Thu, 19 Dec 2019 20:55:45 GMT
49
+ Via:
50
+ - 1.1 varnish
51
+ X-Served-By:
52
+ - cache-msp20825-MSP
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1576788945.296140,VS0,VE43
59
+ Vary:
60
+ - Origin,Accept-Encoding
61
+ body:
62
+ encoding: ASCII-8BIT
63
+ string: '{"message":"Invalid API key: non-existent"}'
64
+ http_version:
65
+ recorded_at: Thu, 19 Dec 2019 20:55:45 GMT
66
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/identify"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"<BRAZE_REST_API_KEY>","aliases_to_identify":[{"external_id":400,"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.2
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 201
21
+ message: Created
22
+ headers:
23
+ Connection:
24
+ - keep-alive
25
+ Content-Length:
26
+ - '66'
27
+ Cache-Control:
28
+ - max-age=0, private, must-revalidate
29
+ Content-Type:
30
+ - application/json
31
+ Etag:
32
+ - W/"da612bda0a786bcb949da037e296a092"
33
+ Server:
34
+ - nginx
35
+ Strict-Transport-Security:
36
+ - max-age=0; includeSubDomains
37
+ - max-age=31536000; includeSubDomains
38
+ X-Ratelimit-Limit:
39
+ - '250000'
40
+ X-Ratelimit-Remaining:
41
+ - '249975'
42
+ X-Ratelimit-Reset:
43
+ - '1576789200'
44
+ X-Request-Id:
45
+ - 9348cf6f-365f-43fe-b460-f956c932097d
46
+ X-Runtime:
47
+ - '0.005338'
48
+ Accept-Ranges:
49
+ - bytes
50
+ Date:
51
+ - Thu, 19 Dec 2019 20:55:44 GMT
52
+ Via:
53
+ - 1.1 varnish
54
+ X-Served-By:
55
+ - cache-msp20820-MSP
56
+ X-Cache:
57
+ - MISS
58
+ X-Cache-Hits:
59
+ - '0'
60
+ X-Timer:
61
+ - S1576788945.699710,VS0,VE187
62
+ Vary:
63
+ - Origin,Accept-Encoding
64
+ body:
65
+ encoding: ASCII-8BIT
66
+ string: '{"aliases_processed":1,"message":"success"}'
67
+ http_version:
68
+ recorded_at: Thu, 19 Dec 2019 20:55:44 GMT
69
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/identify"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"<BRAZE_REST_API_KEY>","aliases_to_identify":[{"external_id":400,"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.2
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 201
21
+ message: Created
22
+ headers:
23
+ Connection:
24
+ - keep-alive
25
+ Content-Length:
26
+ - '66'
27
+ Cache-Control:
28
+ - max-age=0, private, must-revalidate
29
+ Content-Type:
30
+ - application/json
31
+ Etag:
32
+ - W/"da612bda0a786bcb949da037e296a092"
33
+ Server:
34
+ - nginx
35
+ Strict-Transport-Security:
36
+ - max-age=0; includeSubDomains
37
+ - max-age=31536000; includeSubDomains
38
+ X-Ratelimit-Limit:
39
+ - '250000'
40
+ X-Ratelimit-Remaining:
41
+ - '249974'
42
+ X-Ratelimit-Reset:
43
+ - '1576789200'
44
+ X-Request-Id:
45
+ - 6df46e00-4a8a-4b57-8acf-849cbc53c569
46
+ X-Runtime:
47
+ - '0.005888'
48
+ Accept-Ranges:
49
+ - bytes
50
+ Date:
51
+ - Thu, 19 Dec 2019 20:55:45 GMT
52
+ Via:
53
+ - 1.1 varnish
54
+ X-Served-By:
55
+ - cache-msp20823-MSP
56
+ X-Cache:
57
+ - MISS
58
+ X-Cache-Hits:
59
+ - '0'
60
+ X-Timer:
61
+ - S1576788945.958885,VS0,VE226
62
+ Vary:
63
+ - Origin,Accept-Encoding
64
+ body:
65
+ encoding: ASCII-8BIT
66
+ string: '{"aliases_processed":1,"message":"success"}'
67
+ http_version:
68
+ recorded_at: Thu, 19 Dec 2019 20:55:45 GMT
69
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'identify users' do
6
+ let(:user) { { external_id: 400, user_alias: { alias_name: 'abc', alias_label: 'foo' } } }
7
+
8
+ subject(:identify_users) do
9
+ api.identify_users(aliases_to_identify: [user])
10
+ end
11
+
12
+ context 'with success', vcr: true do
13
+ it 'responds with created' do
14
+ expect(identify_users.status).to be 201
15
+ end
16
+
17
+ it 'responds with success message' do
18
+ expect(JSON.parse(identify_users.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(identify_users.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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nussbaum
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-11-27 00:00:00.000000000 Z
13
+ date: 2019-12-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 0.17.1
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 0.17.1
28
+ version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: bundler
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -165,6 +165,7 @@ files:
165
165
  - lib/braze_ruby/endpoints/delete_users.rb
166
166
  - lib/braze_ruby/endpoints/email_status.rb
167
167
  - lib/braze_ruby/endpoints/email_sync.rb
168
+ - lib/braze_ruby/endpoints/identify_users.rb
168
169
  - lib/braze_ruby/endpoints/schedule_messages.rb
169
170
  - lib/braze_ruby/endpoints/send_messages.rb
170
171
  - lib/braze_ruby/endpoints/subscription.rb
@@ -178,6 +179,7 @@ files:
178
179
  - lib/braze_ruby/rest/email_status.rb
179
180
  - lib/braze_ruby/rest/email_unsubscribes.rb
180
181
  - lib/braze_ruby/rest/export_users.rb
182
+ - lib/braze_ruby/rest/identify_users.rb
181
183
  - lib/braze_ruby/rest/list_segments.rb
182
184
  - lib/braze_ruby/rest/schedule_messages.rb
183
185
  - lib/braze_ruby/rest/send_messages.rb
@@ -194,6 +196,7 @@ files:
194
196
  - spec/braze_ruby/rest/delete_users_spec.rb
195
197
  - spec/braze_ruby/rest/email_status_spec.rb
196
198
  - spec/braze_ruby/rest/export_users_spec.rb
199
+ - spec/braze_ruby/rest/identify_users_spec.rb
197
200
  - spec/braze_ruby/rest/schedule_messages_spec.rb
198
201
  - spec/braze_ruby/rest/send_messages_spec.rb
199
202
  - spec/braze_ruby/rest/track_users_spec.rb
@@ -213,6 +216,9 @@ files:
213
216
  - spec/fixtures/responses/email_sync/unsubscribes/responds_with_unsubscribed_emails.yml
214
217
  - spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml
215
218
  - spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml
219
+ - spec/fixtures/responses/identify_users/unauthorized/responds_with_unauthorized.yml
220
+ - spec/fixtures/responses/identify_users/with_success/responds_with_created.yml
221
+ - spec/fixtures/responses/identify_users/with_success/responds_with_success_message.yml
216
222
  - spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml
217
223
  - spec/fixtures/responses/list_segments/with_success/responds_with_success.yml
218
224
  - spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml
@@ -236,6 +242,7 @@ files:
236
242
  - spec/integrations/email_status_spec.rb
237
243
  - spec/integrations/email_sync_spec.rb
238
244
  - spec/integrations/export_users_spec.rb
245
+ - spec/integrations/identify_users_spec.rb
239
246
  - spec/integrations/list_segments_spec.rb
240
247
  - spec/integrations/schedule_messages_spec.rb
241
248
  - spec/integrations/send_messages_spec.rb
@@ -278,6 +285,7 @@ test_files:
278
285
  - spec/braze_ruby/rest/delete_users_spec.rb
279
286
  - spec/braze_ruby/rest/email_status_spec.rb
280
287
  - spec/braze_ruby/rest/export_users_spec.rb
288
+ - spec/braze_ruby/rest/identify_users_spec.rb
281
289
  - spec/braze_ruby/rest/schedule_messages_spec.rb
282
290
  - spec/braze_ruby/rest/send_messages_spec.rb
283
291
  - spec/braze_ruby/rest/track_users_spec.rb
@@ -297,6 +305,9 @@ test_files:
297
305
  - spec/fixtures/responses/email_sync/unsubscribes/responds_with_unsubscribed_emails.yml
298
306
  - spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml
299
307
  - spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml
308
+ - spec/fixtures/responses/identify_users/unauthorized/responds_with_unauthorized.yml
309
+ - spec/fixtures/responses/identify_users/with_success/responds_with_created.yml
310
+ - spec/fixtures/responses/identify_users/with_success/responds_with_success_message.yml
300
311
  - spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml
301
312
  - spec/fixtures/responses/list_segments/with_success/responds_with_success.yml
302
313
  - spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml
@@ -320,6 +331,7 @@ test_files:
320
331
  - spec/integrations/email_status_spec.rb
321
332
  - spec/integrations/email_sync_spec.rb
322
333
  - spec/integrations/export_users_spec.rb
334
+ - spec/integrations/identify_users_spec.rb
323
335
  - spec/integrations/list_segments_spec.rb
324
336
  - spec/integrations/schedule_messages_spec.rb
325
337
  - spec/integrations/send_messages_spec.rb