braze_ruby 0.3.2 → 0.3.3
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/lib/braze_ruby/api.rb +5 -4
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- data/lib/braze_ruby/http.rb +12 -1
- data/lib/braze_ruby/rest/base.rb +3 -2
- data/lib/braze_ruby/rest/canvas_details.rb +2 -2
- data/lib/braze_ruby/rest/email_hard_bounces.rb +2 -2
- data/lib/braze_ruby/rest/email_status.rb +2 -2
- data/lib/braze_ruby/rest/email_unsubscribes.rb +2 -2
- data/lib/braze_ruby/rest/schedule_messages.rb +2 -2
- data/lib/braze_ruby/rest/send_messages.rb +2 -2
- data/lib/braze_ruby/rest/subscription_status_get.rb +2 -2
- data/lib/braze_ruby/rest/subscription_status_set.rb +2 -2
- data/lib/braze_ruby/rest/subscription_user_status.rb +2 -2
- data/lib/braze_ruby/rest/trigger_campaign_send.rb +2 -2
- data/lib/braze_ruby/rest/trigger_canvas_send.rb +2 -2
- data/lib/braze_ruby/version.rb +1 -1
- data/spec/braze_ruby/http_spec.rb +45 -0
- data/spec/braze_ruby/rest/delete_users_spec.rb +1 -1
- data/spec/braze_ruby/rest/email_status_spec.rb +1 -1
- data/spec/braze_ruby/rest/export_users_spec.rb +1 -1
- data/spec/braze_ruby/rest/identify_users_spec.rb +1 -1
- data/spec/braze_ruby/rest/schedule_messages_spec.rb +1 -1
- data/spec/braze_ruby/rest/send_messages_spec.rb +3 -1
- data/spec/braze_ruby/rest/track_users_spec.rb +1 -1
- data/spec/support/integrations.rb +5 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00f98a5e5a27d4b6fee439d6a9e94d4cba07a289d19156676cb40ca461f49ebe
|
4
|
+
data.tar.gz: f1d8d93b6fc59235283f56d97a70e5865648f0112ed96d4e236ee026b71e4afb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5054700908a8a4082656351cf8be6a1e1f2733f1ca9b82a1fb1d3bc6b66332dc1c08c46cb739dd13f3083ee09dde3cf3ecce21afee61aca4d1be46c386a7066f
|
7
|
+
data.tar.gz: a2a388bb6cdef1683ccd31b6a185d2343d6190c4c4d32479158c830fe94ba79bc30599e7c7bc8a882faa11a7bf4fe4267166f0476ec4198e48cf076ab4014240
|
data/lib/braze_ruby/api.rb
CHANGED
@@ -27,18 +27,19 @@ module BrazeRuby
|
|
27
27
|
include BrazeRuby::Endpoints::IdentifyUsers
|
28
28
|
|
29
29
|
def export_users(**payload)
|
30
|
-
BrazeRuby::REST::ExportUsers.new(braze_url).perform(api_key, payload)
|
30
|
+
BrazeRuby::REST::ExportUsers.new(braze_url, options).perform(api_key, payload)
|
31
31
|
end
|
32
32
|
|
33
33
|
def list_segments
|
34
|
-
BrazeRuby::REST::ListSegments.new(braze_url).perform(api_key)
|
34
|
+
BrazeRuby::REST::ListSegments.new(braze_url, options).perform(api_key)
|
35
35
|
end
|
36
36
|
|
37
|
-
attr_reader :api_key, :braze_url
|
37
|
+
attr_reader :api_key, :braze_url, :options
|
38
38
|
|
39
|
-
def initialize(api_key, braze_url)
|
39
|
+
def initialize(api_key, braze_url, options = {})
|
40
40
|
@api_key = api_key
|
41
41
|
@braze_url = braze_url
|
42
|
+
@options = options
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -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, 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, 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, payload).perform
|
11
|
+
BrazeRuby::REST::CanvasDetails.new(api_key, braze_url, options, payload).perform
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -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, 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, payload).perform
|
11
|
+
BrazeRuby::REST::EmailHardBounces.new(api_key, braze_url, options, payload).perform
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -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, 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, 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, payload).perform
|
16
|
+
BrazeRuby::REST::SubscriptionUserStatus.new(api_key, braze_url, options, payload).perform
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/braze_ruby/http.rb
CHANGED
@@ -5,8 +5,11 @@ require 'faraday'
|
|
5
5
|
|
6
6
|
module BrazeRuby
|
7
7
|
class HTTP
|
8
|
-
|
8
|
+
DEFAULT_TIMEOUT = 30
|
9
|
+
|
10
|
+
def initialize(braze_url, options = {})
|
9
11
|
@braze_url = braze_url
|
12
|
+
@options = default_options.merge(options)
|
10
13
|
end
|
11
14
|
|
12
15
|
def post(path, payload)
|
@@ -28,7 +31,15 @@ module BrazeRuby
|
|
28
31
|
connection.response :logger if ENV['BRAZE_RUBY_DEBUG']
|
29
32
|
|
30
33
|
connection.adapter Faraday.default_adapter
|
34
|
+
|
35
|
+
connection.options[:timeout] = @options[:timeout]
|
31
36
|
end
|
32
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def default_options
|
42
|
+
{timeout: DEFAULT_TIMEOUT}
|
43
|
+
end
|
33
44
|
end
|
34
45
|
end
|
data/lib/braze_ruby/rest/base.rb
CHANGED
@@ -7,14 +7,15 @@ module BrazeRuby
|
|
7
7
|
class Base
|
8
8
|
attr_writer :http
|
9
9
|
|
10
|
-
def initialize(braze_url)
|
10
|
+
def initialize(braze_url, options)
|
11
11
|
@braze_url = braze_url
|
12
|
+
@options = options
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
17
|
def http
|
17
|
-
@http ||= BrazeRuby::HTTP.new(@braze_url)
|
18
|
+
@http ||= BrazeRuby::HTTP.new(@braze_url, @options)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -5,10 +5,10 @@ module BrazeRuby
|
|
5
5
|
class CanvasDetails < Base
|
6
6
|
attr_reader :api_key, :params
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, **params)
|
8
|
+
def initialize(api_key, braze_url, options, **params)
|
9
9
|
@api_key = api_key
|
10
10
|
@params = params
|
11
|
-
super braze_url
|
11
|
+
super braze_url, options
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
@@ -5,10 +5,10 @@ module BrazeRuby
|
|
5
5
|
class EmailHardBounces < Base
|
6
6
|
attr_reader :api_key, :params
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, **params)
|
8
|
+
def initialize(api_key, braze_url, options, **params)
|
9
9
|
@api_key = api_key
|
10
10
|
@params = params
|
11
|
-
super braze_url
|
11
|
+
super braze_url, options
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
@@ -5,11 +5,11 @@ module BrazeRuby
|
|
5
5
|
class EmailStatus < Base
|
6
6
|
attr_reader :api_key, :email, :status
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, email: nil, status: nil)
|
8
|
+
def initialize(api_key, braze_url, options, email: nil, status: nil)
|
9
9
|
@api_key = api_key
|
10
10
|
@email = email
|
11
11
|
@status = status
|
12
|
-
super braze_url
|
12
|
+
super braze_url, options
|
13
13
|
end
|
14
14
|
|
15
15
|
def perform
|
@@ -5,10 +5,10 @@ module BrazeRuby
|
|
5
5
|
class EmailUnsubscribes < Base
|
6
6
|
attr_reader :api_key, :params
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, **params)
|
8
|
+
def initialize(api_key, braze_url, options, **params)
|
9
9
|
@api_key = api_key
|
10
10
|
@params = params
|
11
|
-
super braze_url
|
11
|
+
super braze_url, options
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
@@ -5,13 +5,13 @@ module BrazeRuby
|
|
5
5
|
class ScheduleMessages < Base
|
6
6
|
attr_reader :api_key, :time, :messages, :in_local_time, :external_user_ids
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, time: nil, messages: [], external_user_ids: [], in_local_time: false)
|
8
|
+
def initialize(api_key, braze_url, options, time: nil, messages: [], external_user_ids: [], in_local_time: false)
|
9
9
|
@api_key = api_key
|
10
10
|
@messages = messages
|
11
11
|
@time = time
|
12
12
|
@external_user_ids = external_user_ids
|
13
13
|
@in_local_time = in_local_time
|
14
|
-
super braze_url
|
14
|
+
super braze_url, options
|
15
15
|
end
|
16
16
|
|
17
17
|
def perform
|
@@ -5,11 +5,11 @@ module BrazeRuby
|
|
5
5
|
class SendMessages < Base
|
6
6
|
attr_reader :api_key, :messages, :external_user_ids
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, messages: [], external_user_ids: [])
|
8
|
+
def initialize(api_key, braze_url, options, messages: [], external_user_ids: [])
|
9
9
|
@api_key = api_key
|
10
10
|
@messages = messages
|
11
11
|
@external_user_ids = external_user_ids
|
12
|
-
super braze_url
|
12
|
+
super braze_url, options
|
13
13
|
end
|
14
14
|
|
15
15
|
def perform
|
@@ -5,10 +5,10 @@ module BrazeRuby
|
|
5
5
|
class SubscriptionStatusGet < Base
|
6
6
|
attr_reader :api_key, :params
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, **params)
|
8
|
+
def initialize(api_key, braze_url, options, **params)
|
9
9
|
@api_key = api_key
|
10
10
|
@params = params
|
11
|
-
super braze_url
|
11
|
+
super braze_url, options
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
@@ -5,10 +5,10 @@ module BrazeRuby
|
|
5
5
|
class SubscriptionStatusSet < Base
|
6
6
|
attr_reader :api_key, :params
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, **params)
|
8
|
+
def initialize(api_key, braze_url, options, **params)
|
9
9
|
@api_key = api_key
|
10
10
|
@params = params
|
11
|
-
super braze_url
|
11
|
+
super braze_url, options
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
@@ -5,10 +5,10 @@ module BrazeRuby
|
|
5
5
|
class SubscriptionUserStatus < Base
|
6
6
|
attr_reader :api_key, :params
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, **params)
|
8
|
+
def initialize(api_key, braze_url, options, **params)
|
9
9
|
@api_key = api_key
|
10
10
|
@params = params
|
11
|
-
super braze_url
|
11
|
+
super braze_url, options
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
@@ -5,10 +5,10 @@ module BrazeRuby
|
|
5
5
|
class TriggerCampaignSend < Base
|
6
6
|
attr_reader :api_key, :params
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, **params)
|
8
|
+
def initialize(api_key, braze_url, options, **params)
|
9
9
|
@api_key = api_key
|
10
10
|
@params = params
|
11
|
-
super braze_url
|
11
|
+
super braze_url, options
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
@@ -5,10 +5,10 @@ module BrazeRuby
|
|
5
5
|
class TriggerCanvasSend < Base
|
6
6
|
attr_reader :api_key, :params
|
7
7
|
|
8
|
-
def initialize(api_key, braze_url, **params)
|
8
|
+
def initialize(api_key, braze_url, options, **params)
|
9
9
|
@api_key = api_key
|
10
10
|
@params = params
|
11
|
-
super braze_url
|
11
|
+
super braze_url, options
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform
|
data/lib/braze_ruby/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'braze_ruby/http'
|
5
|
+
|
6
|
+
describe BrazeRuby::HTTP do
|
7
|
+
describe "#connection" do
|
8
|
+
let(:options) { double("options", :"[]=" => nil) }
|
9
|
+
let(:headers) { double("headers", :"[]=" => nil) }
|
10
|
+
let(:conn) { double("conn", adapter: nil, options: options, headers: headers) }
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
allow(Faraday).to receive(:new).and_yield(conn)
|
14
|
+
allow(Faraday).to receive(:default_adapter).and_return(:default_adapter)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "it defaults to the timeout option" do
|
18
|
+
described_class.new("http://example.com").connection
|
19
|
+
|
20
|
+
expect(options).to have_received(:"[]=").with(:timeout, described_class::DEFAULT_TIMEOUT)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "it sets the default timeout option when given" do
|
24
|
+
timeout = 5
|
25
|
+
described_class.new("http://example.com", {timeout: timeout}).connection
|
26
|
+
|
27
|
+
expect(options).to have_received(:"[]=").with(:timeout, timeout)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "sets the headers" do
|
31
|
+
described_class.new("http://example.com").connection
|
32
|
+
|
33
|
+
|
34
|
+
expect(headers).to have_received(:"[]=").with("Content-Type", "application/json")
|
35
|
+
expect(headers).to have_received(:"[]=").with("Accept", "application/json")
|
36
|
+
expect(headers).to have_received(:"[]=").with("User-Agent", "Braze Ruby gem v#{BrazeRuby::VERSION}")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "it sets the default adapter" do
|
40
|
+
described_class.new("http://example.com").connection
|
41
|
+
|
42
|
+
expect(conn).to have_received(:adapter).with(:default_adapter)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -7,7 +7,7 @@ describe BrazeRuby::REST::EmailStatus do
|
|
7
7
|
|
8
8
|
before { subject.http = http }
|
9
9
|
|
10
|
-
subject { described_class.new(:api_key, :rest_url, email: :email, status: :status) }
|
10
|
+
subject { described_class.new(:api_key, :rest_url, {}, email: :email, status: :status) }
|
11
11
|
|
12
12
|
it 'makes an http call to the email status endpoint' do
|
13
13
|
expect(http).to receive(:post).with '/email/status', {
|
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.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nussbaum
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-02-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- spec/braze_ruby/api_spec.rb
|
194
194
|
- spec/braze_ruby/endpoints/delete_users_spec.rb
|
195
195
|
- spec/braze_ruby/endpoints/track_users_spec.rb
|
196
|
+
- spec/braze_ruby/http_spec.rb
|
196
197
|
- spec/braze_ruby/rest/delete_users_spec.rb
|
197
198
|
- spec/braze_ruby/rest/email_status_spec.rb
|
198
199
|
- spec/braze_ruby/rest/export_users_spec.rb
|
@@ -282,6 +283,7 @@ test_files:
|
|
282
283
|
- spec/braze_ruby/api_spec.rb
|
283
284
|
- spec/braze_ruby/endpoints/delete_users_spec.rb
|
284
285
|
- spec/braze_ruby/endpoints/track_users_spec.rb
|
286
|
+
- spec/braze_ruby/http_spec.rb
|
285
287
|
- spec/braze_ruby/rest/delete_users_spec.rb
|
286
288
|
- spec/braze_ruby/rest/email_status_spec.rb
|
287
289
|
- spec/braze_ruby/rest/export_users_spec.rb
|