drip-ruby 3.2.0 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +5 -5
  2. data/.github/pull_request_template.md +39 -0
  3. data/.rubocop.yml +5 -1
  4. data/.rubocop_todo.yml +17 -9
  5. data/.travis.yml +2 -4
  6. data/CHANGELOG.md +51 -1
  7. data/Gemfile +12 -0
  8. data/README.md +6 -0
  9. data/Rakefile +2 -0
  10. data/drip-ruby.gemspec +4 -11
  11. data/lib/drip.rb +2 -0
  12. data/lib/drip/client.rb +48 -66
  13. data/lib/drip/client/accounts.rb +4 -2
  14. data/lib/drip/client/broadcasts.rb +4 -2
  15. data/lib/drip/client/campaign_subscriptions.rb +3 -1
  16. data/lib/drip/client/campaigns.rb +7 -5
  17. data/lib/drip/client/configuration.rb +30 -0
  18. data/lib/drip/client/conversions.rb +4 -2
  19. data/lib/drip/client/custom_fields.rb +3 -1
  20. data/lib/drip/client/events.rb +6 -4
  21. data/lib/drip/client/forms.rb +4 -2
  22. data/lib/drip/client/http_client.rb +66 -0
  23. data/lib/drip/client/orders.rb +5 -3
  24. data/lib/drip/client/shopper_activity.rb +80 -0
  25. data/lib/drip/client/subscribers.rb +30 -16
  26. data/lib/drip/client/tags.rb +5 -3
  27. data/lib/drip/client/users.rb +17 -0
  28. data/lib/drip/client/webhooks.rb +7 -5
  29. data/lib/drip/client/workflow_triggers.rb +5 -3
  30. data/lib/drip/client/workflows.rb +8 -6
  31. data/lib/drip/collection.rb +2 -0
  32. data/lib/drip/collections.rb +2 -0
  33. data/lib/drip/collections/accounts.rb +2 -0
  34. data/lib/drip/collections/broadcasts.rb +2 -0
  35. data/lib/drip/collections/campaign_subscriptions.rb +2 -0
  36. data/lib/drip/collections/campaigns.rb +2 -0
  37. data/lib/drip/collections/errors.rb +2 -0
  38. data/lib/drip/collections/orders.rb +2 -0
  39. data/lib/drip/collections/purchases.rb +2 -0
  40. data/lib/drip/collections/subscribers.rb +2 -0
  41. data/lib/drip/collections/tags.rb +2 -0
  42. data/lib/drip/collections/webhooks.rb +2 -0
  43. data/lib/drip/collections/workflow_triggers.rb +2 -0
  44. data/lib/drip/collections/workflows.rb +2 -0
  45. data/lib/drip/errors.rb +2 -0
  46. data/lib/drip/request.rb +33 -0
  47. data/lib/drip/resource.rb +2 -0
  48. data/lib/drip/resources.rb +2 -0
  49. data/lib/drip/resources/account.rb +2 -0
  50. data/lib/drip/resources/broadcast.rb +2 -0
  51. data/lib/drip/resources/campaign.rb +2 -0
  52. data/lib/drip/resources/campaign_subscription.rb +2 -0
  53. data/lib/drip/resources/error.rb +2 -0
  54. data/lib/drip/resources/order.rb +2 -0
  55. data/lib/drip/resources/purchase.rb +2 -0
  56. data/lib/drip/resources/subscriber.rb +2 -0
  57. data/lib/drip/resources/tag.rb +2 -0
  58. data/lib/drip/resources/webhook.rb +2 -0
  59. data/lib/drip/resources/workflow.rb +2 -0
  60. data/lib/drip/resources/workflow_trigger.rb +2 -0
  61. data/lib/drip/response.rb +15 -13
  62. data/lib/drip/version.rb +3 -1
  63. data/test/drip/client/accounts_test.rb +2 -0
  64. data/test/drip/client/broadcasts_test.rb +2 -0
  65. data/test/drip/client/campaign_subscriptions_test.rb +2 -0
  66. data/test/drip/client/campaigns_test.rb +2 -0
  67. data/test/drip/client/configuration_test.rb +112 -0
  68. data/test/drip/client/conversions_test.rb +2 -0
  69. data/test/drip/client/custom_fields_test.rb +2 -0
  70. data/test/drip/client/events_test.rb +2 -0
  71. data/test/drip/client/forms_test.rb +2 -0
  72. data/test/drip/client/http_client_test.rb +98 -0
  73. data/test/drip/client/orders_test.rb +2 -0
  74. data/test/drip/client/shopper_activity_test.rb +189 -0
  75. data/test/drip/client/subscribers_test.rb +8 -0
  76. data/test/drip/client/tags_test.rb +2 -0
  77. data/test/drip/client/users_test.rb +24 -0
  78. data/test/drip/client/webhooks_test.rb +2 -0
  79. data/test/drip/client/workflow_triggers_test.rb +2 -0
  80. data/test/drip/client/workflows_test.rb +2 -0
  81. data/test/drip/client_test.rb +34 -97
  82. data/test/drip/collection_test.rb +16 -0
  83. data/test/drip/collections/account_test.rb +10 -0
  84. data/test/drip/collections/broadcasts_test.rb +10 -0
  85. data/test/drip/collections/campaign_subscriptions_test.rb +10 -0
  86. data/test/drip/collections/campaigns_test.rb +10 -0
  87. data/test/drip/collections/errors_test.rb +10 -0
  88. data/test/drip/collections/orders_test.rb +10 -0
  89. data/test/drip/collections/purchases_test.rb +10 -0
  90. data/test/drip/collections/tags_test.rb +10 -0
  91. data/test/drip/collections/webhooks_test.rb +10 -0
  92. data/test/drip/collections/workflow_triggers_test.rb +10 -0
  93. data/test/drip/collections/workflows_test.rb +10 -0
  94. data/test/drip/collections_test.rb +2 -0
  95. data/test/drip/request_test.rb +60 -0
  96. data/test/drip/resource_test.rb +14 -0
  97. data/test/drip/resources/account_test.rb +2 -0
  98. data/test/drip/resources/order_test.rb +2 -0
  99. data/test/drip/resources/subscriber_test.rb +2 -0
  100. data/test/drip/resources/tag_test.rb +15 -0
  101. data/test/drip/resources_test.rb +2 -0
  102. data/test/drip/response_test.rb +35 -0
  103. data/test/test_helper.rb +5 -0
  104. metadata +50 -109
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 70f3d91d9c2443f74403c190edb0cf38e67f6659
4
- data.tar.gz: '0759cfde4ef6ed2361b909c6f765a9cec2579a14'
2
+ SHA256:
3
+ metadata.gz: a315464f308426c87063f971108b2861cc7f6beacf9320fdf16af17bed73fc16
4
+ data.tar.gz: 70cd96e4f9ea7a463f73ae83990e8cfda6519563bbcaec9b4942d1862d7613b8
5
5
  SHA512:
6
- metadata.gz: cad33578769c6b1e0d45dec91e9f4fd691eb32f36df440b82b41649ea723bf5906c3bc4fa0a5341920e17e2720857c94e6da1459ebe18df023a12c1fc28686f7
7
- data.tar.gz: c03a67601a4d2cd13154002460576ffe475049d00e5beadb84b49a7b9ba263c6806624aa847767473cf6caaa972d8d46c43edbddf2a7b4f3be55919e680237dc
6
+ metadata.gz: b9d9dba42336127f9cfc9269ab57ff0f7af9fac620fb735d0749cb40ecf76a96175e25bee9b2a55ef94fd4ba038d10ae0fa371c9b0b0d7ded6f09f4169bbcb93
7
+ data.tar.gz: 1991082152cbf1bfc5748a37e6108418313871ea5272e8ad42b33a2be4081174b282601deedd027f8187df2e513071ea80636423f77168fffe2d2f42dba82af2
@@ -0,0 +1,39 @@
1
+ Addresses: [ECI-XXXX](https://dripcom.atlassian.net/browse/ECI-XXXX)
2
+
3
+ plus links to any other relevant tickets, PRs, JIRAs, wikis, e.g.:
4
+
5
+ Followup to: https://github.com/DripEmail/drip-ruby/12437
6
+
7
+ Also any pair partners that worked on this code:
8
+
9
+ Co-authored-by: Jesse Developer <jesse.developer@drip.com>
10
+
11
+ ## Background
12
+
13
+ Explain the context and why you're making that change. What is the
14
+ problem you're trying to solve? In some cases there is not a problem
15
+ and this can be thought of being the motivation for your change.
16
+
17
+ ## Modification
18
+
19
+ Describe the modifications you've done.
20
+
21
+ ## Result
22
+
23
+ What will change as a result of your pull request? Note that sometimes
24
+ this section is unnecessary because it is self-explanatory based on
25
+ the solution.
26
+
27
+ ## Additional Context
28
+
29
+ Does the PR title contain the JIRA key if using JIRA?
30
+
31
+ ## How to verify/test
32
+
33
+ Aside from automated tests that should be part of every PR,
34
+ what are the steps necessary to independently confirm that the PR
35
+ is correct in staging or production? Describe here the steps did you do
36
+ to manually smoke test or verify the functionality from the point of
37
+ view of a non-developer.
38
+
39
+ This section may not apply to all PRs.
data/.rubocop.yml CHANGED
@@ -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
 
@@ -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 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,17 +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
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: 23
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: 45
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: 10
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: 605
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
@@ -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
data/CHANGELOG.md CHANGED
@@ -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.2.0...HEAD
9
+ [master]: https://github.com/DripEmail/drip-ruby/compare/v3.4.2...HEAD
10
10
 
11
11
  - Your contribution here!
12
12
 
13
+ ## [3.4.2] - 2021-04-25
14
+
15
+ [3.4.2]: https://github.com/DripEmail/drip-ruby/compare/v3.4.1...v3.4.2
16
+
17
+ ### Changed
18
+ - `Drip::Client#create_or_update_subscriber` can be used with a BigCommerce Subscriber ID as the required key
19
+
20
+ ## [3.4.1] - 2020-04-21
21
+
22
+ [3.4.1]: https://github.com/DripEmail/drip-ruby/compare/v3.4.0...v3.4.1
23
+
24
+ ### Fixed
25
+ - Support for Ruby 2.7 hash parameters.
26
+
27
+ ## [3.4.0] - 2020-04-21
28
+
29
+ [3.4.0]: https://github.com/DripEmail/drip-ruby/compare/v3.3.1...v3.4.0
30
+
31
+ ### Added
32
+ - Support for the user endpoint in the REST API
33
+
34
+ ### Changed
35
+ - `Drip::Client#create_cart_activity_event` can be used with visitor UUID
36
+
37
+ ## [3.3.1] - 2019-05-28
38
+
39
+ [3.3.1]: https://github.com/DripEmail/drip-ruby/compare/v3.3.0...v3.3.1
40
+
41
+ ### Fixed
42
+ - Correct shopper activity batch orders API to wrap things in an `orders` key.
43
+
44
+ ## [3.3.0] - 2019-05-24
45
+
46
+ [3.3.0]: https://github.com/DripEmail/drip-ruby/compare/v3.2.0...v3.3.0
47
+
48
+ ### Added
49
+ - Support for the cart, order, and product endpoints in the shopper activity API.
50
+
51
+ ### Changed
52
+ - `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.
53
+ - `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.
54
+ - `Drip::Client#generate_resource` is deprecated and will be removed in a future version.
55
+ - `Drip::Client#content_type` is deprecated and will be removed in a future version. It is no longer used internally, effective immediately.
56
+ - When using the block form of parameter initialization, a configuration object is provided instead of the client itself.
57
+ - Calling configuration setters on `Drip::Client` is deprecated.
58
+ - `Drip::Client::REDIRECT_LIMIT` constant is now private. This is supposed to be an implementation detail and shouldn't leak.
59
+
60
+ ### Removed
61
+ - Drop support for Ruby 2.1.
62
+
13
63
  ## [3.2.0] - 2018-08-15
14
64
 
15
65
  [3.2.0]: https://github.com/DripEmail/drip-ruby/compare/v3.1.1...v3.2.0
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
 
data/drip-ruby.gemspec CHANGED
@@ -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
data/lib/drip.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "drip/version"
2
4
  require "drip/client"
data/lib/drip/client.rb CHANGED
@@ -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