appboy 0.1.5 → 0.1.6

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: e2539aee6f4676b905088a742fd7f4483940c1dd92357bb90b80429c9c8f39be
4
- data.tar.gz: f50416d403099d46c0756415e532f0bf756a63bcc81ed46a5c6f7d1738e2e303
3
+ metadata.gz: 40adbe58a4c6aa0fc54d42723bd422307cb4a07ca7d4b9c6eeb4c0832c03ba61
4
+ data.tar.gz: 970578c0bae8fe4486fe6ba5c183573fc8bdcac07e9dc5affd17d5b01abfea4d
5
5
  SHA512:
6
- metadata.gz: 86539b94ede05d465e58499621ed49b10779a2bf3ecf4c6d175f0cd7c03c1987b5c03122a7d0b1ad09cee2d1b5e2fd7e2a0359d15ea78588a6cf9a11ce667495
7
- data.tar.gz: 2a95b92212b4e434257edf59c5c0dd18287b328c6222c14da6a5b31b1f3616398ee4556d61af1dae894146b1a3c2b113c475f4a2ef9bed6a32cac6fd2d745dd8
6
+ metadata.gz: 38e72090668868edad059635cf35d74087a97cfe653e9e5d5abeb61e5b51ddc6e6b9cd28bae8f43f06658539c69debb0bac3f1af7b67dc619f8b6bdbbc8f77b9
7
+ data.tar.gz: 99f58e65afbd21443d00602d343e8e79dce2178d5b848fcd5af752eed69adc90ef86b83c12a870ec3f2528ac90f61dee68a5867818ad86033c1624828b7ce01e
data/README.md CHANGED
@@ -27,12 +27,12 @@ api = Appboy::API.new('<app-group-id>')
27
27
  By default Appboy will be using 'https://api.appboy.com' as the default REST API base url, but you can override this base url by setting the env variable `APPBOY_REST_BASE_URL`. E.G.
28
28
 
29
29
  ```
30
- APPBOY_REST_BASE_URL="https://rest.iad-01.braze.com"
30
+ APPBOY_REST_BASE_URL="https://rest.iad-01.braze.com"
31
31
  ```
32
32
 
33
33
  ### Track User Attributes
34
34
 
35
- See: [User Attributes Object Specification](https://documentation.appboy.com/REST_APIs/User_Data#user-attribute-object)
35
+ See: [User Attributes Object Specification](https://www.braze.com/documentation/REST_API/#user-attributes-object-specification)
36
36
 
37
37
  ```ruby
38
38
  api.track_users(attributes: [{
@@ -52,7 +52,7 @@ api.track_attribute(external_id: 123, first_name: 'John', ...)
52
52
 
53
53
  ### Track Event
54
54
 
55
- See: [Event Object Specification](https://documentation.appboy.com/REST_APIs/User_Data#event-object)
55
+ See: [Event Object Specification](https://www.braze.com/documentation/REST_API/#event-object-specification)
56
56
 
57
57
  ```ruby
58
58
  api.track_users(events: [{
@@ -70,7 +70,7 @@ api.track_event(external_id: 123, name: 'Event', ...)
70
70
 
71
71
  ### Track Purchase
72
72
 
73
- See: [Purchase Object Specfication](https://documentation.appboy.com/REST_APIs/User_Data#purchase-object)
73
+ See: [Purchase Object Specfication](https://www.braze.com/documentation/REST_API/#purchase-object-specification)
74
74
 
75
75
  ```ruby
76
76
  api.track_users(purchases: [{
@@ -96,7 +96,7 @@ api.track_users(purchases: purchases, events: events, attributes: attributes)
96
96
 
97
97
  ### Send Message
98
98
 
99
- See: [Platform Push Object Specifications](https://documentation.appboy.com/REST_APIs/Messaging#platform-push-object)
99
+ See: [Platform Push Object Specifications](https://www.braze.com/documentation/REST_API/#messaging)
100
100
 
101
101
  ##### Messages Payload
102
102
 
@@ -119,10 +119,39 @@ api.send_messages(messages: messages, external_user_ids: [123, 456])
119
119
  api.send_messages(messages: messages, segment_id: '<segment-id>')
120
120
  ```
121
121
 
122
+ ### Triggered Delivery Messages
123
+
124
+ See: [Sending Messages via API Triggered Delivery](https://www.braze.com/documentation/REST_API/#sending-messages-via-api-triggered-delivery)
125
+
126
+ ##### Option A, Using Campaign ID
127
+ ```ruby
128
+ api.trigger_campaign(
129
+ api_key: (required, string),
130
+ campaign_id: (required, string),
131
+ send_id: (optional, string),
132
+ audience: (optional, string),
133
+ trigger_properties: (optional, object),
134
+ broadcast: (optional, boolean, default, false),
135
+ recipients: (optional, array of recipient objects)
136
+ )
137
+ ```
138
+
139
+ ##### Option B, Using Canvas ID
140
+
141
+ ```ruby
142
+ api.trigger_canvas(
143
+ api_key: (required, string),
144
+ campaign_id: (required, string),
145
+ audience: (optional, string),
146
+ canvas_entry_properties: (optional, object),
147
+ broadcast: (optional, boolean, default, false),
148
+ recipients: (optional, array of recipient objects)
149
+ )
150
+ ```
122
151
 
123
152
  ### Schedule Message
124
153
 
125
- See: [Platform Push Object Specifications](https://documentation.appboy.com/REST_APIs/Messaging#platform-push-object)
154
+ See: [Platform Push Object Specifications](https://www.braze.com/documentation/REST_API/#schedule-api-triggered-campaigns-and-canvases)
126
155
 
127
156
  ```ruby
128
157
  api.schedule_messages(send_at: 1.hour.since, messages: messages, segment_id: '<segment-id>')
@@ -130,7 +159,7 @@ api.schedule_messages(send_at: 1.hour.since, messages: messages, segment_id: '<s
130
159
 
131
160
  ### Changing Email Subscription
132
161
 
133
- See: [Changing Email Subscription Status](https://documentation.appboy.com/REST_APIs/Email_Sync#post)
162
+ See: [Changing Email Subscription Status](https://www.braze.com/documentation/REST_API/#email-sync)
134
163
 
135
164
  ```ruby
136
165
  api.email_status(email: 'john@example.com', status: :opted_in)
@@ -138,7 +167,7 @@ api.email_status(email: 'john@example.com', status: :opted_in)
138
167
 
139
168
  ### List Segments
140
169
 
141
- See: [Segment Export](https://documentation.appboy.com/REST_APIs/Export)
170
+ See: [Segment Export](https://www.braze.com/documentation/REST_API/#segment-export)
142
171
 
143
172
  ```ruby
144
173
  api.list_segments
@@ -146,7 +175,7 @@ api.list_segments
146
175
 
147
176
  ### Export Users
148
177
 
149
- See: [User Export](https://documentation.appboy.com/REST_APIs/Export#user-export)
178
+ See: [User Export](https://www.braze.com/documentation/REST_API/#user-export)
150
179
 
151
180
  #### By IDs
152
181
 
@@ -4,6 +4,8 @@ require 'appboy/endpoints/delete_users'
4
4
  require 'appboy/endpoints/send_messages'
5
5
  require 'appboy/endpoints/schedule_messages'
6
6
  require 'appboy/endpoints/email_status'
7
+ require 'appboy/endpoints/trigger_campaign'
8
+ require 'appboy/endpoints/trigger_canvas'
7
9
 
8
10
  module Appboy
9
11
  class API
@@ -14,6 +16,8 @@ module Appboy
14
16
  include Appboy::Endpoints::SendMessages
15
17
  include Appboy::Endpoints::ScheduleMessages
16
18
  include Appboy::Endpoints::EmailStatus
19
+ include Appboy::Endpoints::TriggerCampaign
20
+ include Appboy::Endpoints::TriggerCanvas
17
21
 
18
22
  def export_users(**payload)
19
23
  Appboy::REST::ExportUsers.new.perform(app_group_id, payload)
@@ -0,0 +1,15 @@
1
+ module Appboy
2
+ module Endpoints
3
+ module TriggerCampaign
4
+ def trigger_campaign(**payload)
5
+ trigger_campaign_service.new(app_group_id, payload).perform
6
+ end
7
+
8
+ private
9
+
10
+ def trigger_campaign_service
11
+ Appboy::REST::TriggerCampaign
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Appboy
2
+ module Endpoints
3
+ module TriggerCanvas
4
+ def trigger_canvas(**payload)
5
+ trigger_canvas_service.new(app_group_id, payload).perform
6
+ end
7
+
8
+ private
9
+
10
+ def trigger_canvas_service
11
+ Appboy::REST::TriggerCanvas
12
+ end
13
+ end
14
+ end
15
+ end
@@ -6,3 +6,5 @@ require 'appboy/rest/schedule_messages'
6
6
  require 'appboy/rest/email_status'
7
7
  require 'appboy/rest/export_users'
8
8
  require 'appboy/rest/list_segments'
9
+ require 'appboy/rest/trigger_campaign'
10
+ require 'appboy/rest/trigger_canvas'
@@ -0,0 +1,30 @@
1
+ module Appboy
2
+ module REST
3
+ class TriggerCampaign < Base
4
+ attr_reader :api_key, :audience, :broadcast, :campaign_id,
5
+ :recipients, :send_id, :trigger_properties
6
+
7
+ def initialize(api_key, options = {})
8
+ @api_key = api_key
9
+ @audience = options[:audience]
10
+ @broadcast = options[:broadcast] || false
11
+ @campaign_id = options[:campaign_id]
12
+ @recipients = options[:recipients]
13
+ @send_id = options[:send_id]
14
+ @trigger_properties = options[:trigger_properties]
15
+ end
16
+
17
+ def perform
18
+ http.post '/campaigns/trigger/send', {
19
+ api_key: api_key,
20
+ audience: audience,
21
+ broadcast: broadcast,
22
+ campaign_id: campaign_id,
23
+ recipients: recipients,
24
+ send_id: send_id,
25
+ trigger_properties: trigger_properties
26
+ }.compact
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ module Appboy
2
+ module REST
3
+ class TriggerCanvas < Base
4
+ attr_reader :api_key, :audience, :broadcast, :canvas_id,
5
+ :canvas_entry_properties, :recipients
6
+
7
+ def initialize(app_group_id, options = {})
8
+ @api_key = app_group_id
9
+ @audience = options[:audience]
10
+ @broadcast = options[:broadcast] || false
11
+ @canvas_entry_properties = options[:canvas_entry_properties]
12
+ @canvas_id = options[:canvas_id]
13
+ @recipients = options[:recipients]
14
+ end
15
+
16
+ def perform
17
+ http.post '/canvas/trigger/send', {
18
+ api_key: api_key,
19
+ audience: audience,
20
+ broadcast: broadcast,
21
+ canvas_entry_properties: canvas_entry_properties,
22
+ canvas_id: canvas_id,
23
+ recipients: recipients
24
+ }.compact
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Appboy
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'appboy/endpoints/trigger_campaign'
3
+
4
+ class API
5
+ include Appboy::Endpoints::TriggerCampaign
6
+
7
+ def app_group_id
8
+ :api_key
9
+ end
10
+ end
11
+
12
+ describe 'Appboy::Endpoints::TriggerCampaign' do
13
+ let(:api) { API.new }
14
+ let(:performer) do
15
+ instance_double 'Appboy::REST::TriggerCampaign'
16
+ end
17
+
18
+ before do
19
+ allow(api.send(:trigger_campaign_service))
20
+ .to receive(:new).and_return(performer)
21
+ allow(performer).to receive(:perform).and_return true
22
+ end
23
+
24
+ describe '#trigger_campaign_service', vcr: true do
25
+ let(:payload) do
26
+ {
27
+ audience: :audience,
28
+ broadcast: :broadcast,
29
+ campaign_id: :campaign_id,
30
+ recipients: :recipients,
31
+ send_id: :send_id,
32
+ trigger_properties: :trigger_properties
33
+ }
34
+ end
35
+
36
+ subject(:trigger_campaign!) do
37
+ api.trigger_campaign(payload)
38
+ end
39
+
40
+ it 'sends a campaign message with recipients' do
41
+ expect(api.send(:trigger_campaign_service))
42
+ .to receive(:new).with(:api_key, payload)
43
+
44
+ trigger_campaign!
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'appboy/endpoints/trigger_canvas'
3
+
4
+ class API
5
+ include Appboy::Endpoints::TriggerCanvas
6
+
7
+ def app_group_id
8
+ :api_key
9
+ end
10
+ end
11
+
12
+ describe Appboy::Endpoints::TriggerCanvas do
13
+ let(:api) { API.new }
14
+ let(:performer) do
15
+ instance_double "Appboy::REST::TriggerCanvas"
16
+ end
17
+
18
+ before do
19
+ allow(api.send(:trigger_canvas_service))
20
+ .to receive(:new).and_return(performer)
21
+ allow(performer).to receive(:perform).and_return true
22
+ end
23
+
24
+ describe '#trigger_canvas_service', vcr: true do
25
+ let(:payload) do
26
+ {
27
+ audience: :audience,
28
+ broadcast: :broadcast,
29
+ canvas_entry_properties: :canvas_entry_properties,
30
+ canvas_id: :canvas_id,
31
+ recipients: :recipients,
32
+ send_id: :send_id
33
+ }
34
+ end
35
+
36
+ subject(:trigger_canvas!) do
37
+ api.trigger_canvas(payload)
38
+ end
39
+
40
+ it 'sends a canvas message with recipients' do
41
+ expect(api.send(:trigger_canvas_service))
42
+ .to receive(:new).with(:api_key, payload)
43
+
44
+ trigger_canvas!
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Appboy::REST::TriggerCampaign do
4
+ let(:http) { double(:http) }
5
+
6
+ let(:payload) do
7
+ {
8
+ audience: :audience,
9
+ broadcast: :broadcast,
10
+ campaign_id: :campaign_id,
11
+ recipients: :recipients,
12
+ send_id: :send_id,
13
+ trigger_properties: :trigger_properties
14
+ }
15
+ end
16
+
17
+ let(:api_key) { :api_key }
18
+
19
+ subject do
20
+ described_class.new(
21
+ api_key,
22
+ audience: :audience,
23
+ broadcast: :broadcast,
24
+ campaign_id: :campaign_id,
25
+ recipients: :recipients,
26
+ send_id: :send_id,
27
+ trigger_properties: :trigger_properties
28
+ )
29
+ end
30
+
31
+ before { subject.http = http }
32
+
33
+ it 'makes an http call to the send messages endpoint' do
34
+ expect_send_messages_http_call
35
+
36
+ subject.perform
37
+ end
38
+
39
+ def expect_send_messages_http_call
40
+ expect(http).to receive(:post).with '/campaigns/trigger/send', {
41
+ api_key: :api_key,
42
+ audience: :audience,
43
+ broadcast: :broadcast,
44
+ campaign_id: :campaign_id,
45
+ recipients: :recipients,
46
+ send_id: :send_id,
47
+ trigger_properties: :trigger_properties
48
+ }
49
+ end
50
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Appboy::REST::TriggerCanvas do
4
+ let(:http) { double(:http) }
5
+
6
+ let(:payload) do
7
+ {
8
+ audience: :audience,
9
+ broadcast: :broadcast,
10
+ canvas_id: :canvas_id,
11
+ canvas_entry_properties: :canvas_entry_properties,
12
+ recipients: :recipients
13
+ }
14
+ end
15
+
16
+ let(:api_key) { :api_key }
17
+
18
+ subject do
19
+ described_class.new(
20
+ api_key,
21
+ audience: :audience,
22
+ broadcast: :broadcast,
23
+ canvas_id: :canvas_id,
24
+ canvas_entry_properties: :canvas_entry_properties,
25
+ recipients: :recipients
26
+ )
27
+ end
28
+
29
+ before { subject.http = http }
30
+
31
+ it 'makes an http call to the send messages endpoint' do
32
+ expect_send_messages_http_call
33
+
34
+ subject.perform
35
+ end
36
+
37
+ def expect_send_messages_http_call
38
+ expect(http).to receive(:post).with '/canvas/trigger/send', {
39
+ api_key: :api_key,
40
+ audience: :audience,
41
+ broadcast: :broadcast,
42
+ canvas_id: :canvas_id,
43
+ canvas_entry_properties: :canvas_entry_properties,
44
+ recipients: :recipients
45
+ }
46
+ end
47
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appboy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nussbaum
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-26 00:00:00.000000000 Z
12
+ date: 2018-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: virtus
@@ -202,6 +202,8 @@ files:
202
202
  - lib/appboy/endpoints/schedule_messages.rb
203
203
  - lib/appboy/endpoints/send_messages.rb
204
204
  - lib/appboy/endpoints/track_users.rb
205
+ - lib/appboy/endpoints/trigger_campaign.rb
206
+ - lib/appboy/endpoints/trigger_canvas.rb
205
207
  - lib/appboy/http.rb
206
208
  - lib/appboy/rest.rb
207
209
  - lib/appboy/rest/base.rb
@@ -212,9 +214,13 @@ files:
212
214
  - lib/appboy/rest/schedule_messages.rb
213
215
  - lib/appboy/rest/send_messages.rb
214
216
  - lib/appboy/rest/track_users.rb
217
+ - lib/appboy/rest/trigger_campaign.rb
218
+ - lib/appboy/rest/trigger_canvas.rb
215
219
  - lib/appboy/version.rb
216
220
  - spec/appboy/api_spec.rb
217
221
  - spec/appboy/endpoints/track_users_spec.rb
222
+ - spec/appboy/endpoints/trigger_campaigns_spec.rb
223
+ - spec/appboy/endpoints/trigger_canvas_spec.rb
218
224
  - spec/appboy/http_spec.rb
219
225
  - spec/appboy/rest/delete_users_spec.rb
220
226
  - spec/appboy/rest/email_status_spec.rb
@@ -222,6 +228,8 @@ files:
222
228
  - spec/appboy/rest/schedule_messages_spec.rb
223
229
  - spec/appboy/rest/send_messages_spec.rb
224
230
  - spec/appboy/rest/track_users_spec.rb
231
+ - spec/appboy/rest/trigger_campaign_spec.rb
232
+ - spec/appboy/rest/trigger_canvas_spec.rb
225
233
  - spec/factories.rb
226
234
  - spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml
227
235
  - spec/fixtures/responses/delete_users/with_success/responds_with_created.yml
@@ -282,6 +290,8 @@ summary: A wrapper for the Appboy REST API, track users/events/purchases, send &
282
290
  test_files:
283
291
  - spec/appboy/api_spec.rb
284
292
  - spec/appboy/endpoints/track_users_spec.rb
293
+ - spec/appboy/endpoints/trigger_campaigns_spec.rb
294
+ - spec/appboy/endpoints/trigger_canvas_spec.rb
285
295
  - spec/appboy/http_spec.rb
286
296
  - spec/appboy/rest/delete_users_spec.rb
287
297
  - spec/appboy/rest/email_status_spec.rb
@@ -289,6 +299,8 @@ test_files:
289
299
  - spec/appboy/rest/schedule_messages_spec.rb
290
300
  - spec/appboy/rest/send_messages_spec.rb
291
301
  - spec/appboy/rest/track_users_spec.rb
302
+ - spec/appboy/rest/trigger_campaign_spec.rb
303
+ - spec/appboy/rest/trigger_canvas_spec.rb
292
304
  - spec/factories.rb
293
305
  - spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml
294
306
  - spec/fixtures/responses/delete_users/with_success/responds_with_created.yml