braze_ruby 0.3.3 → 0.4.0
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 +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
 
| 
         @@ -3,18 +3,16 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class EmailStatus < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :email, :status
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, email: nil, status: nil)
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @email = email
         
     | 
| 
       11 
10 
     | 
    
         
             
                    @status = status
         
     | 
| 
       12 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 11 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       13 
12 
     | 
    
         
             
                  end
         
     | 
| 
       14 
13 
     | 
    
         | 
| 
       15 
14 
     | 
    
         
             
                  def perform
         
     | 
| 
       16 
15 
     | 
    
         
             
                    http.post '/email/status', {
         
     | 
| 
       17 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       18 
16 
     | 
    
         
             
                      'email': email,
         
     | 
| 
       19 
17 
     | 
    
         
             
                      'subscription_state': status
         
     | 
| 
       20 
18 
     | 
    
         
             
                    }
         
     | 
| 
         @@ -3,17 +3,15 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class EmailUnsubscribes < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :params
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, **params)
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @params = params
         
     | 
| 
       11 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       12 
11 
     | 
    
         
             
                  end
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
13 
     | 
    
         
             
                  def perform
         
     | 
| 
       15 
14 
     | 
    
         
             
                    http.get('/email/unsubscribes', {
         
     | 
| 
       16 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       17 
15 
     | 
    
         
             
                      **params
         
     | 
| 
       18 
16 
     | 
    
         
             
                    })
         
     | 
| 
       19 
17 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -3,24 +3,22 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class ExportUsers < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  def perform( 
     | 
| 
       7 
     | 
    
         
            -
                    return export_users_by_ids( 
     | 
| 
      
 6 
     | 
    
         
            +
                  def perform(external_ids: nil, segment_id: nil, **options)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    return export_users_by_ids(external_ids) if external_ids
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                    export_users_by_segment( 
     | 
| 
      
 9 
     | 
    
         
            +
                    export_users_by_segment(segment_id, options) if segment_id
         
     | 
| 
       10 
10 
     | 
    
         
             
                  end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                  private
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                  def export_users_by_ids( 
     | 
| 
      
 14 
     | 
    
         
            +
                  def export_users_by_ids(external_ids)
         
     | 
| 
       15 
15 
     | 
    
         
             
                    http.post '/users/export/ids', {
         
     | 
| 
       16 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       17 
16 
     | 
    
         
             
                      'external_ids': external_ids
         
     | 
| 
       18 
17 
     | 
    
         
             
                    }
         
     | 
| 
       19 
18 
     | 
    
         
             
                  end
         
     | 
| 
       20 
19 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                  def export_users_by_segment( 
     | 
| 
      
 20 
     | 
    
         
            +
                  def export_users_by_segment(segment_id, options)
         
     | 
| 
       22 
21 
     | 
    
         
             
                    http.post '/users/export/segment', {
         
     | 
| 
       23 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       24 
22 
     | 
    
         
             
                      'segment_id': segment_id
         
     | 
| 
       25 
23 
     | 
    
         
             
                    }.merge(options)
         
     | 
| 
       26 
24 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -3,10 +3,9 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class IdentifyUsers < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  def perform( 
     | 
| 
      
 6 
     | 
    
         
            +
                  def perform(aliases_to_identify: [])
         
     | 
| 
       7 
7 
     | 
    
         
             
                    http.post '/users/identify', {
         
     | 
| 
       8 
     | 
    
         
            -
                      ' 
     | 
| 
       9 
     | 
    
         
            -
                      'aliases_to_identify': aliases_to_identify,
         
     | 
| 
      
 8 
     | 
    
         
            +
                      'aliases_to_identify': aliases_to_identify
         
     | 
| 
       10 
9 
     | 
    
         
             
                    }
         
     | 
| 
       11 
10 
     | 
    
         
             
                  end
         
     | 
| 
       12 
11 
     | 
    
         
             
                end
         
     | 
| 
         @@ -3,20 +3,18 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class ScheduleMessages < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :time, :messages, :in_local_time, :external_user_ids
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, time: nil, messages: [], external_user_ids: [], in_local_time: false)
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @messages = messages
         
     | 
| 
       11 
10 
     | 
    
         
             
                    @time = time
         
     | 
| 
       12 
11 
     | 
    
         
             
                    @external_user_ids = external_user_ids
         
     | 
| 
       13 
12 
     | 
    
         
             
                    @in_local_time = in_local_time
         
     | 
| 
       14 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 13 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       15 
14 
     | 
    
         
             
                  end
         
     | 
| 
       16 
15 
     | 
    
         | 
| 
       17 
16 
     | 
    
         
             
                  def perform
         
     | 
| 
       18 
17 
     | 
    
         
             
                    http.post '/messages/schedule/create', {
         
     | 
| 
       19 
     | 
    
         
            -
                      'api_key':                    api_key,
         
     | 
| 
       20 
18 
     | 
    
         
             
                      'external_user_ids':          external_user_ids,
         
     | 
| 
       21 
19 
     | 
    
         
             
                      'schedule': {
         
     | 
| 
       22 
20 
     | 
    
         
             
                        'time':                       time,
         
     | 
| 
         @@ -3,18 +3,16 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class SendMessages < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :messages, :external_user_ids
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, messages: [], external_user_ids: [])
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @messages = messages
         
     | 
| 
       11 
10 
     | 
    
         
             
                    @external_user_ids = external_user_ids
         
     | 
| 
       12 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 11 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       13 
12 
     | 
    
         
             
                  end
         
     | 
| 
       14 
13 
     | 
    
         | 
| 
       15 
14 
     | 
    
         
             
                  def perform
         
     | 
| 
       16 
15 
     | 
    
         
             
                    http.post '/messages/send', {
         
     | 
| 
       17 
     | 
    
         
            -
                      'api_key':           api_key,
         
     | 
| 
       18 
16 
     | 
    
         
             
                      'messages':          messages,
         
     | 
| 
       19 
17 
     | 
    
         
             
                      'external_user_ids': external_user_ids
         
     | 
| 
       20 
18 
     | 
    
         
             
                    }
         
     | 
| 
         @@ -3,17 +3,15 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class SubscriptionStatusGet < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :params
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, **params)
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @params = params
         
     | 
| 
       11 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       12 
11 
     | 
    
         
             
                  end
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
13 
     | 
    
         
             
                  def perform
         
     | 
| 
       15 
14 
     | 
    
         
             
                    http.get('/subscription/status/get', {
         
     | 
| 
       16 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       17 
15 
     | 
    
         
             
                      **params
         
     | 
| 
       18 
16 
     | 
    
         
             
                    })
         
     | 
| 
       19 
17 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -3,17 +3,15 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class SubscriptionStatusSet < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :params
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, **params)
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @params = params
         
     | 
| 
       11 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       12 
11 
     | 
    
         
             
                  end
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
13 
     | 
    
         
             
                  def perform
         
     | 
| 
       15 
14 
     | 
    
         
             
                    http.post('/subscription/status/set', {
         
     | 
| 
       16 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       17 
15 
     | 
    
         
             
                      **params
         
     | 
| 
       18 
16 
     | 
    
         
             
                    })
         
     | 
| 
       19 
17 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -3,17 +3,15 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class SubscriptionUserStatus < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :params
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, **params)
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @params = params
         
     | 
| 
       11 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       12 
11 
     | 
    
         
             
                  end
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
13 
     | 
    
         
             
                  def perform
         
     | 
| 
       15 
14 
     | 
    
         
             
                    http.get('/subscription/user/status', {
         
     | 
| 
       16 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       17 
15 
     | 
    
         
             
                      **params
         
     | 
| 
       18 
16 
     | 
    
         
             
                    })
         
     | 
| 
       19 
17 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -3,9 +3,8 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class TrackUsers < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  def perform( 
     | 
| 
      
 6 
     | 
    
         
            +
                  def perform(attributes: [], events: [], purchases: [])
         
     | 
| 
       7 
7 
     | 
    
         
             
                    http.post '/users/track', {
         
     | 
| 
       8 
     | 
    
         
            -
                      'api_key':        api_key,
         
     | 
| 
       9 
8 
     | 
    
         
             
                      'attributes':     attributes,
         
     | 
| 
       10 
9 
     | 
    
         
             
                      'events':         events,
         
     | 
| 
       11 
10 
     | 
    
         
             
                      'purchases':      purchases
         
     | 
| 
         @@ -3,19 +3,15 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class TriggerCampaignSend < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :params
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, **params)
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @params = params
         
     | 
| 
       11 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       12 
11 
     | 
    
         
             
                  end
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
13 
     | 
    
         
             
                  def perform
         
     | 
| 
       15 
     | 
    
         
            -
                    http.post('/campaigns/trigger/send',  
     | 
| 
       16 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       17 
     | 
    
         
            -
                      **@params
         
     | 
| 
       18 
     | 
    
         
            -
                    })
         
     | 
| 
      
 14 
     | 
    
         
            +
                    http.post('/campaigns/trigger/send', @params)
         
     | 
| 
       19 
15 
     | 
    
         
             
                  end
         
     | 
| 
       20 
16 
     | 
    
         
             
                end
         
     | 
| 
       21 
17 
     | 
    
         
             
              end
         
     | 
| 
         @@ -3,17 +3,15 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module BrazeRuby
         
     | 
| 
       4 
4 
     | 
    
         
             
              module REST
         
     | 
| 
       5 
5 
     | 
    
         
             
                class TriggerCanvasSend < Base
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :params
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(api_key, braze_url, options, **params)
         
     | 
| 
       9 
     | 
    
         
            -
                    @api_key = api_key
         
     | 
| 
       10 
9 
     | 
    
         
             
                    @params = params
         
     | 
| 
       11 
     | 
    
         
            -
                    super braze_url, options
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super api_key, braze_url, options
         
     | 
| 
       12 
11 
     | 
    
         
             
                  end
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
13 
     | 
    
         
             
                  def perform
         
     | 
| 
       15 
14 
     | 
    
         
             
                    http.post('/canvas/trigger/send', {
         
     | 
| 
       16 
     | 
    
         
            -
                      'api_key': api_key,
         
     | 
| 
       17 
15 
     | 
    
         
             
                      **@params
         
     | 
| 
       18 
16 
     | 
    
         
             
                    })
         
     | 
| 
       19 
17 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/braze_ruby/version.rb
    CHANGED
    
    
| 
         @@ -23,11 +23,11 @@ describe BrazeRuby::Endpoints::TrackUsers do 
     | 
|
| 
       23 
23 
     | 
    
         
             
                  purchases: [build(:purchase)]
         
     | 
| 
       24 
24 
     | 
    
         
             
                }}
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                subject(:track_users!) { api.track_users(payload) }
         
     | 
| 
      
 26 
     | 
    
         
            +
                subject(:track_users!) { api.track_users(**payload) }
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                it 'tracks attributes, events and purchases' do
         
     | 
| 
       29 
29 
     | 
    
         
             
                  expect(track_users_service).to receive(:perform)
         
     | 
| 
       30 
     | 
    
         
            -
                    .with( 
     | 
| 
      
 30 
     | 
    
         
            +
                    .with(payload)
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
                  track_users!
         
     | 
| 
       33 
33 
     | 
    
         
             
                end
         
     | 
| 
         @@ -36,11 +36,11 @@ describe BrazeRuby::Endpoints::TrackUsers do 
     | 
|
| 
       36 
36 
     | 
    
         
             
              describe '#track_purchase' do
         
     | 
| 
       37 
37 
     | 
    
         
             
                let(:payload) { build(:purchase) }
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                subject(:track_purchase!) { api.track_purchase(payload) }
         
     | 
| 
      
 39 
     | 
    
         
            +
                subject(:track_purchase!) { api.track_purchase(**payload) }
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                it 'tracks a single purchase' do
         
     | 
| 
       42 
42 
     | 
    
         
             
                  expect(track_users_service).to receive(:perform)
         
     | 
| 
       43 
     | 
    
         
            -
                    .with( 
     | 
| 
      
 43 
     | 
    
         
            +
                    .with(purchases: [payload])
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
                  track_purchase!
         
     | 
| 
       46 
46 
     | 
    
         
             
                end
         
     | 
| 
         @@ -49,11 +49,11 @@ describe BrazeRuby::Endpoints::TrackUsers do 
     | 
|
| 
       49 
49 
     | 
    
         
             
              describe '#track_event' do
         
     | 
| 
       50 
50 
     | 
    
         
             
                let(:payload) { build(:event) }
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
                subject(:track_event!) { api.track_event(payload) }
         
     | 
| 
      
 52 
     | 
    
         
            +
                subject(:track_event!) { api.track_event(**payload) }
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
                it 'tracks a single purchase' do
         
     | 
| 
       55 
55 
     | 
    
         
             
                  expect(track_users_service).to receive(:perform)
         
     | 
| 
       56 
     | 
    
         
            -
                    .with( 
     | 
| 
      
 56 
     | 
    
         
            +
                    .with(events: [payload])
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                  track_event!
         
     | 
| 
       59 
59 
     | 
    
         
             
                end
         
     | 
| 
         @@ -62,11 +62,11 @@ describe BrazeRuby::Endpoints::TrackUsers do 
     | 
|
| 
       62 
62 
     | 
    
         
             
              describe '#track_attribute' do
         
     | 
| 
       63 
63 
     | 
    
         
             
                let(:payload) { build(:attribute) }
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
                subject(:track_attribute!) { api.track_attribute(payload) }
         
     | 
| 
      
 65 
     | 
    
         
            +
                subject(:track_attribute!) { api.track_attribute(**payload) }
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
       67 
67 
     | 
    
         
             
                it 'tracks a single purchase' do
         
     | 
| 
       68 
68 
     | 
    
         
             
                  expect(track_users_service).to receive(:perform)
         
     | 
| 
       69 
     | 
    
         
            -
                      .with( 
     | 
| 
      
 69 
     | 
    
         
            +
                      .with(attributes: [payload])
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
                  track_attribute!
         
     | 
| 
       72 
72 
     | 
    
         
             
                end
         
     | 
| 
         @@ -8,6 +8,8 @@ describe BrazeRuby::HTTP do 
     | 
|
| 
       8 
8 
     | 
    
         
             
                let(:options) { double("options", :"[]=" => nil) }
         
     | 
| 
       9 
9 
     | 
    
         
             
                let(:headers) { double("headers", :"[]=" => nil) }
         
     | 
| 
       10 
10 
     | 
    
         
             
                let(:conn) { double("conn", adapter: nil, options: options, headers: headers) }
         
     | 
| 
      
 11 
     | 
    
         
            +
                let(:api_key) { "braze-api-key" }
         
     | 
| 
      
 12 
     | 
    
         
            +
                let(:braze_url) { "http://example.com" }
         
     | 
| 
       11 
13 
     | 
    
         | 
| 
       12 
14 
     | 
    
         
             
                before :each do
         
     | 
| 
       13 
15 
     | 
    
         
             
                  allow(Faraday).to receive(:new).and_yield(conn)
         
     | 
| 
         @@ -15,29 +17,30 @@ describe BrazeRuby::HTTP do 
     | 
|
| 
       15 
17 
     | 
    
         
             
                end
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
       17 
19 
     | 
    
         
             
                it "it defaults to the timeout option" do
         
     | 
| 
       18 
     | 
    
         
            -
                  described_class.new( 
     | 
| 
      
 20 
     | 
    
         
            +
                  described_class.new(api_key, braze_url).connection
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
22 
     | 
    
         
             
                  expect(options).to have_received(:"[]=").with(:timeout, described_class::DEFAULT_TIMEOUT)
         
     | 
| 
       21 
23 
     | 
    
         
             
                end
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
       23 
25 
     | 
    
         
             
                it "it sets the default timeout option when given" do
         
     | 
| 
       24 
26 
     | 
    
         
             
                  timeout = 5
         
     | 
| 
       25 
     | 
    
         
            -
                  described_class.new( 
     | 
| 
      
 27 
     | 
    
         
            +
                  described_class.new(api_key, braze_url, {timeout: timeout}).connection
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
29 
     | 
    
         
             
                  expect(options).to have_received(:"[]=").with(:timeout, timeout)
         
     | 
| 
       28 
30 
     | 
    
         
             
                end
         
     | 
| 
       29 
31 
     | 
    
         | 
| 
       30 
32 
     | 
    
         
             
                it "sets the headers" do
         
     | 
| 
       31 
     | 
    
         
            -
                  described_class.new( 
     | 
| 
      
 33 
     | 
    
         
            +
                  described_class.new(api_key, braze_url).connection
         
     | 
| 
       32 
34 
     | 
    
         | 
| 
       33 
35 
     | 
    
         | 
| 
       34 
36 
     | 
    
         
             
                  expect(headers).to have_received(:"[]=").with("Content-Type", "application/json")
         
     | 
| 
       35 
37 
     | 
    
         
             
                  expect(headers).to have_received(:"[]=").with("Accept", "application/json")
         
     | 
| 
       36 
38 
     | 
    
         
             
                  expect(headers).to have_received(:"[]=").with("User-Agent", "Braze Ruby gem v#{BrazeRuby::VERSION}")
         
     | 
| 
      
 39 
     | 
    
         
            +
                  expect(headers).to have_received(:"[]=").with("Authorization", "Bearer braze-api-key")
         
     | 
| 
       37 
40 
     | 
    
         
             
                end
         
     | 
| 
       38 
41 
     | 
    
         | 
| 
       39 
42 
     | 
    
         
             
                it "it sets the default adapter" do
         
     | 
| 
       40 
     | 
    
         
            -
                  described_class.new( 
     | 
| 
      
 43 
     | 
    
         
            +
                  described_class.new(api_key, braze_url).connection
         
     | 
| 
       41 
44 
     | 
    
         | 
| 
       42 
45 
     | 
    
         
             
                  expect(conn).to have_received(:adapter).with(:default_adapter)
         
     | 
| 
       43 
46 
     | 
    
         
             
                end
         
     | 
| 
         @@ -9,14 +9,14 @@ describe BrazeRuby::REST::DeleteUsers do 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              let(:api_key) { :api_key }
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
              subject { described_class.new :rest_url, {}}
         
     | 
| 
      
 12 
     | 
    
         
            +
              subject { described_class.new :api_key, :rest_url, {}}
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
              before { subject.http = http }
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              it 'makes an http call to the delete user endpoint' do
         
     | 
| 
       17 
17 
     | 
    
         
             
                expect(http).to receive(:post).with '/users/delete',
         
     | 
| 
       18 
     | 
    
         
            -
                    payload 
     | 
| 
      
 18 
     | 
    
         
            +
                    payload
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                subject.perform( 
     | 
| 
      
 20 
     | 
    
         
            +
                subject.perform(**payload)
         
     | 
| 
       21 
21 
     | 
    
         
             
              end
         
     | 
| 
       22 
22 
     | 
    
         
             
            end
         
     | 
| 
         @@ -8,14 +8,14 @@ describe BrazeRuby::REST::ExportUsers do 
     | 
|
| 
       8 
8 
     | 
    
         
             
              let(:payload) {{ external_ids: external_ids }}
         
     | 
| 
       9 
9 
     | 
    
         
             
              let(:external_ids) { [1] }
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
              subject { described_class.new :rest_url, {} }
         
     | 
| 
      
 11 
     | 
    
         
            +
              subject { described_class.new :api_key, :rest_url, {} }
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              before { subject.http = http }
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              it 'makes an http call to the track user endpoint' do
         
     | 
| 
       16 
16 
     | 
    
         
             
                expect(http).to receive(:post).with '/users/export/ids',
         
     | 
| 
       17 
     | 
    
         
            -
                    payload 
     | 
| 
      
 17 
     | 
    
         
            +
                    payload
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                subject.perform( 
     | 
| 
      
 19 
     | 
    
         
            +
                subject.perform(**payload)
         
     | 
| 
       20 
20 
     | 
    
         
             
              end
         
     | 
| 
       21 
21 
     | 
    
         
             
            end
         
     | 
| 
         @@ -10,14 +10,14 @@ describe BrazeRuby::REST::IdentifyUsers do 
     | 
|
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              let(:api_key) { :api_key }
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
              subject { described_class.new :rest_url, {}}
         
     | 
| 
      
 13 
     | 
    
         
            +
              subject { described_class.new :api_key, :rest_url, {}}
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              before { subject.http = http }
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
              it 'makes an http call to the identify users endpoint' do
         
     | 
| 
       18 
18 
     | 
    
         
             
                expect(http).to receive(:post).with '/users/identify',
         
     | 
| 
       19 
     | 
    
         
            -
                    payload 
     | 
| 
      
 19 
     | 
    
         
            +
                    payload
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                subject.perform( 
     | 
| 
      
 21 
     | 
    
         
            +
                subject.perform(**payload)
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
23 
     | 
    
         
             
            end
         
     | 
| 
         @@ -14,7 +14,7 @@ describe BrazeRuby::REST::ScheduleMessages do 
     | 
|
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              let(:api_key) { :api_key }
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              subject { described_class.new(api_key, :rest_url, {}, payload) }
         
     | 
| 
      
 17 
     | 
    
         
            +
              subject { described_class.new(api_key, :rest_url, {}, **payload) }
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              before { subject.http = http }
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
         @@ -26,7 +26,6 @@ describe BrazeRuby::REST::ScheduleMessages do 
     | 
|
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
              def expect_schedule_messages_http_call
         
     | 
| 
       28 
28 
     | 
    
         
             
                expect(http).to receive(:post).with '/messages/schedule/create', {
         
     | 
| 
       29 
     | 
    
         
            -
                  api_key: api_key,
         
     | 
| 
       30 
29 
     | 
    
         
             
                  external_user_ids: :external_user_ids,
         
     | 
| 
       31 
30 
     | 
    
         
             
                  schedule: {
         
     | 
| 
       32 
31 
     | 
    
         
             
                    time: :time,
         
     |