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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00f98a5e5a27d4b6fee439d6a9e94d4cba07a289d19156676cb40ca461f49ebe
4
- data.tar.gz: f1d8d93b6fc59235283f56d97a70e5865648f0112ed96d4e236ee026b71e4afb
3
+ metadata.gz: c8cd9bb68fd35c0ccd7a9ecae5c5231696f2a48e906cea65f4436d7383167916
4
+ data.tar.gz: 54c80de739f86eaf92321a6ff2a2fae377e17c2915427ea614e242547debd32a
5
5
  SHA512:
6
- metadata.gz: 5054700908a8a4082656351cf8be6a1e1f2733f1ca9b82a1fb1d3bc6b66332dc1c08c46cb739dd13f3083ee09dde3cf3ecce21afee61aca4d1be46c386a7066f
7
- data.tar.gz: a2a388bb6cdef1683ccd31b6a185d2343d6190c4c4d32479158c830fe94ba79bc30599e7c7bc8a882faa11a7bf4fe4267166f0476ec4198e48cf076ab4014240
6
+ metadata.gz: 8862330d38a1b209bcb0afcb4ad11140e91c76cb3d4070010ed39f8272c3a21834412e5d41945e2e5a0e1ed8bc162e6ef75d92933e5e16b7cb1960e7bf1ff0ed
7
+ data.tar.gz: 6df0f44bc9e59531234a465384eb2ad7996abf43329f84aa0efff5714c980269277e83f464e0b6e33a54fc2ef6753e66d48110f34dbda8e4fa0bb203c024de39
@@ -7,13 +7,24 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
 
9
9
  steps:
10
- - uses: actions/checkout@v1
10
+ - uses: actions/checkout@v2
11
+
11
12
  - name: Set up Ruby
12
- uses: actions/setup-ruby@v1
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6
16
+
17
+ - name: Cache gems
18
+ uses: actions/cache@v1
13
19
  with:
14
- ruby-version: 2.6.x
20
+ path: vendor/bundle
21
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
22
+ restore-keys: |
23
+ ${{ runner.os }}-gems-
24
+
15
25
  - name: Build and test
16
26
  run: |
17
27
  gem install bundler
28
+ bundle config path vendor/bundle
18
29
  bundle install --jobs 4 --retry 3
19
30
  bundle exec rake spec
@@ -1,64 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- braze_ruby (0.3.2)
4
+ braze_ruby (0.4.0)
5
5
  faraday
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.0.0)
10
+ activesupport (6.0.3.2)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 0.7, < 2)
13
13
  minitest (~> 5.1)
14
14
  tzinfo (~> 1.1)
15
- zeitwerk (~> 2.1, >= 2.1.8)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
16
  addressable (2.7.0)
17
17
  public_suffix (>= 2.0.2, < 5.0)
18
- coderay (1.1.2)
19
- concurrent-ruby (1.1.5)
18
+ coderay (1.1.3)
19
+ concurrent-ruby (1.1.6)
20
20
  crack (0.4.3)
21
21
  safe_yaml (~> 1.0.0)
22
22
  diff-lcs (1.3)
23
23
  dotenv (2.7.5)
24
- factory_bot (5.1.0)
24
+ factory_bot (5.2.0)
25
25
  activesupport (>= 4.2.0)
26
- faraday (0.17.1)
26
+ faraday (1.0.1)
27
27
  multipart-post (>= 1.2, < 3)
28
- hashdiff (1.0.0)
29
- i18n (1.6.0)
28
+ hashdiff (1.0.1)
29
+ i18n (1.8.3)
30
30
  concurrent-ruby (~> 1.0)
31
- method_source (0.9.2)
32
- minitest (5.12.0)
31
+ method_source (1.0.0)
32
+ minitest (5.14.1)
33
33
  multipart-post (2.1.1)
34
- pry (0.12.2)
35
- coderay (~> 1.1.0)
36
- method_source (~> 0.9.0)
37
- public_suffix (4.0.1)
38
- rake (12.3.3)
39
- rspec (3.8.0)
40
- rspec-core (~> 3.8.0)
41
- rspec-expectations (~> 3.8.0)
42
- rspec-mocks (~> 3.8.0)
43
- rspec-core (3.8.2)
44
- rspec-support (~> 3.8.0)
45
- rspec-expectations (3.8.4)
34
+ pry (0.13.1)
35
+ coderay (~> 1.1)
36
+ method_source (~> 1.0)
37
+ public_suffix (4.0.5)
38
+ rake (13.0.1)
39
+ rspec (3.9.0)
40
+ rspec-core (~> 3.9.0)
41
+ rspec-expectations (~> 3.9.0)
42
+ rspec-mocks (~> 3.9.0)
43
+ rspec-core (3.9.2)
44
+ rspec-support (~> 3.9.3)
45
+ rspec-expectations (3.9.2)
46
46
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.8.0)
48
- rspec-mocks (3.8.1)
47
+ rspec-support (~> 3.9.0)
48
+ rspec-mocks (3.9.1)
49
49
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.8.0)
51
- rspec-support (3.8.2)
50
+ rspec-support (~> 3.9.0)
51
+ rspec-support (3.9.3)
52
52
  safe_yaml (1.0.5)
53
53
  thread_safe (0.3.6)
54
- tzinfo (1.2.5)
54
+ tzinfo (1.2.7)
55
55
  thread_safe (~> 0.1)
56
- vcr (5.0.0)
57
- webmock (3.7.5)
56
+ vcr (6.0.0)
57
+ webmock (3.8.3)
58
58
  addressable (>= 2.3.6)
59
59
  crack (>= 0.3.2)
60
60
  hashdiff (>= 0.4.0, < 2.0.0)
61
- zeitwerk (2.1.10)
61
+ zeitwerk (2.3.0)
62
62
 
63
63
  PLATFORMS
64
64
  ruby
@@ -67,12 +67,12 @@ DEPENDENCIES
67
67
  braze_ruby!
68
68
  bundler (>= 1.3)
69
69
  dotenv (~> 2.7.5)
70
- factory_bot (~> 5.1.0)
71
- pry (~> 0.12.2)
72
- rake (~> 12.3.3)
73
- rspec (~> 3.8.0)
74
- vcr (~> 5.0.0)
75
- webmock (~> 3.7.5)
70
+ factory_bot (>= 5.1.0)
71
+ pry (>= 0.12.2)
72
+ rake (>= 12.3.3)
73
+ rspec (~> 3.8)
74
+ vcr (>= 5.0.0)
75
+ webmock (>= 3.7.5)
76
76
 
77
77
  BUNDLED WITH
78
- 2.1.1
78
+ 2.1.4
@@ -28,11 +28,11 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'faraday'
29
29
 
30
30
  spec.add_development_dependency 'bundler', '>= 1.3'
31
- spec.add_development_dependency 'rake', '~> 12.3.3'
32
- spec.add_development_dependency 'rspec', '~> 3.8.0'
31
+ spec.add_development_dependency 'rake', '>= 12.3.3'
32
+ spec.add_development_dependency 'rspec', '~> 3.8'
33
33
  spec.add_development_dependency 'dotenv', '~> 2.7.5'
34
- spec.add_development_dependency 'vcr', '~> 5.0.0'
35
- spec.add_development_dependency 'webmock', '~> 3.7.5'
36
- spec.add_development_dependency 'pry', '~> 0.12.2'
37
- spec.add_development_dependency 'factory_bot', '~> 5.1.0'
34
+ spec.add_development_dependency 'vcr', '>= 5.0.0'
35
+ spec.add_development_dependency 'webmock', '>= 3.7.5'
36
+ spec.add_development_dependency 'pry', '>= 0.12.2'
37
+ spec.add_development_dependency 'factory_bot', '>= 5.1.0'
38
38
  end
@@ -27,11 +27,11 @@ module BrazeRuby
27
27
  include BrazeRuby::Endpoints::IdentifyUsers
28
28
 
29
29
  def export_users(**payload)
30
- BrazeRuby::REST::ExportUsers.new(braze_url, options).perform(api_key, payload)
30
+ BrazeRuby::REST::ExportUsers.new(api_key, braze_url, options).perform(**payload)
31
31
  end
32
32
 
33
33
  def list_segments
34
- BrazeRuby::REST::ListSegments.new(braze_url, options).perform(api_key)
34
+ BrazeRuby::REST::ListSegments.new(api_key, braze_url, options).perform
35
35
  end
36
36
 
37
37
  attr_reader :api_key, :braze_url, :options
@@ -4,7 +4,7 @@ module BrazeRuby
4
4
  module Endpoints
5
5
  module Campaigns
6
6
  def trigger_campaign_send(**payload)
7
- BrazeRuby::REST::TriggerCampaignSend.new(api_key, braze_url, options, payload).perform
7
+ BrazeRuby::REST::TriggerCampaignSend.new(api_key, braze_url, options, **payload).perform
8
8
  end
9
9
  end
10
10
  end
@@ -4,11 +4,11 @@ module BrazeRuby
4
4
  module Endpoints
5
5
  module Canvas
6
6
  def trigger_canvas_send(**payload)
7
- BrazeRuby::REST::TriggerCanvasSend.new(api_key, braze_url, options, payload).perform
7
+ BrazeRuby::REST::TriggerCanvasSend.new(api_key, braze_url, options, **payload).perform
8
8
  end
9
9
 
10
10
  def canvas_details(**payload)
11
- BrazeRuby::REST::CanvasDetails.new(api_key, braze_url, options, payload).perform
11
+ BrazeRuby::REST::CanvasDetails.new(api_key, braze_url, options, **payload).perform
12
12
  end
13
13
  end
14
14
  end
@@ -6,7 +6,7 @@ module BrazeRuby
6
6
  attr_writer :delete_users_service
7
7
 
8
8
  def delete_users_action(**payload)
9
- delete_users_service.perform(api_key, payload)
9
+ delete_users_service.perform(**payload)
10
10
  end
11
11
 
12
12
  def delete_users(payload)
@@ -16,7 +16,7 @@ module BrazeRuby
16
16
  private
17
17
 
18
18
  def delete_users_service
19
- @delete_users_service ||= BrazeRuby::REST::DeleteUsers.new(braze_url, options)
19
+ @delete_users_service ||= BrazeRuby::REST::DeleteUsers.new(api_key, braze_url, options)
20
20
  end
21
21
  end
22
22
  end
@@ -4,7 +4,7 @@ module BrazeRuby
4
4
  module Endpoints
5
5
  module EmailStatus
6
6
  def email_status(**payload)
7
- email_status_service.new(api_key, braze_url, options, payload).perform
7
+ email_status_service.new(api_key, braze_url, options, **payload).perform
8
8
  end
9
9
 
10
10
  def email_status_service
@@ -4,11 +4,11 @@ module BrazeRuby
4
4
  module Endpoints
5
5
  module EmailSync
6
6
  def email_unsubscribes(**payload)
7
- BrazeRuby::REST::EmailUnsubscribes.new(api_key, braze_url, options, payload).perform
7
+ BrazeRuby::REST::EmailUnsubscribes.new(api_key, braze_url, options, **payload).perform
8
8
  end
9
9
 
10
10
  def email_hard_bounces(**payload)
11
- BrazeRuby::REST::EmailHardBounces.new(api_key, braze_url, options, payload).perform
11
+ BrazeRuby::REST::EmailHardBounces.new(api_key, braze_url, options, **payload).perform
12
12
  end
13
13
  end
14
14
  end
@@ -6,13 +6,13 @@ module BrazeRuby
6
6
  attr_writer :identify_users_service
7
7
 
8
8
  def identify_users(**payload)
9
- identify_users_service.perform(api_key, payload)
9
+ identify_users_service.perform(**payload)
10
10
  end
11
11
 
12
12
  private
13
13
 
14
14
  def identify_users_service
15
- @identify_users_service ||= BrazeRuby::REST::IdentifyUsers.new(braze_url, options)
15
+ @identify_users_service ||= BrazeRuby::REST::IdentifyUsers.new(api_key, braze_url, options)
16
16
  end
17
17
  end
18
18
  end
@@ -4,7 +4,7 @@ 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
+ schedule_messages_service.new(api_key, braze_url, options, **payload).perform
8
8
  end
9
9
 
10
10
  private
@@ -4,7 +4,7 @@ module BrazeRuby
4
4
  module Endpoints
5
5
  module SendMessages
6
6
  def send_messages(**payload)
7
- send_messages_service.new(api_key, braze_url, options, payload).perform
7
+ send_messages_service.new(api_key, braze_url, options, **payload).perform
8
8
  end
9
9
 
10
10
  private
@@ -4,16 +4,16 @@ module BrazeRuby
4
4
  module Endpoints
5
5
  module Subscription
6
6
  def subscription_status_set(**payload)
7
- BrazeRuby::REST::SubscriptionStatusSet.new(api_key, braze_url, options, payload).perform
7
+ BrazeRuby::REST::SubscriptionStatusSet.new(api_key, braze_url, options, **payload).perform
8
8
  end
9
9
 
10
10
  def subscription_status_get(**payload)
11
- BrazeRuby::REST::SubscriptionStatusGet.new(api_key, braze_url, options, payload).perform
11
+ BrazeRuby::REST::SubscriptionStatusGet.new(api_key, braze_url, options, **payload).perform
12
12
  end
13
13
 
14
14
 
15
15
  def subscription_user_status(**payload)
16
- BrazeRuby::REST::SubscriptionUserStatus.new(api_key, braze_url, options, payload).perform
16
+ BrazeRuby::REST::SubscriptionUserStatus.new(api_key, braze_url, options, **payload).perform
17
17
  end
18
18
  end
19
19
  end
@@ -6,25 +6,25 @@ module BrazeRuby
6
6
  attr_writer :track_users_service
7
7
 
8
8
  def track_users(**payload)
9
- track_users_service.perform(api_key, payload)
9
+ track_users_service.perform(**payload)
10
10
  end
11
11
 
12
- def track_purchase(payload)
12
+ def track_purchase(**payload)
13
13
  track_users(purchases: [payload])
14
14
  end
15
15
 
16
- def track_event(payload)
16
+ def track_event(**payload)
17
17
  track_users(events: [payload])
18
18
  end
19
19
 
20
- def track_attribute(payload)
20
+ def track_attribute(**payload)
21
21
  track_users(attributes: [payload])
22
22
  end
23
23
 
24
24
  private
25
25
 
26
26
  def track_users_service
27
- @track_users_service ||= BrazeRuby::REST::TrackUsers.new(braze_url, options)
27
+ @track_users_service ||= BrazeRuby::REST::TrackUsers.new(api_key, braze_url, options)
28
28
  end
29
29
  end
30
30
  end
@@ -7,9 +7,10 @@ module BrazeRuby
7
7
  class HTTP
8
8
  DEFAULT_TIMEOUT = 30
9
9
 
10
- def initialize(braze_url, options = {})
10
+ def initialize(api_key, braze_url, options = {})
11
+ @api_key = api_key
11
12
  @braze_url = braze_url
12
- @options = default_options.merge(options)
13
+ @options = default_options.merge(options)
13
14
  end
14
15
 
15
16
  def post(path, payload)
@@ -18,15 +19,16 @@ module BrazeRuby
18
19
  end
19
20
  end
20
21
 
21
- def get(path, query)
22
+ def get(path, query = {})
22
23
  connection.get path, query
23
24
  end
24
25
 
25
26
  def connection
26
27
  @connection ||= Faraday.new(url: @braze_url) do |connection|
27
- connection.headers['Content-Type'] = 'application/json'
28
- connection.headers['Accept'] = 'application/json'
29
- connection.headers['User-Agent'] = "Braze Ruby gem v#{BrazeRuby::VERSION}"
28
+ connection.headers["Content-Type"] = "application/json"
29
+ connection.headers["Accept"] = "application/json"
30
+ connection.headers["User-Agent"] = "Braze Ruby gem v#{BrazeRuby::VERSION}"
31
+ connection.headers["Authorization"] = "Bearer #{@api_key}"
30
32
 
31
33
  connection.response :logger if ENV['BRAZE_RUBY_DEBUG']
32
34
 
@@ -7,15 +7,16 @@ module BrazeRuby
7
7
  class Base
8
8
  attr_writer :http
9
9
 
10
- def initialize(braze_url, options)
10
+ def initialize(api_key, braze_url, options)
11
+ @api_key = api_key
11
12
  @braze_url = braze_url
12
- @options = options
13
+ @options = options
13
14
  end
14
15
 
15
16
  private
16
17
 
17
18
  def http
18
- @http ||= BrazeRuby::HTTP.new(@braze_url, @options)
19
+ @http ||= BrazeRuby::HTTP.new(@api_key, @braze_url, @options)
19
20
  end
20
21
  end
21
22
  end
@@ -3,17 +3,15 @@
3
3
  module BrazeRuby
4
4
  module REST
5
5
  class CanvasDetails < Base
6
- attr_reader :api_key, :params
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('/canvas/details', {
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 DeleteUsers < Base
6
- def perform(api_key, external_ids: [])
6
+ def perform(external_ids: [])
7
7
  http.post '/users/delete', {
8
- 'api_key': api_key,
9
8
  'external_ids': external_ids
10
9
  }
11
10
  end
@@ -3,17 +3,15 @@
3
3
  module BrazeRuby
4
4
  module REST
5
5
  class EmailHardBounces < Base
6
- attr_reader :api_key, :params
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/hard_bounces', {
16
- 'api_key': api_key,
17
15
  **@params
18
16
  })
19
17
  end