braze_ruby 0.7.0 → 0.8.0

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: 39bc36a3cad69bd3b9bd36df61c45e8052c594ea7533ea7c888cb6978f739adf
4
- data.tar.gz: 4f01c13fa4bc9cb0ca255d370096bd90b9bf811cee980e60dc62186731b86d5d
3
+ metadata.gz: 92627ab40d55d8abadf9acd07b143a0eae13586d0caad935e657c8e4fb074d54
4
+ data.tar.gz: e21b4acbf9aef12c2f7ab37029aece94f421a3a9e2d45afd0c41216316b3a402
5
5
  SHA512:
6
- metadata.gz: c89ff06b6416a93a68a02c360d50cecde4b9132df53e692f7ffd26b259f8d783b3d83d3d78325c5d6b898ae292e3688aa43c83f83ecd2a93d611b4d83424d710
7
- data.tar.gz: 51b93002f6521205daf03e196a32f70971b2ad89f8b160c38cbd179e4d813296335979e707e28b0d45242fff54474a961f02f30795ab399baa06eaa0a5eaa13e
6
+ metadata.gz: 841f8f3d844ee4881f2d98745eaca37cbf47f7e3352e13373a39bf95567cfd10950df47b60ace6810f805db7962e76bcdcf707dd2ae363f7a16a14850e558b57
7
+ data.tar.gz: 5163647859b894bb7946503995fdbad55bc8becd0eb25fb3378b11cfb5283d1ae0cf01f8003a683246693d9c4e52b085f1b7af99e3e4cab0d6053189e10739df
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # BrazeRuby [![CircleCI][badge]][circle]
2
2
 
3
- A wrapper for the Braze REST API. Forked from https://github.com/DynamoMTL/appboy
3
+ A wrapper for the Braze REST API. Forked from
4
+ https://github.com/DynamoMTL/appboy
4
5
 
5
6
  ## Installation
6
7
 
@@ -16,12 +17,32 @@ Or install it yourself as:
16
17
 
17
18
  $ gem install braze_ruby
18
19
 
20
+ ### Configuration
21
+
22
+ Configuration options may be passed when a new API object is instantiated:
23
+
24
+ ```ruby
25
+ BrazeRuby::API.new('<braze-rest-api-key>', '<braze-rest-url', {<additional options>})
26
+ ```
27
+
28
+ Alternatively, you can pass your [Braze REST API key][braze_api_key], [Braze
29
+ REST URL][braze_url], and any required [Faraday options][faraday_options] to the
30
+ `BrazeRuby::configure` method:
31
+
32
+ ```ruby
33
+ BrazeRuby.configure do |config|
34
+ config.rest_api_key = '<braze-rest-api-key>'
35
+ config.rest_url = '<braze-rest-url>'
36
+ config.options = {<additional options>}
37
+ end
38
+ ```
39
+
19
40
  ## Examples
20
41
 
21
42
  ### Initializing API
22
43
 
23
44
  ```ruby
24
- api = BrazeRuby::API.new('<braze-rest-api-key>', '<braze-rest-api-url')
45
+ api = BrazeRuby::API.new('<braze-rest-api-key>', '<braze-rest-url')
25
46
  ```
26
47
 
27
48
  ### Track User Attributes
@@ -105,7 +126,6 @@ api.send_messages(messages: messages, external_user_ids: [123, 456])
105
126
  api.send_messages(messages: messages, segment_id: '<segment-id>')
106
127
  ```
107
128
 
108
-
109
129
  ### Schedule Message
110
130
 
111
131
  ```ruby
@@ -122,6 +142,15 @@ api.trigger_campaign_schedule(
122
142
  )
123
143
  ```
124
144
 
145
+ ### Delete Scheduled Campaign
146
+
147
+ ```ruby
148
+ api.delete_campaign_trigger_schedule(
149
+ campaign_id: 'campaign_id',
150
+ schedule_id: 'schedule_id'
151
+ )
152
+ ```
153
+
125
154
  ### Send Campaigns
126
155
 
127
156
  ```ruby
@@ -146,6 +175,12 @@ api.trigger_canvas_send(
146
175
  api.email_status(email: 'john@example.com', status: :opted_in)
147
176
  ```
148
177
 
178
+ ### List Scheduled Messages and Canvases
179
+
180
+ ```ruby
181
+ api.scheduled_messages(end_time: Time.now.advance(weeks: 2).iso861)
182
+ ```
183
+
149
184
  ### List Segments
150
185
 
151
186
  ```ruby
@@ -263,7 +298,8 @@ api.remove_emails_from_spam(email: ['jdoe@example.com'])
263
298
 
264
299
  ## Debugging
265
300
 
266
- The BRAZE_RUBY_DEBUG environment variable will trigger full printouts of the Faraday gem's HTTP requests and responses.
301
+ The BRAZE_RUBY_DEBUG environment variable will trigger full printouts of the
302
+ Faraday gem's HTTP requests and responses.
267
303
 
268
304
  ```bash
269
305
  cd /my/app
@@ -280,4 +316,7 @@ bundle exec rails whatever
280
316
  5. Create new Pull Request
281
317
 
282
318
  [badge]: https://circleci.com/gh/jonallured/braze_ruby.svg?style=svg
319
+ [braze_api_key]: https://www.braze.com/docs/api/api_key/
320
+ [braze_url]: https://www.braze.com/docs/api/basics/#endpoints
283
321
  [circle]: https://circleci.com/gh/jonallured/braze_ruby
322
+ [faraday_options]: https://github.com/lostisland/faraday/blob/main/lib/faraday/options.rb
@@ -44,9 +44,9 @@ module BrazeRuby
44
44
  attr_reader :api_key, :braze_url, :options
45
45
 
46
46
  def initialize(api_key, braze_url, options = {})
47
- @api_key = api_key
48
- @braze_url = braze_url
49
- @options = options
47
+ @api_key = api_key || configuration.rest_api_key
48
+ @braze_url = braze_url || configuration.rest_url
49
+ @options = options || configuration.options
50
50
  end
51
51
  end
52
52
  end
@@ -0,0 +1,13 @@
1
+ module BrazeRuby
2
+ class Configuration
3
+ attr_accessor :rest_api_key,
4
+ :rest_url,
5
+ :options # See BrazeRuby::HTTP#default_options
6
+
7
+ def initialize
8
+ @rest_api_key = nil
9
+ @rest_url = nil
10
+ @options = nil
11
+ end
12
+ end
13
+ end
@@ -3,6 +3,10 @@
3
3
  module BrazeRuby
4
4
  module Endpoints
5
5
  module Campaigns
6
+ def delete_campaign_trigger_schedule(**payload)
7
+ BrazeRuby::REST::DeleteTriggerCampaignSchedule.new(api_key, braze_url, options).perform(**payload)
8
+ end
9
+
6
10
  def trigger_campaign_send(**payload)
7
11
  BrazeRuby::REST::TriggerCampaignSend.new(api_key, braze_url, options, **payload).perform
8
12
  end
@@ -4,13 +4,11 @@ module BrazeRuby
4
4
  module Endpoints
5
5
  module ScheduleMessages
6
6
  def schedule_messages(**payload)
7
- schedule_messages_service.new(api_key, braze_url, options, **payload).perform
7
+ BrazeRuby::REST::ScheduleMessages.new(api_key, braze_url, options, **payload).perform
8
8
  end
9
9
 
10
- private
11
-
12
- def schedule_messages_service
13
- BrazeRuby::REST::ScheduleMessages
10
+ def scheduled_messages(**payload)
11
+ BrazeRuby::REST::ScheduledBroadcasts.new(api_key, braze_url, options, **payload).perform
14
12
  end
15
13
  end
16
14
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module REST
5
+ class DeleteTriggerCampaignSchedule < Base
6
+ def perform(campaign_id:, schedule_id:)
7
+ http.post(
8
+ "/campaigns/trigger/schedule/delete",
9
+ campaign_id: campaign_id,
10
+ schedule_id: schedule_id
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrazeRuby
4
+ module REST
5
+ class ScheduledBroadcasts < Base
6
+ attr_reader :params
7
+
8
+ def initialize(api_key, braze_url, options, **params)
9
+ @params = params
10
+ super api_key, braze_url, options
11
+ end
12
+
13
+ def perform
14
+ http.post "/messages/scheduled_broadcasts", {
15
+ **@params
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,6 +4,7 @@ require "braze_ruby/rest/base"
4
4
  require "braze_ruby/rest/track_users"
5
5
  require "braze_ruby/rest/send_messages"
6
6
  require "braze_ruby/rest/schedule_messages"
7
+ require "braze_ruby/rest/scheduled_broadcasts"
7
8
  require "braze_ruby/rest/email_status"
8
9
  require "braze_ruby/rest/email_hard_bounces"
9
10
  require "braze_ruby/rest/email_unsubscribes"
@@ -11,6 +12,7 @@ require "braze_ruby/rest/export_users"
11
12
  require "braze_ruby/rest/list_segments"
12
13
  require "braze_ruby/rest/delete_users"
13
14
  require "braze_ruby/rest/trigger_campaign_schedule"
15
+ require "braze_ruby/rest/delete_trigger_campaign_schedule"
14
16
  require "braze_ruby/rest/trigger_campaign_send"
15
17
  require "braze_ruby/rest/trigger_canvas_send"
16
18
  require "braze_ruby/rest/canvas_details"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrazeRuby
4
- VERSION = "0.7.0"
4
+ VERSION = "0.8.0"
5
5
  end
data/lib/braze_ruby.rb CHANGED
@@ -1,9 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "braze_ruby/version"
4
+ require "braze_ruby/configuration"
4
5
 
5
6
  module BrazeRuby
6
7
  autoload :API, "braze_ruby/api"
7
8
  autoload :REST, "braze_ruby/rest"
8
9
  autoload :Endpoints, "braze_ruby/endpoints"
10
+
11
+ class << self
12
+ attr_writer :configuration
13
+ end
14
+
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.configure
20
+ yield(configuration)
21
+ end
9
22
  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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nussbaum
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-09-29 00:00:00.000000000 Z
14
+ date: 2022-01-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday
@@ -163,6 +163,7 @@ files:
163
163
  - braze_ruby.gemspec
164
164
  - lib/braze_ruby.rb
165
165
  - lib/braze_ruby/api.rb
166
+ - lib/braze_ruby/configuration.rb
166
167
  - lib/braze_ruby/deprecated.rb
167
168
  - lib/braze_ruby/endpoints.rb
168
169
  - lib/braze_ruby/endpoints/campaigns.rb
@@ -184,6 +185,7 @@ files:
184
185
  - lib/braze_ruby/rest/base.rb
185
186
  - lib/braze_ruby/rest/canvas_details.rb
186
187
  - lib/braze_ruby/rest/create_user_aliases.rb
188
+ - lib/braze_ruby/rest/delete_trigger_campaign_schedule.rb
187
189
  - lib/braze_ruby/rest/delete_users.rb
188
190
  - lib/braze_ruby/rest/email_hard_bounces.rb
189
191
  - lib/braze_ruby/rest/email_status.rb
@@ -195,6 +197,7 @@ files:
195
197
  - lib/braze_ruby/rest/remove_external_ids.rb
196
198
  - lib/braze_ruby/rest/rename_external_ids.rb
197
199
  - lib/braze_ruby/rest/schedule_messages.rb
200
+ - lib/braze_ruby/rest/scheduled_broadcasts.rb
198
201
  - lib/braze_ruby/rest/send_messages.rb
199
202
  - lib/braze_ruby/rest/subscription_status_get.rb
200
203
  - lib/braze_ruby/rest/subscription_status_set.rb