drip-ruby 3.1.1 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +9 -1
  3. data/.rubocop_todo.yml +17 -14
  4. data/.travis.yml +2 -4
  5. data/CHANGELOG.md +51 -1
  6. data/Gemfile +12 -0
  7. data/README.md +6 -0
  8. data/Rakefile +2 -0
  9. data/drip-ruby.gemspec +4 -11
  10. data/lib/drip.rb +2 -0
  11. data/lib/drip/client.rb +48 -66
  12. data/lib/drip/client/accounts.rb +4 -2
  13. data/lib/drip/client/broadcasts.rb +4 -2
  14. data/lib/drip/client/campaign_subscriptions.rb +3 -1
  15. data/lib/drip/client/campaigns.rb +7 -5
  16. data/lib/drip/client/configuration.rb +30 -0
  17. data/lib/drip/client/conversions.rb +4 -2
  18. data/lib/drip/client/custom_fields.rb +3 -1
  19. data/lib/drip/client/events.rb +6 -4
  20. data/lib/drip/client/forms.rb +4 -2
  21. data/lib/drip/client/http_client.rb +66 -0
  22. data/lib/drip/client/orders.rb +5 -3
  23. data/lib/drip/client/shopper_activity.rb +80 -0
  24. data/lib/drip/client/subscribers.rb +23 -16
  25. data/lib/drip/client/tags.rb +5 -3
  26. data/lib/drip/client/users.rb +17 -0
  27. data/lib/drip/client/webhooks.rb +7 -5
  28. data/lib/drip/client/workflow_triggers.rb +5 -3
  29. data/lib/drip/client/workflows.rb +8 -6
  30. data/lib/drip/collection.rb +3 -1
  31. data/lib/drip/collections.rb +2 -0
  32. data/lib/drip/collections/accounts.rb +2 -0
  33. data/lib/drip/collections/broadcasts.rb +2 -0
  34. data/lib/drip/collections/campaign_subscriptions.rb +2 -0
  35. data/lib/drip/collections/campaigns.rb +2 -0
  36. data/lib/drip/collections/errors.rb +2 -0
  37. data/lib/drip/collections/orders.rb +2 -0
  38. data/lib/drip/collections/purchases.rb +2 -0
  39. data/lib/drip/collections/subscribers.rb +2 -0
  40. data/lib/drip/collections/tags.rb +2 -0
  41. data/lib/drip/collections/webhooks.rb +2 -0
  42. data/lib/drip/collections/workflow_triggers.rb +2 -0
  43. data/lib/drip/collections/workflows.rb +2 -0
  44. data/lib/drip/errors.rb +2 -0
  45. data/lib/drip/request.rb +33 -0
  46. data/lib/drip/resource.rb +2 -0
  47. data/lib/drip/resources.rb +2 -0
  48. data/lib/drip/resources/account.rb +2 -0
  49. data/lib/drip/resources/broadcast.rb +2 -0
  50. data/lib/drip/resources/campaign.rb +2 -0
  51. data/lib/drip/resources/campaign_subscription.rb +2 -0
  52. data/lib/drip/resources/error.rb +2 -0
  53. data/lib/drip/resources/order.rb +2 -0
  54. data/lib/drip/resources/purchase.rb +2 -0
  55. data/lib/drip/resources/subscriber.rb +2 -0
  56. data/lib/drip/resources/tag.rb +2 -0
  57. data/lib/drip/resources/webhook.rb +2 -0
  58. data/lib/drip/resources/workflow.rb +2 -0
  59. data/lib/drip/resources/workflow_trigger.rb +2 -0
  60. data/lib/drip/response.rb +15 -13
  61. data/lib/drip/version.rb +3 -1
  62. data/test/drip/client/accounts_test.rb +2 -0
  63. data/test/drip/client/broadcasts_test.rb +2 -0
  64. data/test/drip/client/campaign_subscriptions_test.rb +2 -0
  65. data/test/drip/client/campaigns_test.rb +2 -0
  66. data/test/drip/client/configuration_test.rb +112 -0
  67. data/test/drip/client/conversions_test.rb +2 -0
  68. data/test/drip/client/custom_fields_test.rb +11 -1
  69. data/test/drip/client/events_test.rb +2 -0
  70. data/test/drip/client/forms_test.rb +2 -0
  71. data/test/drip/client/http_client_test.rb +98 -0
  72. data/test/drip/client/orders_test.rb +2 -0
  73. data/test/drip/client/shopper_activity_test.rb +189 -0
  74. data/test/drip/client/subscribers_test.rb +16 -1
  75. data/test/drip/client/tags_test.rb +2 -0
  76. data/test/drip/client/users_test.rb +24 -0
  77. data/test/drip/client/webhooks_test.rb +2 -0
  78. data/test/drip/client/workflow_triggers_test.rb +2 -0
  79. data/test/drip/client/workflows_test.rb +2 -0
  80. data/test/drip/client_test.rb +34 -97
  81. data/test/drip/collection_test.rb +16 -0
  82. data/test/drip/collections/account_test.rb +10 -0
  83. data/test/drip/collections/broadcasts_test.rb +10 -0
  84. data/test/drip/collections/campaign_subscriptions_test.rb +10 -0
  85. data/test/drip/collections/campaigns_test.rb +10 -0
  86. data/test/drip/collections/errors_test.rb +10 -0
  87. data/test/drip/collections/orders_test.rb +10 -0
  88. data/test/drip/collections/purchases_test.rb +10 -0
  89. data/test/drip/collections/tags_test.rb +10 -0
  90. data/test/drip/collections/webhooks_test.rb +10 -0
  91. data/test/drip/collections/workflow_triggers_test.rb +10 -0
  92. data/test/drip/collections/workflows_test.rb +10 -0
  93. data/test/drip/collections_test.rb +2 -0
  94. data/test/drip/request_test.rb +60 -0
  95. data/test/drip/resource_test.rb +14 -0
  96. data/test/drip/resources/account_test.rb +2 -0
  97. data/test/drip/resources/order_test.rb +2 -0
  98. data/test/drip/resources/subscriber_test.rb +2 -0
  99. data/test/drip/resources/tag_test.rb +15 -0
  100. data/test/drip/resources_test.rb +2 -0
  101. data/test/drip/response_test.rb +35 -0
  102. data/test/test_helper.rb +5 -0
  103. metadata +49 -109
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 34ab6a491e2d7b0bdf33b525a11c7d5499bd0e2f
4
- data.tar.gz: d5b703ea0a8f113be93b5c19bbf13849f7fbb6b7
2
+ SHA256:
3
+ metadata.gz: 187036a01190c508e9f62cdb1f0b3feed1f1f48f57b401abbb94f4c76e47f72b
4
+ data.tar.gz: 5f346605646162e11440de3094602e279d615595d3e3cd6ede2b3739a3893d35
5
5
  SHA512:
6
- metadata.gz: ffb4cacb8da55651f34b33c9377de84104fa5913eb520f7437a2b0cf045eba8da1743043538c10ee00be64b562697128d22e35225307d5f4dee1c318c5022bdc
7
- data.tar.gz: 3bce36166a411416f7258939b2283c403ec35903b882144538f95b893f56a61bd7bb3f90503ae61f7c318a834356ca073b594555fbc62f6185f4d8d6fa29908c
6
+ metadata.gz: 84d6861c2a98a80e42c385a84b8a09cca7f556029778acd9bd1e8bcc468b2fb85a09ebb3f4c6192ee9069617e3cb1c57ab26996cc5b04fc843db68144c7b583e
7
+ data.tar.gz: 454de61b3f91e50a7f2948b6698c8e824f8e8a702ff96fb482c2542c0d1437fea5fe051da856f19f9f1340676a5b48c33da3815f989ab7bdbac52829c9f8034c
@@ -1,7 +1,7 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: '2.1'
4
+ TargetRubyVersion: '2.3'
5
5
  Exclude:
6
6
  - 'test/fixtures/**/*'
7
7
 
@@ -28,3 +28,11 @@ Layout/MultilineOperationIndentation:
28
28
 
29
29
  Layout/MultilineMethodCallIndentation:
30
30
  EnforcedStyle: 'indented'
31
+
32
+ Metrics/ClassLength:
33
+ Exclude:
34
+ - 'test/**/*'
35
+
36
+ Metrics/BlockLength:
37
+ Exclude:
38
+ - 'test/**/*'
@@ -1,11 +1,18 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-05-24 10:21:33 -0500 using RuboCop version 0.56.0.
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,22 +21,18 @@ Lint/UnusedMethodArgument:
14
21
  - 'lib/drip/client.rb'
15
22
  - 'lib/drip/collection.rb'
16
23
 
17
- # Offense count: 1
24
+ # Offense count: 2
18
25
  Metrics/AbcSize:
19
- Max: 26
26
+ Max: 25
20
27
 
21
- # Offense count: 5
28
+ # Offense count: 8
22
29
  # Configuration parameters: CountComments, ExcludedMethods.
30
+ # ExcludedMethods: refine
23
31
  Metrics/BlockLength:
24
32
  Max: 46
25
33
 
26
- # Offense count: 3
27
- # Configuration parameters: CountComments.
28
- Metrics/ClassLength:
29
- Max: 173
30
-
31
34
  # Offense count: 4
32
- # Configuration parameters: CountComments.
35
+ # Configuration parameters: CountComments, ExcludedMethods.
33
36
  Metrics/MethodLength:
34
37
  Max: 26
35
38
 
@@ -44,14 +47,14 @@ Performance/InefficientHashSearch:
44
47
  - 'lib/drip/resource.rb'
45
48
  - 'lib/drip/response.rb'
46
49
 
47
- # Offense count: 23
50
+ # Offense count: 24
48
51
  # Cop supports --auto-correct.
49
52
  # Configuration parameters: AutoCorrect, EnforcedStyle.
50
53
  # SupportedStyles: nested, compact
51
54
  Style/ClassAndModuleChildren:
52
55
  Enabled: false
53
56
 
54
- # Offense count: 45
57
+ # Offense count: 44
55
58
  Style/Documentation:
56
59
  Enabled: false
57
60
 
@@ -86,13 +89,13 @@ Style/MissingRespondToMissing:
86
89
  - 'lib/drip/resource.rb'
87
90
  - 'lib/drip/response.rb'
88
91
 
89
- # Offense count: 10
92
+ # Offense count: 12
90
93
  # Cop supports --auto-correct.
91
94
  # Configuration parameters: Strict.
92
95
  Style/NumericLiterals:
93
96
  MinDigits: 8
94
97
 
95
- # Offense count: 605
98
+ # Offense count: 700
96
99
  # Cop supports --auto-correct.
97
100
  # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
98
101
  # SupportedStyles: single_quotes, double_quotes
@@ -1,9 +1,7 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
+ - 2.7
5
+ - 2.6
4
6
  - 2.5
5
- - 2.4
6
- - 2.3
7
- - 2.2
8
- - 2.1
9
7
  - jruby-19mode
@@ -6,10 +6,60 @@ 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.0.0...HEAD
9
+ [master]: https://github.com/DripEmail/drip-ruby/compare/v3.4.1...HEAD
10
10
 
11
11
  - Your contribution here!
12
12
 
13
+ ## [3.4.1] - 2020-04-21
14
+
15
+ [3.4.1]: https://github.com/DripEmail/drip-ruby/compare/v3.4.0...v3.4.1
16
+
17
+ ### Fixed
18
+ - Support for Ruby 2.7 hash parameters.
19
+
20
+ ## [3.4.0] - 2020-04-21
21
+
22
+ [3.4.0]: https://github.com/DripEmail/drip-ruby/compare/v3.3.1...v3.4.0
23
+
24
+ ### Added
25
+ - Support for the user endpoint in the REST API
26
+
27
+ ### Changed
28
+ - `Drip::Client#create_cart_activity_event` can be used with visitor UUID
29
+
30
+ ## [3.3.1] - 2019-05-28
31
+
32
+ [3.3.1]: https://github.com/DripEmail/drip-ruby/compare/v3.3.0...v3.3.1
33
+
34
+ ### Fixed
35
+ - Correct shopper activity batch orders API to wrap things in an `orders` key.
36
+
37
+ ## [3.3.0] - 2019-05-24
38
+
39
+ [3.3.0]: https://github.com/DripEmail/drip-ruby/compare/v3.2.0...v3.3.0
40
+
41
+ ### Added
42
+ - Support for the cart, order, and product endpoints in the shopper activity API.
43
+
44
+ ### Changed
45
+ - `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.
46
+ - `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.
47
+ - `Drip::Client#generate_resource` is deprecated and will be removed in a future version.
48
+ - `Drip::Client#content_type` is deprecated and will be removed in a future version. It is no longer used internally, effective immediately.
49
+ - When using the block form of parameter initialization, a configuration object is provided instead of the client itself.
50
+ - Calling configuration setters on `Drip::Client` is deprecated.
51
+ - `Drip::Client::REDIRECT_LIMIT` constant is now private. This is supposed to be an implementation detail and shouldn't leak.
52
+
53
+ ### Removed
54
+ - Drop support for Ruby 2.1.
55
+
56
+ ## [3.2.0] - 2018-08-15
57
+
58
+ [3.2.0]: https://github.com/DripEmail/drip-ruby/compare/v3.1.1...v3.2.0
59
+
60
+ - Allow `#create_or_update_subscriber` to work with Drip id. Fixes [#50](https://github.com/DripEmail/drip-ruby/issues/50)
61
+ - [#52](https://github.com/DripEmail/drip-ruby/pull/52): Fix `#custom_fields` to accept the API response without error. Fixes [#30](https://github.com/DripEmail/drip-ruby/issues/30)
62
+
13
63
  ## [3.1.1] - 2018-06-06
14
64
 
15
65
  [3.1.1]: https://github.com/DripEmail/drip-ruby/compare/v3.1.0...v3.1.1
data/Gemfile CHANGED
@@ -1,4 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in drip-ruby.gemspec
4
6
  gemspec
7
+
8
+ gem "bundler", ">= 1.6", "< 3"
9
+ gem "minitest", "~> 5.0"
10
+ gem "mocha", "~> 1.1"
11
+ gem "rake", "~> 12.0"
12
+ gem "rubocop", "~> 0.67.2"
13
+ gem "rubocop-performance", "~> 1.1.0"
14
+ gem "shoulda-context", "~> 1.0"
15
+ gem "simplecov", require: false
16
+ gem "webmock", "~> 3.4"
data/README.md CHANGED
@@ -150,6 +150,12 @@ as methods on the client object. The following methods are currently available:
150
150
  | Apply a tag | `#apply_tag(email, tag)` |
151
151
  | Remove a tag | `#remove_tag(email, tag)` |
152
152
 
153
+
154
+ #### Users
155
+ | Actions | Methods |
156
+ | :------------------------- | :--------------------------------------------------- |
157
+ | Fetch user | `#user` |
158
+
153
159
  #### Webhooks
154
160
 
155
161
  | Actions | Methods |
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
3
5
 
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  lib = File.expand_path('../lib', __FILE__)
4
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -7,8 +8,8 @@ require 'drip/version'
7
8
  Gem::Specification.new do |spec|
8
9
  spec.name = "drip-ruby"
9
10
  spec.version = Drip::VERSION
10
- spec.authors = ["Derrick Reimer"]
11
- spec.email = ["derrickreimer@gmail.com"]
11
+ spec.authors = ["Drip"]
12
+ spec.email = ["support@drip.com"]
12
13
  spec.summary = 'A Ruby gem for interacting with the Drip API'
13
14
  spec.description = 'A simple wrapper for the Drip API'
14
15
  spec.homepage = "http://github.com/DripEmail/drip-ruby"
@@ -19,13 +20,5 @@ Gem::Specification.new do |spec|
19
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
21
  spec.require_paths = ["lib"]
21
22
 
22
- spec.required_ruby_version = '>= 2.1'
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"
23
+ spec.required_ruby_version = '>= 2.3'
31
24
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "drip/version"
2
4
  require "drip/client"
@@ -1,16 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "drip/errors"
4
+ require "drip/request"
2
5
  require "drip/response"
3
6
  require "drip/client/accounts"
4
7
  require "drip/client/broadcasts"
5
8
  require "drip/client/campaigns"
6
9
  require "drip/client/campaign_subscriptions"
10
+ require "drip/client/configuration"
7
11
  require "drip/client/conversions"
8
12
  require "drip/client/custom_fields"
9
13
  require "drip/client/events"
10
14
  require "drip/client/forms"
15
+ require "drip/client/http_client"
11
16
  require "drip/client/orders"
17
+ require "drip/client/shopper_activity"
12
18
  require "drip/client/subscribers"
13
19
  require "drip/client/tags"
20
+ require "drip/client/users"
14
21
  require "drip/client/webhooks"
15
22
  require "drip/client/workflows"
16
23
  require "drip/client/workflow_triggers"
@@ -29,88 +36,76 @@ module Drip
29
36
  include Events
30
37
  include Forms
31
38
  include Orders
39
+ include ShopperActivity
32
40
  include Subscribers
33
41
  include Tags
42
+ include Users
34
43
  include Webhooks
35
44
  include Workflows
36
45
  include WorkflowTriggers
37
46
 
38
- REDIRECT_LIMIT = 10
47
+ Drip::Client::Configuration::CONFIGURATION_FIELDS.each do |config_key|
48
+ define_method(config_key) do
49
+ @config.public_send(config_key)
50
+ end
51
+
52
+ setter_name = "#{config_key}=".to_sym
53
+ define_method(setter_name) do |val|
54
+ warn "[DEPRECATED] Setting configuration on Drip::Client after initialization will be removed in a future version"
55
+ @config.public_send(setter_name, val)
56
+ end
57
+ end
58
+
59
+ JSON_API_CONTENT_TYPE = "application/vnd.api+json"
60
+ private_constant :JSON_API_CONTENT_TYPE
39
61
 
40
- attr_accessor :access_token, :api_key, :account_id, :url_prefix, :http_open_timeout, :http_timeout
62
+ JSON_CONTENT_TYPE = "application/json"
63
+ private_constant :JSON_CONTENT_TYPE
41
64
 
42
65
  def initialize(options = {})
43
- @account_id = options[:account_id]
44
- @access_token = options[:access_token]
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?
66
+ @config = Drip::Client::Configuration.new(**options)
67
+ yield(@config) if block_given?
50
68
  end
51
69
 
52
70
  def generate_resource(key, *args)
53
- { key => args }
71
+ warn "[DEPRECATED] Drip::Client#generate_resource is deprecated and will be removed in a future version"
72
+ private_generate_resource(key, *args)
54
73
  end
55
74
 
56
75
  def content_type
57
- 'application/vnd.api+json'
76
+ warn "[DEPRECATED] Drip::Client#content_type is deprecated and will be removed in a future version"
77
+ JSON_API_CONTENT_TYPE
58
78
  end
59
79
 
60
- def get(url, options = {})
61
- make_request(Net::HTTP::Get, make_uri(url), options)
80
+ Drip::Request::VERB_CLASS_MAPPING.keys.each do |verb|
81
+ define_method(verb) do |path, options = {}|
82
+ warn "[DEPRECATED] Drip::Client##{verb} please use the API endpoint specific methods"
83
+ make_json_api_request(verb, "v2/#{path}", options)
84
+ end
62
85
  end
63
86
 
64
- def post(url, options = {})
65
- make_request(Net::HTTP::Post, make_uri(url), options)
66
- end
87
+ private
67
88
 
68
- def put(url, options = {})
69
- make_request(Net::HTTP::Put, make_uri(url), options)
89
+ def make_json_api_request(http_verb, path, options = {})
90
+ make_request Drip::Request.new(http_verb, make_uri(path), options, JSON_API_CONTENT_TYPE)
70
91
  end
71
92
 
72
- def delete(url, options = {})
73
- make_request(Net::HTTP::Delete, make_uri(url), options)
93
+ def make_json_request(http_verb, path, options = {})
94
+ make_request Drip::Request.new(http_verb, make_uri(path), options, JSON_CONTENT_TYPE)
74
95
  end
75
96
 
76
- private
97
+ def private_generate_resource(key, *args)
98
+ # No reason for this to be part of the public API, so making a duplicate method to make it private.
99
+ { key => args }
100
+ end
77
101
 
78
102
  def make_uri(path)
79
- URI(url_prefix) + URI(path)
103
+ URI(@config.url_prefix) + URI(path)
80
104
  end
81
105
 
82
- def make_request(verb_klass, uri, options, step = 0)
83
- raise TooManyRedirectsError, 'too many HTTP redirects' if step >= REDIRECT_LIMIT
84
-
106
+ def make_request(drip_request)
85
107
  build_response do
86
- Net::HTTP.start(uri.host, uri.port, connection_options(uri.scheme)) do |http|
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
108
+ Drip::Client::HTTPClient.new(@config).make_request(drip_request)
114
109
  end
115
110
  end
116
111
 
@@ -120,18 +115,5 @@ module Drip
120
115
  rescue JSON::ParserError
121
116
  Drip::Response.new(response.code.to_i, nil)
122
117
  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
118
  end
137
119
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Drip
2
4
  class Client
3
5
  module Accounts
@@ -6,7 +8,7 @@ module Drip
6
8
  # Returns a Drip::Response.
7
9
  # See https://www.getdrip.com/docs/rest-api#accounts
8
10
  def accounts
9
- get "accounts"
11
+ make_json_api_request :get, "v2/accounts"
10
12
  end
11
13
 
12
14
  # Public: Fetch an account.
@@ -16,7 +18,7 @@ module Drip
16
18
  # Returns a Drip::Response.
17
19
  # See https://www.getdrip.com/docs/rest-api#accounts
18
20
  def account(id)
19
- get "accounts/#{id}"
21
+ make_json_api_request :get, "v2/accounts/#{id}"
20
22
  end
21
23
  end
22
24
  end