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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +14 -3
- data/Gemfile.lock +38 -38
- data/braze_ruby.gemspec +6 -6
- data/lib/braze_ruby/api.rb +2 -2
- data/lib/braze_ruby/endpoints/campaigns.rb +1 -1
- data/lib/braze_ruby/endpoints/canvas.rb +2 -2
- data/lib/braze_ruby/endpoints/delete_users.rb +2 -2
- data/lib/braze_ruby/endpoints/email_status.rb +1 -1
- data/lib/braze_ruby/endpoints/email_sync.rb +2 -2
- data/lib/braze_ruby/endpoints/identify_users.rb +2 -2
- data/lib/braze_ruby/endpoints/schedule_messages.rb +1 -1
- data/lib/braze_ruby/endpoints/send_messages.rb +1 -1
- data/lib/braze_ruby/endpoints/subscription.rb +3 -3
- data/lib/braze_ruby/endpoints/track_users.rb +5 -5
- data/lib/braze_ruby/http.rb +8 -6
- data/lib/braze_ruby/rest/base.rb +4 -3
- data/lib/braze_ruby/rest/canvas_details.rb +2 -4
- data/lib/braze_ruby/rest/delete_users.rb +1 -2
- data/lib/braze_ruby/rest/email_hard_bounces.rb +2 -4
- data/lib/braze_ruby/rest/email_status.rb +2 -4
- data/lib/braze_ruby/rest/email_unsubscribes.rb +2 -4
- data/lib/braze_ruby/rest/export_users.rb +5 -7
- data/lib/braze_ruby/rest/identify_users.rb +2 -3
- data/lib/braze_ruby/rest/list_segments.rb +2 -4
- data/lib/braze_ruby/rest/schedule_messages.rb +2 -4
- data/lib/braze_ruby/rest/send_messages.rb +2 -4
- data/lib/braze_ruby/rest/subscription_status_get.rb +2 -4
- data/lib/braze_ruby/rest/subscription_status_set.rb +2 -4
- data/lib/braze_ruby/rest/subscription_user_status.rb +2 -4
- data/lib/braze_ruby/rest/track_users.rb +1 -2
- data/lib/braze_ruby/rest/trigger_campaign_send.rb +3 -7
- data/lib/braze_ruby/rest/trigger_canvas_send.rb +2 -4
- data/lib/braze_ruby/version.rb +1 -1
- data/spec/braze_ruby/endpoints/delete_users_spec.rb +1 -1
- data/spec/braze_ruby/endpoints/track_users_spec.rb +8 -8
- data/spec/braze_ruby/http_spec.rb +7 -4
- data/spec/braze_ruby/rest/delete_users_spec.rb +3 -3
- data/spec/braze_ruby/rest/email_status_spec.rb +0 -1
- data/spec/braze_ruby/rest/export_users_spec.rb +3 -3
- data/spec/braze_ruby/rest/identify_users_spec.rb +3 -3
- data/spec/braze_ruby/rest/schedule_messages_spec.rb +1 -2
- data/spec/braze_ruby/rest/send_messages_spec.rb +6 -13
- data/spec/braze_ruby/rest/track_users_spec.rb +10 -9
- data/spec/fixtures/responses/campaigns/trigger_send/sends_an_email.yml +17 -15
- data/spec/fixtures/responses/canvas/details/returns_error_when_no_canvas.yml +16 -14
- data/spec/fixtures/responses/canvas/trigger_send/sends_a_canvas.yml +18 -16
- data/spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml +20 -18
- data/spec/fixtures/responses/delete_users/with_success/responds_with_created.yml +25 -23
- data/spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml +25 -23
- data/spec/fixtures/responses/email_status/existing_email/responds_with_created.yml +22 -20
- data/spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml +22 -20
- data/spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml +22 -20
- data/spec/fixtures/responses/email_status/unknown_email/responds_with_success_message.yml +22 -20
- data/spec/fixtures/responses/email_sync/hard_bounces/responds_with_empty_array_when_no_hard_bounces.yml +18 -16
- data/spec/fixtures/responses/email_sync/unsubscribes/responds_with_empty_array_when_no_unsubscribes.yml +18 -16
- data/spec/fixtures/responses/email_sync/unsubscribes/responds_with_unsubscribed_emails.yml +21 -20
- data/spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml +25 -22
- data/spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml +24 -22
- data/spec/fixtures/responses/identify_users/unauthorized/responds_with_unauthorized.yml +10 -8
- data/spec/fixtures/responses/identify_users/with_success/responds_with_created.yml +12 -10
- data/spec/fixtures/responses/identify_users/with_success/responds_with_success_message.yml +12 -10
- data/spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml +35 -35
- data/spec/fixtures/responses/list_segments/with_success/responds_with_success.yml +35 -35
- data/spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml +20 -19
- data/spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml +24 -23
- data/spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml +24 -23
- data/spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml +20 -18
- data/spec/fixtures/responses/send_messages/with_success/responds_with_created.yml +24 -22
- data/spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml +24 -22
- data/spec/fixtures/responses/subscription/subscription_status_set/when_subscribing/subscribes_the_user.yml +16 -14
- data/spec/fixtures/responses/subscription/subscription_status_set/when_subscription_group_does_not_exist/returns_an_error_status.yml +16 -14
- data/spec/fixtures/responses/subscription/subscription_status_set/when_unsubscribing/unsubscribes_the_user.yml +32 -28
- 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
- data/spec/fixtures/responses/subscription/when_getting_subscription_group_statuses/subscription_status_get/when_group_does_not_exist/returns_an_error.yml +48 -42
- data/spec/fixtures/responses/subscription/when_getting_subscription_group_statuses/subscription_user_status/returns_subscription_groups_and_status_for_every_group.yml +50 -46
- data/spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml +23 -21
- data/spec/fixtures/responses/track_users/with_success/responds_with_created.yml +22 -20
- data/spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml +22 -20
- data/spec/integrations/campaigns_spec.rb +4 -2
- data/spec/integrations/canvas_spec.rb +4 -2
- data/spec/integrations/delete_users_spec.rb +1 -0
- data/spec/integrations/email_sync_spec.rb +2 -2
- data/spec/integrations/export_users_spec.rb +2 -2
- data/spec/integrations/identify_users_spec.rb +1 -1
- data/spec/integrations/list_segments_spec.rb +1 -1
- data/spec/integrations/schedule_messages_spec.rb +2 -1
- data/spec/integrations/send_messages_spec.rb +2 -1
- data/spec/integrations/subscription_spec.rb +7 -7
- data/spec/integrations/track_users_spec.rb +1 -0
- data/spec/spec_helper.rb +0 -8
- data/spec/support/vcr.rb +3 -1
- 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: '
|
9
|
+
campaign_id: 'd8b73da7-0b7c-fc72-1d80-e59c7f20f0d3',
|
10
10
|
recipients: [
|
11
|
-
external_user_id:
|
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: '
|
9
|
+
canvas_id: '70a7fb99-cbcb-451a-8224-5f8b8c63e03f',
|
10
10
|
recipients: [
|
11
|
-
external_user_id:
|
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
|
|
@@ -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: '
|
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('
|
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: [
|
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) {
|
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:
|
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])
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe 'send messages' do
|
6
|
-
let(:user_ids) { [
|
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) { '
|
7
|
-
let(:subscribed_user) { 'test-
|
8
|
-
let(:unsubscribed_user) { 'test-
|
9
|
-
let(:never_subscribed_user) { 'test-
|
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-
|
87
|
-
'test-
|
88
|
-
'test-
|
86
|
+
'test-user-1' => 'Subscribed',
|
87
|
+
'test-user-2' => 'Unsubscribed',
|
88
|
+
'test-user-3' => 'unknown'
|
89
89
|
}
|
90
90
|
)
|
91
91
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -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
|
data/spec/support/vcr.rb
CHANGED
@@ -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.
|
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-
|
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
|
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
|
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.
|
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,
|