braze_ruby 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +14 -3
  3. data/Gemfile.lock +38 -38
  4. data/braze_ruby.gemspec +6 -6
  5. data/lib/braze_ruby/api.rb +2 -2
  6. data/lib/braze_ruby/endpoints/campaigns.rb +1 -1
  7. data/lib/braze_ruby/endpoints/canvas.rb +2 -2
  8. data/lib/braze_ruby/endpoints/delete_users.rb +2 -2
  9. data/lib/braze_ruby/endpoints/email_status.rb +1 -1
  10. data/lib/braze_ruby/endpoints/email_sync.rb +2 -2
  11. data/lib/braze_ruby/endpoints/identify_users.rb +2 -2
  12. data/lib/braze_ruby/endpoints/schedule_messages.rb +1 -1
  13. data/lib/braze_ruby/endpoints/send_messages.rb +1 -1
  14. data/lib/braze_ruby/endpoints/subscription.rb +3 -3
  15. data/lib/braze_ruby/endpoints/track_users.rb +5 -5
  16. data/lib/braze_ruby/http.rb +8 -6
  17. data/lib/braze_ruby/rest/base.rb +4 -3
  18. data/lib/braze_ruby/rest/canvas_details.rb +2 -4
  19. data/lib/braze_ruby/rest/delete_users.rb +1 -2
  20. data/lib/braze_ruby/rest/email_hard_bounces.rb +2 -4
  21. data/lib/braze_ruby/rest/email_status.rb +2 -4
  22. data/lib/braze_ruby/rest/email_unsubscribes.rb +2 -4
  23. data/lib/braze_ruby/rest/export_users.rb +5 -7
  24. data/lib/braze_ruby/rest/identify_users.rb +2 -3
  25. data/lib/braze_ruby/rest/list_segments.rb +2 -4
  26. data/lib/braze_ruby/rest/schedule_messages.rb +2 -4
  27. data/lib/braze_ruby/rest/send_messages.rb +2 -4
  28. data/lib/braze_ruby/rest/subscription_status_get.rb +2 -4
  29. data/lib/braze_ruby/rest/subscription_status_set.rb +2 -4
  30. data/lib/braze_ruby/rest/subscription_user_status.rb +2 -4
  31. data/lib/braze_ruby/rest/track_users.rb +1 -2
  32. data/lib/braze_ruby/rest/trigger_campaign_send.rb +3 -7
  33. data/lib/braze_ruby/rest/trigger_canvas_send.rb +2 -4
  34. data/lib/braze_ruby/version.rb +1 -1
  35. data/spec/braze_ruby/endpoints/delete_users_spec.rb +1 -1
  36. data/spec/braze_ruby/endpoints/track_users_spec.rb +8 -8
  37. data/spec/braze_ruby/http_spec.rb +7 -4
  38. data/spec/braze_ruby/rest/delete_users_spec.rb +3 -3
  39. data/spec/braze_ruby/rest/email_status_spec.rb +0 -1
  40. data/spec/braze_ruby/rest/export_users_spec.rb +3 -3
  41. data/spec/braze_ruby/rest/identify_users_spec.rb +3 -3
  42. data/spec/braze_ruby/rest/schedule_messages_spec.rb +1 -2
  43. data/spec/braze_ruby/rest/send_messages_spec.rb +6 -13
  44. data/spec/braze_ruby/rest/track_users_spec.rb +10 -9
  45. data/spec/fixtures/responses/campaigns/trigger_send/sends_an_email.yml +17 -15
  46. data/spec/fixtures/responses/canvas/details/returns_error_when_no_canvas.yml +16 -14
  47. data/spec/fixtures/responses/canvas/trigger_send/sends_a_canvas.yml +18 -16
  48. data/spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml +20 -18
  49. data/spec/fixtures/responses/delete_users/with_success/responds_with_created.yml +25 -23
  50. data/spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml +25 -23
  51. data/spec/fixtures/responses/email_status/existing_email/responds_with_created.yml +22 -20
  52. data/spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml +22 -20
  53. data/spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml +22 -20
  54. data/spec/fixtures/responses/email_status/unknown_email/responds_with_success_message.yml +22 -20
  55. data/spec/fixtures/responses/email_sync/hard_bounces/responds_with_empty_array_when_no_hard_bounces.yml +18 -16
  56. data/spec/fixtures/responses/email_sync/unsubscribes/responds_with_empty_array_when_no_unsubscribes.yml +18 -16
  57. data/spec/fixtures/responses/email_sync/unsubscribes/responds_with_unsubscribed_emails.yml +21 -20
  58. data/spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml +25 -22
  59. data/spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml +24 -22
  60. data/spec/fixtures/responses/identify_users/unauthorized/responds_with_unauthorized.yml +10 -8
  61. data/spec/fixtures/responses/identify_users/with_success/responds_with_created.yml +12 -10
  62. data/spec/fixtures/responses/identify_users/with_success/responds_with_success_message.yml +12 -10
  63. data/spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml +35 -35
  64. data/spec/fixtures/responses/list_segments/with_success/responds_with_success.yml +35 -35
  65. data/spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml +20 -19
  66. data/spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml +24 -23
  67. data/spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml +24 -23
  68. data/spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml +20 -18
  69. data/spec/fixtures/responses/send_messages/with_success/responds_with_created.yml +24 -22
  70. data/spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml +24 -22
  71. data/spec/fixtures/responses/subscription/subscription_status_set/when_subscribing/subscribes_the_user.yml +16 -14
  72. data/spec/fixtures/responses/subscription/subscription_status_set/when_subscription_group_does_not_exist/returns_an_error_status.yml +16 -14
  73. data/spec/fixtures/responses/subscription/subscription_status_set/when_unsubscribing/unsubscribes_the_user.yml +32 -28
  74. data/spec/fixtures/responses/subscription/when_getting_subscription_group_statuses/subscription_status_get/when_checking_subscribed_and_unsubscribed_user_status/returns_only_users_that_were_once_subscribed.yml +50 -44
  75. data/spec/fixtures/responses/subscription/when_getting_subscription_group_statuses/subscription_status_get/when_group_does_not_exist/returns_an_error.yml +48 -42
  76. data/spec/fixtures/responses/subscription/when_getting_subscription_group_statuses/subscription_user_status/returns_subscription_groups_and_status_for_every_group.yml +50 -46
  77. data/spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml +23 -21
  78. data/spec/fixtures/responses/track_users/with_success/responds_with_created.yml +22 -20
  79. data/spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml +22 -20
  80. data/spec/integrations/campaigns_spec.rb +4 -2
  81. data/spec/integrations/canvas_spec.rb +4 -2
  82. data/spec/integrations/delete_users_spec.rb +1 -0
  83. data/spec/integrations/email_sync_spec.rb +2 -2
  84. data/spec/integrations/export_users_spec.rb +2 -2
  85. data/spec/integrations/identify_users_spec.rb +1 -1
  86. data/spec/integrations/list_segments_spec.rb +1 -1
  87. data/spec/integrations/schedule_messages_spec.rb +2 -1
  88. data/spec/integrations/send_messages_spec.rb +2 -1
  89. data/spec/integrations/subscription_spec.rb +7 -7
  90. data/spec/integrations/track_users_spec.rb +1 -0
  91. data/spec/spec_helper.rb +0 -8
  92. data/spec/support/vcr.rb +3 -1
  93. metadata +15 -15
@@ -6,12 +6,14 @@ RSpec.describe 'campaigns' do
6
6
  describe 'trigger_send' do
7
7
  it 'sends an email', vcr: true do
8
8
  response = api.trigger_campaign_send(
9
- campaign_id: '69e9b681-779c-4b4c-b6b8-cd74b17d21d2',
9
+ campaign_id: 'd8b73da7-0b7c-fc72-1d80-e59c7f20f0d3',
10
10
  recipients: [
11
- external_user_id: 132404,
11
+ external_user_id: 12345,
12
12
  trigger_properties: {first_name: 'John'}
13
13
  ]
14
14
  )
15
+
16
+ expect(response.success?).to eq(true)
15
17
  end
16
18
  end
17
19
  end
@@ -6,12 +6,14 @@ RSpec.describe 'canvas' do
6
6
  describe 'trigger_send' do
7
7
  it 'sends a canvas', vcr: true do
8
8
  response = api.trigger_canvas_send(
9
- canvas_id: 'dc23ade4-e970-0c52-81bc-b369f64f533d',
9
+ canvas_id: '70a7fb99-cbcb-451a-8224-5f8b8c63e03f',
10
10
  recipients: [
11
- external_user_id: 132404,
11
+ external_user_id: 12345,
12
12
  canvas_entry_properties: {first_name: 'John'}
13
13
  ]
14
14
  )
15
+
16
+ expect(response.success?).to eq(true)
15
17
  end
16
18
  end
17
19
 
@@ -16,6 +16,7 @@ describe 'delete users' do
16
16
 
17
17
  it 'responds with success message' do
18
18
  expect(JSON.parse(delete_users.body)).to include(
19
+ 'deleted' => 3,
19
20
  'message' => 'success'
20
21
  )
21
22
  end
@@ -5,11 +5,11 @@ require 'spec_helper'
5
5
  RSpec.describe 'email sync' do
6
6
  describe 'unsubscribes' do
7
7
  it 'responds with unsubscribed emails', vcr: true do
8
- response = api.email_unsubscribes(start_date: '2019-03-20', end_date: '2019-03-25')
8
+ response = api.email_unsubscribes(start_date: '2020-06-17', end_date: '2020-06-18')
9
9
  emails = JSON.parse(response.body)['emails']
10
10
 
11
11
  expect(emails.size).to eq(1)
12
- expect(emails.first['email']).to eq('wojtek@test.com')
12
+ expect(emails.first['email']).to eq('example@123.com')
13
13
  end
14
14
 
15
15
  it 'responds with empty array when no unsubscribes', vcr: true do
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe 'export users' do
6
6
  context 'by ids' do
7
- subject(:export_users) { api.export_users(external_ids: [1]) }
7
+ subject(:export_users) { api.export_users(external_ids: [12345]) }
8
8
 
9
9
  context 'with success', :vcr do
10
10
  it 'responds with created' do
@@ -15,7 +15,7 @@ describe 'export users' do
15
15
 
16
16
  context 'by segment' do
17
17
  context 'with success', :vcr do
18
- let(:segment_id) { braze_test_segment }
18
+ let(:segment_id) { "3aca937b-9bbc-4e42-9370-05e411967b2b" }
19
19
 
20
20
  subject(:export_users) do
21
21
  api.export_users(segment_id: segment_id, callback_endpoint: 'https://example.com')
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'identify users' do
6
- let(:user) { { external_id: 400, user_alias: { alias_name: 'abc', alias_label: 'foo' } } }
6
+ let(:user) { { external_id: 12345, user_alias: { alias_name: 'abc', alias_label: 'foo' } } }
7
7
 
8
8
  subject(:identify_users) do
9
9
  api.identify_users(aliases_to_identify: [user])
@@ -11,7 +11,7 @@ describe 'list segments' do
11
11
  end
12
12
 
13
13
  it 'responds with a list of segments' do
14
- expect(segments.count).to be 13
14
+ expect(segments.count).to be 6
15
15
  end
16
16
 
17
17
  def segments
@@ -3,7 +3,8 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'schedule messages' do
6
- let(:user_ids) { [1] }
6
+ let(:user_ids) { [12345] }
7
+ let(:test_time) { "2020-08-07T00:00:00+02:00" }
7
8
  let(:messages) { build(:messages) }
8
9
 
9
10
  subject(:schedule_messages) do
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'send messages' do
6
- let(:user_ids) { [1] }
6
+ let(:user_ids) { [12345] }
7
7
  let(:messages) { build(:messages) }
8
8
 
9
9
  subject(:send_messages) do
@@ -17,6 +17,7 @@ describe 'send messages' do
17
17
 
18
18
  it 'responds with success message' do
19
19
  expect(JSON.parse(send_messages.body)).to eq(
20
+ 'dispatch_id' => "ea0532cddfc97cd4e5767b351d6af0eb",
20
21
  'message' => 'success'
21
22
  )
22
23
  end
@@ -3,10 +3,10 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe 'subscription', vcr: true do
6
- let(:subscription_group_id) { '0201b87a-ef6e-4410-9412-a298c4c1206d' }
7
- let(:subscribed_user) { 'test-gem-001' }
8
- let(:unsubscribed_user) { 'test-gem-002' }
9
- let(:never_subscribed_user) { 'test-gem-003' }
6
+ let(:subscription_group_id) { 'ed06e19a-69b1-4f9b-a452-2db2c4e303a8' }
7
+ let(:subscribed_user) { 'test-user-1' }
8
+ let(:unsubscribed_user) { 'test-user-2' }
9
+ let(:never_subscribed_user) { 'test-user-3' }
10
10
 
11
11
  context 'when getting subscription group statuses' do
12
12
  let(:json_response) { JSON.parse(response.body) }
@@ -83,9 +83,9 @@ RSpec.describe 'subscription', vcr: true do
83
83
  expect(json_response).to eq(
84
84
  'message' => 'success',
85
85
  'status' => {
86
- 'test-gem-001' => 'Subscribed',
87
- 'test-gem-002' => 'Unsubscribed',
88
- 'test-gem-003' => 'unknown'
86
+ 'test-user-1' => 'Subscribed',
87
+ 'test-user-2' => 'Unsubscribed',
88
+ 'test-user-3' => 'unknown'
89
89
  }
90
90
  )
91
91
  end
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe 'track users' do
6
6
  let(:attributes) { [build(:attribute)] }
7
+ let(:test_time) { Time.parse('2019-02-15 00:00:00 -0500') }
7
8
  let(:events) { [build(:event, time: test_time)] }
8
9
  let(:purchases) { [build(:purchase, time: test_time)] }
9
10
 
@@ -15,10 +15,6 @@ BRAZE_REST_API_KEY = ENV.fetch('BRAZE_REST_API_KEY', 'test')
15
15
  BRAZE_REST_URL = ENV.fetch('BRAZE_REST_URL', 'https://rest.iad-03.braze.com')
16
16
 
17
17
  RSpec.configure do |config|
18
- def test_time
19
- Time.parse('2019-02-15 00:00:00 -0500')
20
- end
21
-
22
18
  def braze_rest_api_key
23
19
  BRAZE_REST_API_KEY
24
20
  end
@@ -26,8 +22,4 @@ RSpec.configure do |config|
26
22
  def braze_rest_url
27
23
  BRAZE_REST_URL
28
24
  end
29
-
30
- def braze_test_segment
31
- 'a8fde797-4c44-4406-8e6c-5850d323f169'
32
- end
33
25
  end
@@ -9,7 +9,9 @@ VCR.configure do |config|
9
9
  config.cassette_library_dir = 'spec/fixtures/responses'
10
10
 
11
11
  config.default_cassette_options = {
12
- match_requests_on: [:method, :uri, :body]
12
+ match_requests_on: [:method, :uri, :body],
13
+ record: :once,
14
+ allow_unused_http_interactions: false
13
15
  }
14
16
 
15
17
  config.configure_rspec_metadata!
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.3
4
+ version: 0.4.0
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-02-04 00:00:00.000000000 Z
13
+ date: 2020-06-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -44,14 +44,14 @@ dependencies:
44
44
  name: rake
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: 12.3.3
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: 12.3.3
57
57
  - !ruby/object:Gem::Dependency
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 3.8.0
63
+ version: '3.8'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: 3.8.0
70
+ version: '3.8'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: dotenv
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -86,56 +86,56 @@ dependencies:
86
86
  name: vcr
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - "~>"
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: 5.0.0
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - "~>"
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: 5.0.0
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: webmock
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - "~>"
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: 3.7.5
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - "~>"
110
+ - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: 3.7.5
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: pry
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - "~>"
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: 0.12.2
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - "~>"
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: 0.12.2
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: factory_bot
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - "~>"
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: 5.1.0
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - "~>"
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: 5.1.0
141
141
  description: Braze wrapper
@@ -274,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
274
  - !ruby/object:Gem::Version
275
275
  version: '0'
276
276
  requirements: []
277
- rubygems_version: 3.0.1
277
+ rubygems_version: 3.1.2
278
278
  signing_key:
279
279
  specification_version: 4
280
280
  summary: A wrapper for the Braze REST API forked from the appboy gem, track users/events/purchases,