braze_ruby 0.4.1 → 0.4.2

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: 9ef227d9be43770703ff994bcda610a34666b8057c5846f270391ee2a0dfd957
4
- data.tar.gz: 866befd357481f0cef4a18b761bb69ce66bfa098af871ee768ef4a8b575c944d
3
+ metadata.gz: 8aae95520a637f8bfb69c12c2df7700966eec68e243743fabc03798b194a924f
4
+ data.tar.gz: 95791c077beeb50119d715e81374533778032ee85d1fef28ed946352a1bd618b
5
5
  SHA512:
6
- metadata.gz: 5bd262c112d84b59dcefe528def47fd7a299715500e032ce0bbb8d3e6cb45fb226aad2c4f2a2f94c202b18efeae0f608c9984e999bb06549b720fedddba0d533
7
- data.tar.gz: 050c09bd0ea3d5b3d5bb7b34f869f9053e628e28e6f192e4b072eb7f3242ed1980f8484dce32708ab1b7cf21fc045318c962b75bc5ac5ae9a75b136b1e3a2b78
6
+ metadata.gz: 61bd0b6c2bb7c59e396cc1c3aa40fe0b54095c95f0195c5287e96c6e8504955442052a36d8e137150e816a357e2ae2982c112d4a79df95047d4841adf9b8b448
7
+ data.tar.gz: 1ac6bb7da1dc22c6138c62a00072ec62d82d48ac2ee8b2922607c62dabcd7febe36b798c606466d85c88bc86f8d01067f347a3c4b11d0d92ba7c46a003b6ea91
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- braze_ruby (0.4.0)
4
+ braze_ruby (0.4.2)
5
5
  faraday
6
6
 
7
7
  GEM
@@ -23,8 +23,11 @@ GEM
23
23
  dotenv (2.7.5)
24
24
  factory_bot (5.2.0)
25
25
  activesupport (>= 4.2.0)
26
- faraday (1.0.1)
26
+ faraday (1.3.0)
27
+ faraday-net_http (~> 1.0)
27
28
  multipart-post (>= 1.2, < 3)
29
+ ruby2_keywords
30
+ faraday-net_http (1.0.1)
28
31
  hashdiff (1.0.1)
29
32
  i18n (1.8.3)
30
33
  concurrent-ruby (~> 1.0)
@@ -49,6 +52,7 @@ GEM
49
52
  diff-lcs (>= 1.2.0, < 2.0)
50
53
  rspec-support (~> 3.9.0)
51
54
  rspec-support (3.9.3)
55
+ ruby2_keywords (0.0.4)
52
56
  safe_yaml (1.0.5)
53
57
  thread_safe (0.3.6)
54
58
  tzinfo (1.2.7)
data/README.md CHANGED
@@ -215,6 +215,25 @@ api.identify_users(
215
215
  )
216
216
  ```
217
217
 
218
+ ### External ID Migration
219
+
220
+ #### Rename users' external IDs with an array of external_id_renames
221
+ Note: you can send up to 50 rename objects per request.
222
+ ```ruby
223
+ api.rename_external_ids(
224
+ external_id_renames: [{
225
+ current_external_id: "old_external_id",
226
+ new_external_id: "new_external_id",
227
+ }]
228
+ )
229
+ ```
230
+
231
+ #### Remove users' old deprecated external IDs
232
+ Note: you can send up to 50 external IDs per request.
233
+ ```ruby
234
+ api.remove_external_ids(external_ids: ['old_external_id'])
235
+ ```
236
+
218
237
  ### Email Sync
219
238
 
220
239
  #### Get List of or Query Email Unsubscribes
@@ -10,6 +10,8 @@ require 'braze_ruby/endpoints/delete_users'
10
10
  require 'braze_ruby/endpoints/campaigns'
11
11
  require 'braze_ruby/endpoints/canvas'
12
12
  require 'braze_ruby/endpoints/subscription'
13
+ require 'braze_ruby/endpoints/rename_external_ids'
14
+ require 'braze_ruby/endpoints/remove_external_ids'
13
15
 
14
16
  module BrazeRuby
15
17
  class API
@@ -26,6 +28,8 @@ module BrazeRuby
26
28
  include BrazeRuby::Endpoints::Subscription
27
29
  include BrazeRuby::Endpoints::IdentifyUsers
28
30
  include BrazeRuby::Endpoints::CreateUserAliases
31
+ include BrazeRuby::Endpoints::RenameExternalIds
32
+ include BrazeRuby::Endpoints::RemoveExternalIds
29
33
 
30
34
  def export_users(**payload)
31
35
  BrazeRuby::REST::ExportUsers.new(api_key, braze_url, options).perform(**payload)
@@ -8,3 +8,5 @@ require 'braze_ruby/endpoints/track_users'
8
8
  require 'braze_ruby/endpoints/delete_users'
9
9
  require 'braze_ruby/endpoints/identify_users'
10
10
  require 'braze_ruby/endpoints/create_user_aliases'
11
+ require 'braze_ruby/endpoints/rename_external_ids'
12
+ require 'braze_ruby/endpoints/remove_external_ids'
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module Endpoints
5
+ module RemoveExternalIds
6
+ attr_writer :remove_external_ids_service
7
+
8
+ def remove_external_ids(**payload)
9
+ remove_external_ids_service.perform(**payload)
10
+ end
11
+
12
+ private
13
+
14
+ def remove_external_ids_service
15
+ @remove_external_ids ||= BrazeRuby::REST::RemoveExternalIds.new(api_key, braze_url, options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module Endpoints
5
+ module RenameExternalIds
6
+ attr_writer :rename_external_ids_service
7
+
8
+ def rename_external_ids(**payload)
9
+ rename_external_ids_service.perform(**payload)
10
+ end
11
+
12
+ private
13
+
14
+ def rename_external_ids_service
15
+ @rename_external_ids ||= BrazeRuby::REST::RenameExternalIds.new(api_key, braze_url, options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -18,3 +18,5 @@ 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
20
  require 'braze_ruby/rest/create_user_aliases'
21
+ require 'braze_ruby/rest/rename_external_ids'
22
+ require 'braze_ruby/rest/remove_external_ids'
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module REST
5
+ class RemoveExternalIds < Base
6
+ def perform(external_ids: [])
7
+ http.post '/users/external_ids/remove', {
8
+ 'external_ids': external_ids
9
+ }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module REST
5
+ class RenameExternalIds < Base
6
+ def perform(external_id_renames: [])
7
+ http.post '/users/external_ids/rename', {
8
+ 'external_id_renames': external_id_renames
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.1'.freeze
4
+ VERSION = '0.4.2'.freeze
5
5
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe BrazeRuby::REST::RemoveExternalIds do
6
+ let(:http) { double(:http) }
7
+
8
+ let(:payload) { { external_ids: ['foo'] } }
9
+
10
+ let(:api_key) { :api_key }
11
+
12
+ subject { described_class.new :api_key, :rest_url, {}}
13
+
14
+ before { subject.http = http }
15
+
16
+ it 'makes an http call to the remove external ids endpoint' do
17
+ expect(http).to receive(:post).with '/users/external_ids/remove',
18
+ payload
19
+
20
+ subject.perform(**payload)
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe BrazeRuby::REST::RenameExternalIds do
6
+ let(:http) { double(:http) }
7
+
8
+ let(:payload) { { external_id_renames: [{ current_external_id: 'abc', new_external_id: 'foo' }] } }
9
+
10
+ let(:api_key) { :api_key }
11
+
12
+ subject { described_class.new :api_key, :rest_url, {}}
13
+
14
+ before { subject.http = http }
15
+
16
+ it 'makes an http call to the rename external ids endpoint' do
17
+ expect(http).to receive(:post).with '/users/external_ids/rename',
18
+ payload
19
+
20
+ subject.perform(**payload)
21
+ end
22
+ end
@@ -0,0 +1,67 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/external_ids/remove"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"external_ids":["abc"]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.4.1
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
+ - fff87872-0c9f-4447-8f75-a4486f719ba5
41
+ X-Runtime:
42
+ - '0.001435'
43
+ Accept-Ranges:
44
+ - bytes
45
+ Date:
46
+ - Wed, 17 Feb 2021 16:18:26 GMT
47
+ Via:
48
+ - 1.1 varnish
49
+ X-Served-By:
50
+ - cache-ams21045-AMS
51
+ X-Cache:
52
+ - MISS
53
+ X-Cache-Hits:
54
+ - '0'
55
+ X-Timer:
56
+ - S1613578706.459807,VS0,VE382
57
+ Vary:
58
+ - Origin,Accept-Encoding
59
+ Strict-Transport-Security:
60
+ - max-age=31536000; includeSubDomains
61
+ Transfer-Encoding:
62
+ - chunked
63
+ body:
64
+ encoding: ASCII-8BIT
65
+ string: '{"message":"Invalid API key: non-existent"}'
66
+ recorded_at: Wed, 17 Feb 2021 16:18:26 GMT
67
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/external_ids/remove"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"external_ids":["abc"]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.4.1
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-Type:
28
+ - application/json
29
+ Server:
30
+ - nginx
31
+ X-Ratelimit-Limit:
32
+ - '1000'
33
+ X-Ratelimit-Remaining:
34
+ - '999'
35
+ X-Ratelimit-Reset:
36
+ - '1613578740'
37
+ Etag:
38
+ - W/"da64f75988bb6d65ffcb9b3107fcc046"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ X-Request-Id:
42
+ - '03680848-33cc-443c-9cf8-a9b47ebb3938'
43
+ X-Runtime:
44
+ - '0.018449'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Date:
48
+ - Wed, 17 Feb 2021 16:18:25 GMT
49
+ Via:
50
+ - 1.1 varnish
51
+ X-Served-By:
52
+ - cache-ams21046-AMS
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1613578705.470198,VS0,VE406
59
+ Vary:
60
+ - Origin,Accept-Encoding
61
+ Strict-Transport-Security:
62
+ - max-age=31536000; includeSubDomains
63
+ Transfer-Encoding:
64
+ - chunked
65
+ body:
66
+ encoding: ASCII-8BIT
67
+ string: '{"removed_ids":["abc"],"removal_errors":[],"message":"success"}'
68
+ recorded_at: Wed, 17 Feb 2021 16:18:25 GMT
69
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/external_ids/remove"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"external_ids":["abc"]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.4.1
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-Type:
28
+ - application/json
29
+ Server:
30
+ - nginx
31
+ X-Ratelimit-Limit:
32
+ - '1000'
33
+ X-Ratelimit-Remaining:
34
+ - '998'
35
+ X-Ratelimit-Reset:
36
+ - '1613578740'
37
+ Etag:
38
+ - W/"9ecbe52521d0bc00a1add74d07debc00"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ X-Request-Id:
42
+ - 584c5e27-bf41-47a6-b89f-d91dfeffd118
43
+ X-Runtime:
44
+ - '0.020452'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Date:
48
+ - Wed, 17 Feb 2021 16:18:26 GMT
49
+ Via:
50
+ - 1.1 varnish
51
+ X-Served-By:
52
+ - cache-ams21056-AMS
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1613578706.952471,VS0,VE408
59
+ Vary:
60
+ - Origin,Accept-Encoding
61
+ Strict-Transport-Security:
62
+ - max-age=31536000; includeSubDomains
63
+ Transfer-Encoding:
64
+ - chunked
65
+ body:
66
+ encoding: ASCII-8BIT
67
+ string: '{"removed_ids":["abc"],"removal_errors":[],"message":"success"}'
68
+ recorded_at: Wed, 17 Feb 2021 16:18:26 GMT
69
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,67 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/external_ids/rename"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"external_id_renames":[{"current_external_id":"abc","new_external_id":"foo"}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.4.1
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
+ - d10d6940-3d0a-4b3c-b232-41b0dcf660d9
41
+ X-Runtime:
42
+ - '0.001364'
43
+ Accept-Ranges:
44
+ - bytes
45
+ Date:
46
+ - Wed, 17 Feb 2021 16:15:49 GMT
47
+ Via:
48
+ - 1.1 varnish
49
+ X-Served-By:
50
+ - cache-ams21077-AMS
51
+ X-Cache:
52
+ - MISS
53
+ X-Cache-Hits:
54
+ - '0'
55
+ X-Timer:
56
+ - S1613578549.095990,VS0,VE391
57
+ Vary:
58
+ - Origin,Accept-Encoding
59
+ Strict-Transport-Security:
60
+ - max-age=31536000; includeSubDomains
61
+ Transfer-Encoding:
62
+ - chunked
63
+ body:
64
+ encoding: ASCII-8BIT
65
+ string: '{"message":"Invalid API key: non-existent"}'
66
+ recorded_at: Wed, 17 Feb 2021 16:15:49 GMT
67
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/external_ids/rename"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"external_id_renames":[{"current_external_id":"abc","new_external_id":"foo"}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.4.1
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-Type:
28
+ - application/json
29
+ Server:
30
+ - nginx
31
+ X-Ratelimit-Limit:
32
+ - '1000'
33
+ X-Ratelimit-Remaining:
34
+ - '999'
35
+ X-Ratelimit-Reset:
36
+ - '1613578560'
37
+ Etag:
38
+ - W/"fa9b69f39f6fa9a3275d0ef31fcd5849"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ X-Request-Id:
42
+ - 34e17828-c6ce-491d-b0fc-7336348443d3
43
+ X-Runtime:
44
+ - '0.029726'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Date:
48
+ - Wed, 17 Feb 2021 16:15:48 GMT
49
+ Via:
50
+ - 1.1 varnish
51
+ X-Served-By:
52
+ - cache-ams21067-AMS
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1613578548.175096,VS0,VE389
59
+ Vary:
60
+ - Origin,Accept-Encoding
61
+ Strict-Transport-Security:
62
+ - max-age=31536000; includeSubDomains
63
+ Transfer-Encoding:
64
+ - chunked
65
+ body:
66
+ encoding: ASCII-8BIT
67
+ string: '{"rename_errors":[],"external_ids":[{"current_external_id":"abc","new_external_id":"foo"}],"message":"success"}'
68
+ recorded_at: Wed, 17 Feb 2021 16:15:48 GMT
69
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/external_ids/rename"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"external_id_renames":[{"current_external_id":"abc","new_external_id":"foo"}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Braze Ruby gem v0.4.1
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-Type:
28
+ - application/json
29
+ Server:
30
+ - nginx
31
+ X-Ratelimit-Limit:
32
+ - '1000'
33
+ X-Ratelimit-Remaining:
34
+ - '998'
35
+ X-Ratelimit-Reset:
36
+ - '1613578560'
37
+ Etag:
38
+ - W/"a9c3c0562b37c07a68d9efb65c83b0ac"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ X-Request-Id:
42
+ - 29237f90-93bf-42d1-9779-ab337284b6aa
43
+ X-Runtime:
44
+ - '0.011804'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Date:
48
+ - Wed, 17 Feb 2021 16:15:49 GMT
49
+ Via:
50
+ - 1.1 varnish
51
+ X-Served-By:
52
+ - cache-ams21022-AMS
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1613578549.641027,VS0,VE361
59
+ Vary:
60
+ - Origin,Accept-Encoding
61
+ Strict-Transport-Security:
62
+ - max-age=31536000; includeSubDomains
63
+ Transfer-Encoding:
64
+ - chunked
65
+ body:
66
+ encoding: ASCII-8BIT
67
+ string: '{"rename_errors":[],"external_ids":[{"current_external_id":"abc","new_external_id":"foo"}],"message":"success"}'
68
+ recorded_at: Wed, 17 Feb 2021 16:15:49 GMT
69
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'remove external ids' do
6
+ let(:external_ids) { { external_ids: ['abc'] } }
7
+
8
+ subject(:remove_external_ids) do
9
+ api.remove_external_ids(external_ids)
10
+ end
11
+
12
+ context 'with success', vcr: true do
13
+ it 'responds with created' do
14
+ expect(remove_external_ids.status).to be 201
15
+ end
16
+
17
+ it 'responds with success message' do
18
+ expect(JSON.parse(remove_external_ids.body)).to include(
19
+ 'removed_ids' => ['abc'],
20
+ 'removal_errors' => [],
21
+ 'message' => 'success'
22
+ )
23
+ end
24
+ end
25
+
26
+ context 'unauthorized', vcr: true do
27
+ let(:api_key) { 'non-existent' }
28
+
29
+ it 'responds with unauthorized' do
30
+ expect(remove_external_ids.status).to be 401
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'rename external ids' do
6
+ let(:external_id_renames) { { external_id_renames: [{ current_external_id: 'abc', new_external_id: 'foo' }] } }
7
+
8
+ subject(:rename_external_ids) do
9
+ api.rename_external_ids(external_id_renames)
10
+ end
11
+
12
+ context 'with success', vcr: true do
13
+ it 'responds with created' do
14
+ expect(rename_external_ids.status).to be 201
15
+ end
16
+
17
+ it 'responds with success message' do
18
+ expect(JSON.parse(rename_external_ids.body)).to include(
19
+ 'external_ids' => [
20
+ hash_including(
21
+ 'current_external_id' => 'abc',
22
+ 'new_external_id' => 'foo'
23
+ ),],
24
+ 'rename_errors' => [],
25
+ 'message' => 'success'
26
+ )
27
+ end
28
+ end
29
+
30
+ context 'unauthorized', vcr: true do
31
+ let(:api_key) { 'non-existent' }
32
+
33
+ it 'responds with unauthorized' do
34
+ expect(rename_external_ids.status).to be 401
35
+ end
36
+ end
37
+ 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.1
4
+ version: 0.4.2
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: 2021-01-31 00:00:00.000000000 Z
13
+ date: 2021-02-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -167,6 +167,8 @@ files:
167
167
  - lib/braze_ruby/endpoints/email_status.rb
168
168
  - lib/braze_ruby/endpoints/email_sync.rb
169
169
  - lib/braze_ruby/endpoints/identify_users.rb
170
+ - lib/braze_ruby/endpoints/remove_external_ids.rb
171
+ - lib/braze_ruby/endpoints/rename_external_ids.rb
170
172
  - lib/braze_ruby/endpoints/schedule_messages.rb
171
173
  - lib/braze_ruby/endpoints/send_messages.rb
172
174
  - lib/braze_ruby/endpoints/subscription.rb
@@ -183,6 +185,8 @@ files:
183
185
  - lib/braze_ruby/rest/export_users.rb
184
186
  - lib/braze_ruby/rest/identify_users.rb
185
187
  - lib/braze_ruby/rest/list_segments.rb
188
+ - lib/braze_ruby/rest/remove_external_ids.rb
189
+ - lib/braze_ruby/rest/rename_external_ids.rb
186
190
  - lib/braze_ruby/rest/schedule_messages.rb
187
191
  - lib/braze_ruby/rest/send_messages.rb
188
192
  - lib/braze_ruby/rest/subscription_status_get.rb
@@ -201,6 +205,8 @@ files:
201
205
  - spec/braze_ruby/rest/email_status_spec.rb
202
206
  - spec/braze_ruby/rest/export_users_spec.rb
203
207
  - spec/braze_ruby/rest/identify_users_spec.rb
208
+ - spec/braze_ruby/rest/remove_external_ids_spec.rb
209
+ - spec/braze_ruby/rest/rename_external_ids_spec.rb
204
210
  - spec/braze_ruby/rest/schedule_messages_spec.rb
205
211
  - spec/braze_ruby/rest/send_messages_spec.rb
206
212
  - spec/braze_ruby/rest/track_users_spec.rb
@@ -228,6 +234,12 @@ files:
228
234
  - spec/fixtures/responses/identify_users/with_success/responds_with_success_message.yml
229
235
  - spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml
230
236
  - spec/fixtures/responses/list_segments/with_success/responds_with_success.yml
237
+ - spec/fixtures/responses/remove_external_ids/unauthorized/responds_with_unauthorized.yml
238
+ - spec/fixtures/responses/remove_external_ids/with_success/responds_with_created.yml
239
+ - spec/fixtures/responses/remove_external_ids/with_success/responds_with_success_message.yml
240
+ - spec/fixtures/responses/rename_external_ids/unauthorized/responds_with_unauthorized.yml
241
+ - spec/fixtures/responses/rename_external_ids/with_success/responds_with_created.yml
242
+ - spec/fixtures/responses/rename_external_ids/with_success/responds_with_success_message.yml
231
243
  - spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml
232
244
  - spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml
233
245
  - spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml
@@ -252,6 +264,8 @@ files:
252
264
  - spec/integrations/export_users_spec.rb
253
265
  - spec/integrations/identify_users_spec.rb
254
266
  - spec/integrations/list_segments_spec.rb
267
+ - spec/integrations/remove_external_ids_spec.rb
268
+ - spec/integrations/rename_external_ids_spec.rb
255
269
  - spec/integrations/schedule_messages_spec.rb
256
270
  - spec/integrations/send_messages_spec.rb
257
271
  - spec/integrations/subscription_spec.rb
@@ -296,6 +310,8 @@ test_files:
296
310
  - spec/braze_ruby/rest/email_status_spec.rb
297
311
  - spec/braze_ruby/rest/export_users_spec.rb
298
312
  - spec/braze_ruby/rest/identify_users_spec.rb
313
+ - spec/braze_ruby/rest/remove_external_ids_spec.rb
314
+ - spec/braze_ruby/rest/rename_external_ids_spec.rb
299
315
  - spec/braze_ruby/rest/schedule_messages_spec.rb
300
316
  - spec/braze_ruby/rest/send_messages_spec.rb
301
317
  - spec/braze_ruby/rest/track_users_spec.rb
@@ -323,6 +339,12 @@ test_files:
323
339
  - spec/fixtures/responses/identify_users/with_success/responds_with_success_message.yml
324
340
  - spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml
325
341
  - spec/fixtures/responses/list_segments/with_success/responds_with_success.yml
342
+ - spec/fixtures/responses/remove_external_ids/unauthorized/responds_with_unauthorized.yml
343
+ - spec/fixtures/responses/remove_external_ids/with_success/responds_with_created.yml
344
+ - spec/fixtures/responses/remove_external_ids/with_success/responds_with_success_message.yml
345
+ - spec/fixtures/responses/rename_external_ids/unauthorized/responds_with_unauthorized.yml
346
+ - spec/fixtures/responses/rename_external_ids/with_success/responds_with_created.yml
347
+ - spec/fixtures/responses/rename_external_ids/with_success/responds_with_success_message.yml
326
348
  - spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml
327
349
  - spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml
328
350
  - spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml
@@ -347,6 +369,8 @@ test_files:
347
369
  - spec/integrations/export_users_spec.rb
348
370
  - spec/integrations/identify_users_spec.rb
349
371
  - spec/integrations/list_segments_spec.rb
372
+ - spec/integrations/remove_external_ids_spec.rb
373
+ - spec/integrations/rename_external_ids_spec.rb
350
374
  - spec/integrations/schedule_messages_spec.rb
351
375
  - spec/integrations/send_messages_spec.rb
352
376
  - spec/integrations/subscription_spec.rb