drip-ruby 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/.rubocop_todo.yml +17 -9
- data/.travis.yml +1 -1
- data/CHANGELOG.md +20 -1
- data/Gemfile +10 -0
- data/drip-ruby.gemspec +3 -11
- data/lib/drip/client.rb +44 -66
- data/lib/drip/client/accounts.rb +2 -2
- data/lib/drip/client/broadcasts.rb +2 -2
- data/lib/drip/client/campaign_subscriptions.rb +1 -1
- data/lib/drip/client/campaigns.rb +5 -5
- data/lib/drip/client/configuration.rb +28 -0
- data/lib/drip/client/conversions.rb +2 -2
- data/lib/drip/client/custom_fields.rb +1 -1
- data/lib/drip/client/events.rb +4 -4
- data/lib/drip/client/forms.rb +2 -2
- data/lib/drip/client/http_client.rb +64 -0
- data/lib/drip/client/orders.rb +3 -3
- data/lib/drip/client/shopper_activity.rb +78 -0
- data/lib/drip/client/subscribers.rb +13 -13
- data/lib/drip/client/tags.rb +3 -3
- data/lib/drip/client/webhooks.rb +5 -5
- data/lib/drip/client/workflow_triggers.rb +3 -3
- data/lib/drip/client/workflows.rb +6 -6
- data/lib/drip/request.rb +31 -0
- data/lib/drip/response.rb +13 -13
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/configuration_test.rb +122 -0
- data/test/drip/client/http_client_test.rb +96 -0
- data/test/drip/client/shopper_activity_test.rb +175 -0
- data/test/drip/client_test.rb +32 -97
- data/test/drip/collection_test.rb +14 -0
- data/test/drip/collections/account_test.rb +8 -0
- data/test/drip/collections/broadcasts_test.rb +8 -0
- data/test/drip/collections/campaign_subscriptions_test.rb +8 -0
- data/test/drip/collections/campaigns_test.rb +8 -0
- data/test/drip/collections/errors_test.rb +8 -0
- data/test/drip/collections/orders_test.rb +8 -0
- data/test/drip/collections/purchases_test.rb +8 -0
- data/test/drip/collections/tags_test.rb +8 -0
- data/test/drip/collections/webhooks_test.rb +8 -0
- data/test/drip/collections/workflow_triggers_test.rb +8 -0
- data/test/drip/collections/workflows_test.rb +8 -0
- data/test/drip/request_test.rb +58 -0
- data/test/drip/resource_test.rb +12 -0
- data/test/drip/resources/tag_test.rb +13 -0
- data/test/drip/response_test.rb +33 -0
- data/test/test_helper.rb +3 -0
- metadata +42 -104
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da8e0406199eb9a3a9c4d1dc54822dcf8126897a
|
4
|
+
data.tar.gz: a4ef8f3a36b59e4a54ed2c7f23895bcedea5d60c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c69d1a5f1a6c1749a0d799a4810aef260c875bb0d03c3a975117f15af9108cfb7dc6f3552a8d15eb31c67a44c5709cabbfc026e35efac5f3f0dc002992c013e
|
7
|
+
data.tar.gz: 183dad58f6e69ee0f1f8f102308a9b8fc42dc87c164523220d7e9d17e07bee1b3f510b4f89a00f319676c009a85c0e233969ce15a9abe7d4c85c7acf500622f5
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: '2.
|
4
|
+
TargetRubyVersion: '2.2'
|
5
5
|
Exclude:
|
6
6
|
- 'test/fixtures/**/*'
|
7
7
|
|
@@ -32,3 +32,7 @@ Layout/MultilineMethodCallIndentation:
|
|
32
32
|
Metrics/ClassLength:
|
33
33
|
Exclude:
|
34
34
|
- 'test/**/*'
|
35
|
+
|
36
|
+
Metrics/BlockLength:
|
37
|
+
Exclude:
|
38
|
+
- 'test/**/*'
|
data/.rubocop_todo.yml
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2019-05-02 16:45:21 -0500 using RuboCop version 0.67.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
# Offense count: 2
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
Layout/EmptyLineAfterGuardClause:
|
12
|
+
Exclude:
|
13
|
+
- 'lib/drip/client/subscribers.rb'
|
14
|
+
- 'lib/drip/response.rb'
|
15
|
+
|
9
16
|
# Offense count: 2
|
10
17
|
# Cop supports --auto-correct.
|
11
18
|
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
@@ -14,17 +21,18 @@ Lint/UnusedMethodArgument:
|
|
14
21
|
- 'lib/drip/client.rb'
|
15
22
|
- 'lib/drip/collection.rb'
|
16
23
|
|
17
|
-
# Offense count:
|
24
|
+
# Offense count: 2
|
18
25
|
Metrics/AbcSize:
|
19
|
-
Max:
|
26
|
+
Max: 25
|
20
27
|
|
21
|
-
# Offense count:
|
28
|
+
# Offense count: 8
|
22
29
|
# Configuration parameters: CountComments, ExcludedMethods.
|
30
|
+
# ExcludedMethods: refine
|
23
31
|
Metrics/BlockLength:
|
24
32
|
Max: 46
|
25
33
|
|
26
34
|
# Offense count: 4
|
27
|
-
# Configuration parameters: CountComments.
|
35
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
28
36
|
Metrics/MethodLength:
|
29
37
|
Max: 26
|
30
38
|
|
@@ -39,14 +47,14 @@ Performance/InefficientHashSearch:
|
|
39
47
|
- 'lib/drip/resource.rb'
|
40
48
|
- 'lib/drip/response.rb'
|
41
49
|
|
42
|
-
# Offense count:
|
50
|
+
# Offense count: 24
|
43
51
|
# Cop supports --auto-correct.
|
44
52
|
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
45
53
|
# SupportedStyles: nested, compact
|
46
54
|
Style/ClassAndModuleChildren:
|
47
55
|
Enabled: false
|
48
56
|
|
49
|
-
# Offense count:
|
57
|
+
# Offense count: 44
|
50
58
|
Style/Documentation:
|
51
59
|
Enabled: false
|
52
60
|
|
@@ -81,13 +89,13 @@ Style/MissingRespondToMissing:
|
|
81
89
|
- 'lib/drip/resource.rb'
|
82
90
|
- 'lib/drip/response.rb'
|
83
91
|
|
84
|
-
# Offense count:
|
92
|
+
# Offense count: 12
|
85
93
|
# Cop supports --auto-correct.
|
86
94
|
# Configuration parameters: Strict.
|
87
95
|
Style/NumericLiterals:
|
88
96
|
MinDigits: 8
|
89
97
|
|
90
|
-
# Offense count:
|
98
|
+
# Offense count: 700
|
91
99
|
# Cop supports --auto-correct.
|
92
100
|
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
93
101
|
# SupportedStyles: single_quotes, double_quotes
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,10 +6,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
-
[master]: https://github.com/DripEmail/drip-ruby/compare/v3.
|
9
|
+
[master]: https://github.com/DripEmail/drip-ruby/compare/v3.3.0...HEAD
|
10
10
|
|
11
11
|
- Your contribution here!
|
12
12
|
|
13
|
+
## [3.3.0] - 2019-05-24
|
14
|
+
|
15
|
+
[3.3.0]: https://github.com/DripEmail/drip-ruby/compare/v3.2.0...v3.3.0
|
16
|
+
|
17
|
+
### Added
|
18
|
+
- Support for the cart, order, and product endpoints in the shopper activity API.
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
- `Drip::Client#url_prefix` parameter no longer includes `/vN` part of the URL in order to prepare for Shopper Activity API. This breaks backwards compatibility for this option, but there is no expected production usage of this parameter.
|
22
|
+
- `Drip::Client#get`, `Drip::Client#post`, `Drip::Client#put`, and `Drip::Client#delete` are deprecated. If you are using these to hit a Drip API endpoint, please file a ticket or PR to fix the use case.
|
23
|
+
- `Drip::Client#generate_resource` is deprecated and will be removed in a future version.
|
24
|
+
- `Drip::Client#content_type` is deprecated and will be removed in a future version. It is no longer used internally, effective immediately.
|
25
|
+
- When using the block form of parameter initialization, a configuration object is provided instead of the client itself.
|
26
|
+
- Calling configuration setters on `Drip::Client` is deprecated.
|
27
|
+
- `Drip::Client::REDIRECT_LIMIT` constant is now private. This is supposed to be an implementation detail and shouldn't leak.
|
28
|
+
|
29
|
+
### Removed
|
30
|
+
- Drop support for Ruby 2.1.
|
31
|
+
|
13
32
|
## [3.2.0] - 2018-08-15
|
14
33
|
|
15
34
|
[3.2.0]: https://github.com/DripEmail/drip-ruby/compare/v3.1.1...v3.2.0
|
data/Gemfile
CHANGED
@@ -2,3 +2,13 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in drip-ruby.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
gem "bundler", ">= 1.6", "< 3"
|
7
|
+
gem "minitest", "~> 5.0"
|
8
|
+
gem "mocha", "~> 1.1"
|
9
|
+
gem "rake", "~> 12.0"
|
10
|
+
gem "rubocop", "~> 0.67.2"
|
11
|
+
gem "rubocop-performance", "~> 1.1.0"
|
12
|
+
gem "shoulda-context", "~> 1.0"
|
13
|
+
gem "simplecov", require: false
|
14
|
+
gem "webmock", "~> 3.4"
|
data/drip-ruby.gemspec
CHANGED
@@ -7,8 +7,8 @@ require 'drip/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "drip-ruby"
|
9
9
|
spec.version = Drip::VERSION
|
10
|
-
spec.authors = ["
|
11
|
-
spec.email = ["
|
10
|
+
spec.authors = ["Drip"]
|
11
|
+
spec.email = ["support@drip.com"]
|
12
12
|
spec.summary = 'A Ruby gem for interacting with the Drip API'
|
13
13
|
spec.description = 'A simple wrapper for the Drip API'
|
14
14
|
spec.homepage = "http://github.com/DripEmail/drip-ruby"
|
@@ -19,13 +19,5 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.required_ruby_version = '>= 2.
|
23
|
-
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
26
|
-
spec.add_development_dependency "mocha", "~> 1.1"
|
27
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
-
spec.add_development_dependency "rubocop", "~> 0.56.0"
|
29
|
-
spec.add_development_dependency "shoulda-context", "~> 1.0"
|
30
|
-
spec.add_development_dependency "webmock", "~> 3.4"
|
22
|
+
spec.required_ruby_version = '>= 2.2'
|
31
23
|
end
|
data/lib/drip/client.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
require "drip/errors"
|
2
|
+
require "drip/request"
|
2
3
|
require "drip/response"
|
3
4
|
require "drip/client/accounts"
|
4
5
|
require "drip/client/broadcasts"
|
5
6
|
require "drip/client/campaigns"
|
6
7
|
require "drip/client/campaign_subscriptions"
|
8
|
+
require "drip/client/configuration"
|
7
9
|
require "drip/client/conversions"
|
8
10
|
require "drip/client/custom_fields"
|
9
11
|
require "drip/client/events"
|
10
12
|
require "drip/client/forms"
|
13
|
+
require "drip/client/http_client"
|
11
14
|
require "drip/client/orders"
|
15
|
+
require "drip/client/shopper_activity"
|
12
16
|
require "drip/client/subscribers"
|
13
17
|
require "drip/client/tags"
|
14
18
|
require "drip/client/webhooks"
|
@@ -29,88 +33,75 @@ module Drip
|
|
29
33
|
include Events
|
30
34
|
include Forms
|
31
35
|
include Orders
|
36
|
+
include ShopperActivity
|
32
37
|
include Subscribers
|
33
38
|
include Tags
|
34
39
|
include Webhooks
|
35
40
|
include Workflows
|
36
41
|
include WorkflowTriggers
|
37
42
|
|
38
|
-
|
43
|
+
Drip::Client::Configuration::CONFIGURATION_FIELDS.each do |config_key|
|
44
|
+
define_method(config_key) do
|
45
|
+
@config.public_send(config_key)
|
46
|
+
end
|
47
|
+
|
48
|
+
setter_name = "#{config_key}=".to_sym
|
49
|
+
define_method(setter_name) do |val|
|
50
|
+
warn "[DEPRECATED] Setting configuration on Drip::Client after initialization will be removed in a future version"
|
51
|
+
@config.public_send(setter_name, val)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
JSON_API_CONTENT_TYPE = "application/vnd.api+json".freeze
|
56
|
+
private_constant :JSON_API_CONTENT_TYPE
|
39
57
|
|
40
|
-
|
58
|
+
JSON_CONTENT_TYPE = "application/json".freeze
|
59
|
+
private_constant :JSON_CONTENT_TYPE
|
41
60
|
|
42
61
|
def initialize(options = {})
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@api_key = options[:api_key]
|
46
|
-
@url_prefix = options[:url_prefix] || "https://api.getdrip.com/v2/"
|
47
|
-
@http_open_timeout = options[:http_open_timeout]
|
48
|
-
@http_timeout = options[:http_timeout]
|
49
|
-
yield(self) if block_given?
|
62
|
+
@config = Drip::Client::Configuration.new(options)
|
63
|
+
yield(@config) if block_given?
|
50
64
|
end
|
51
65
|
|
52
66
|
def generate_resource(key, *args)
|
53
|
-
|
67
|
+
warn "[DEPRECATED] Drip::Client#generate_resource is deprecated and will be removed in a future version"
|
68
|
+
private_generate_resource(key, *args)
|
54
69
|
end
|
55
70
|
|
56
71
|
def content_type
|
57
|
-
|
72
|
+
warn "[DEPRECATED] Drip::Client#content_type is deprecated and will be removed in a future version"
|
73
|
+
JSON_API_CONTENT_TYPE
|
58
74
|
end
|
59
75
|
|
60
|
-
|
61
|
-
|
76
|
+
Drip::Request::VERB_CLASS_MAPPING.keys.each do |verb|
|
77
|
+
define_method(verb) do |path, options = {}|
|
78
|
+
warn "[DEPRECATED] Drip::Client##{verb} please use the API endpoint specific methods"
|
79
|
+
make_json_api_request(verb, "v2/#{path}", options)
|
80
|
+
end
|
62
81
|
end
|
63
82
|
|
64
|
-
|
65
|
-
make_request(Net::HTTP::Post, make_uri(url), options)
|
66
|
-
end
|
83
|
+
private
|
67
84
|
|
68
|
-
def
|
69
|
-
make_request(
|
85
|
+
def make_json_api_request(http_verb, path, options = {})
|
86
|
+
make_request Drip::Request.new(http_verb, make_uri(path), options, JSON_API_CONTENT_TYPE)
|
70
87
|
end
|
71
88
|
|
72
|
-
def
|
73
|
-
make_request(
|
89
|
+
def make_json_request(http_verb, path, options = {})
|
90
|
+
make_request Drip::Request.new(http_verb, make_uri(path), options, JSON_CONTENT_TYPE)
|
74
91
|
end
|
75
92
|
|
76
|
-
|
93
|
+
def private_generate_resource(key, *args)
|
94
|
+
# No reason for this to be part of the public API, so making a duplicate method to make it private.
|
95
|
+
{ key => args }
|
96
|
+
end
|
77
97
|
|
78
98
|
def make_uri(path)
|
79
|
-
URI(url_prefix) + URI(path)
|
99
|
+
URI(@config.url_prefix) + URI(path)
|
80
100
|
end
|
81
101
|
|
82
|
-
def make_request(
|
83
|
-
raise TooManyRedirectsError, 'too many HTTP redirects' if step >= REDIRECT_LIMIT
|
84
|
-
|
102
|
+
def make_request(drip_request)
|
85
103
|
build_response do
|
86
|
-
|
87
|
-
if verb_klass == Net::HTTP::Get
|
88
|
-
uri.query = URI.encode_www_form(options)
|
89
|
-
end
|
90
|
-
|
91
|
-
request = verb_klass.new uri
|
92
|
-
|
93
|
-
unless verb_klass == Net::HTTP::Get
|
94
|
-
request.body = options.to_json
|
95
|
-
end
|
96
|
-
|
97
|
-
request['User-Agent'] = "Drip Ruby v#{Drip::VERSION}"
|
98
|
-
request['Content-Type'] = content_type
|
99
|
-
request['Accept'] = "*/*"
|
100
|
-
|
101
|
-
if access_token
|
102
|
-
request['Authorization'] = "Bearer #{access_token}"
|
103
|
-
else
|
104
|
-
request.basic_auth api_key, ""
|
105
|
-
end
|
106
|
-
|
107
|
-
response = http.request request
|
108
|
-
if response.is_a?(Net::HTTPRedirection)
|
109
|
-
return make_request(verb_klass, URI(response["Location"]), options, step + 1)
|
110
|
-
else
|
111
|
-
response
|
112
|
-
end
|
113
|
-
end
|
104
|
+
Drip::Client::HTTPClient.new(@config).make_request(drip_request)
|
114
105
|
end
|
115
106
|
end
|
116
107
|
|
@@ -120,18 +111,5 @@ module Drip
|
|
120
111
|
rescue JSON::ParserError
|
121
112
|
Drip::Response.new(response.code.to_i, nil)
|
122
113
|
end
|
123
|
-
|
124
|
-
def connection_options(uri_scheme)
|
125
|
-
options = { use_ssl: uri_scheme == "https" }
|
126
|
-
|
127
|
-
if @http_open_timeout
|
128
|
-
options[:open_timeout] = @http_open_timeout
|
129
|
-
options[:ssl_timeout] = @http_open_timeout
|
130
|
-
end
|
131
|
-
|
132
|
-
options[:read_timeout] = @http_timeout if @http_timeout
|
133
|
-
|
134
|
-
options
|
135
|
-
end
|
136
114
|
end
|
137
115
|
end
|
data/lib/drip/client/accounts.rb
CHANGED
@@ -6,7 +6,7 @@ module Drip
|
|
6
6
|
# Returns a Drip::Response.
|
7
7
|
# See https://www.getdrip.com/docs/rest-api#accounts
|
8
8
|
def accounts
|
9
|
-
get "accounts"
|
9
|
+
make_json_api_request :get, "v2/accounts"
|
10
10
|
end
|
11
11
|
|
12
12
|
# Public: Fetch an account.
|
@@ -16,7 +16,7 @@ module Drip
|
|
16
16
|
# Returns a Drip::Response.
|
17
17
|
# See https://www.getdrip.com/docs/rest-api#accounts
|
18
18
|
def account(id)
|
19
|
-
get "accounts/#{id}"
|
19
|
+
make_json_api_request :get, "v2/accounts/#{id}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -12,7 +12,7 @@ module Drip
|
|
12
12
|
# Returns a Drip::Response
|
13
13
|
# See https://www.getdrip.com/docs/rest-api#broadcasts
|
14
14
|
def broadcasts(options = {})
|
15
|
-
get "
|
15
|
+
make_json_api_request :get, "v2/#{account_id}/broadcasts", options
|
16
16
|
end
|
17
17
|
|
18
18
|
# Public: Fetch a broadcast.
|
@@ -22,7 +22,7 @@ module Drip
|
|
22
22
|
# Returns a Drip::Response.
|
23
23
|
# See https://www.getdrip.com/docs/rest-api#broadcasts
|
24
24
|
def broadcast(id)
|
25
|
-
get "
|
25
|
+
make_json_api_request :get, "v2/#{account_id}/broadcasts/#{id}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -8,7 +8,7 @@ module Drip
|
|
8
8
|
# Returns a Drip::Response.
|
9
9
|
# See https://www.getdrip.com/docs.rest-api#campaign_subscriptions
|
10
10
|
def campaign_subscriptions(subscriber_id)
|
11
|
-
get "
|
11
|
+
make_json_api_request :get, "v2/#{account_id}/subscribers/#{subscriber_id}/campaign_subscriptions"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -14,7 +14,7 @@ module Drip
|
|
14
14
|
# Returns a Drip::Response.
|
15
15
|
# See https://www.getdrip.com/docs.rest-api#campaigns
|
16
16
|
def campaigns(options = {})
|
17
|
-
get "
|
17
|
+
make_json_api_request :get, "v2/#{account_id}/campaigns", options
|
18
18
|
end
|
19
19
|
|
20
20
|
# Public: Fetch a campaign.
|
@@ -24,7 +24,7 @@ module Drip
|
|
24
24
|
# Returns a Drip::Response.
|
25
25
|
# See https://www.getdrip.com/docs/rest-api#campaigns
|
26
26
|
def campaign(id)
|
27
|
-
get "
|
27
|
+
make_json_api_request :get, "v2/#{account_id}/campaigns/#{id}"
|
28
28
|
end
|
29
29
|
|
30
30
|
# Public: Activate a campaign.
|
@@ -34,7 +34,7 @@ module Drip
|
|
34
34
|
# Returns a Drip::Response.
|
35
35
|
# See https://www.getdrip.com/docs/rest-api#campaigns
|
36
36
|
def activate_campaign(id)
|
37
|
-
post "
|
37
|
+
make_json_api_request :post, "v2/#{account_id}/campaigns/#{id}/activate"
|
38
38
|
end
|
39
39
|
|
40
40
|
# Public: Pause a campaign.
|
@@ -44,7 +44,7 @@ module Drip
|
|
44
44
|
# Returns a Drip::Response.
|
45
45
|
# See https://www.getdrip.com/docs/rest-api#campaigns
|
46
46
|
def pause_campaign(id)
|
47
|
-
post "
|
47
|
+
make_json_api_request :post, "v2/#{account_id}/campaigns/#{id}/pause"
|
48
48
|
end
|
49
49
|
|
50
50
|
# Public: List everyone subscribed to a campaign.
|
@@ -68,7 +68,7 @@ module Drip
|
|
68
68
|
# Returns a Drip::Response.
|
69
69
|
# See https://www.getdrip.com/docs/rest-api#campaigns
|
70
70
|
def campaign_subscribers(id, options = {})
|
71
|
-
get "
|
71
|
+
make_json_api_request :get, "v2/#{account_id}/campaigns/#{id}/subscribers", options
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Drip
|
2
|
+
class Client
|
3
|
+
class Configuration
|
4
|
+
DEFAULT_URL_PREFIX = "https://api.getdrip.com/".freeze
|
5
|
+
private_constant :DEFAULT_URL_PREFIX
|
6
|
+
|
7
|
+
CONFIGURATION_FIELDS = %i[access_token api_key account_id url_prefix http_open_timeout http_timeout].freeze
|
8
|
+
|
9
|
+
attr_accessor(*CONFIGURATION_FIELDS)
|
10
|
+
|
11
|
+
def initialize(**options)
|
12
|
+
remainder = options.keys - CONFIGURATION_FIELDS
|
13
|
+
raise ArgumentError, "unknown keyword#{'s' if remainder.size > 1}: #{remainder.join(', ')}" unless remainder.empty?
|
14
|
+
|
15
|
+
# Initialize this variable to suppress Ruby warning.
|
16
|
+
@url_prefix = nil
|
17
|
+
|
18
|
+
options.each do |k, v|
|
19
|
+
public_send("#{k}=", v)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def url_prefix
|
24
|
+
@url_prefix || DEFAULT_URL_PREFIX
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|