drip-ruby 3.0.0 → 3.1.0
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/.travis.yml +4 -1
- data/CHANGELOG.md +10 -0
- data/README.md +0 -2
- data/lib/drip/client.rb +19 -4
- data/lib/drip/version.rb +1 -1
- data/test/drip/client_test.rb +35 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cde072743a9010ff142889179cd1c5cb57eb6009
|
4
|
+
data.tar.gz: 2c94bb250107e5412a1e85ca418845ce81242711
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 229a86bbc7153395d73659ea272c9d2467678bf812ca2c687903701969dfd55281eed4c0c45e7eebd536bd3755f5ac31c6312d4f92e13fadac985c9ec804880d
|
7
|
+
data.tar.gz: 6032350979b07376d2de554ac22675a77d8a56a20492431df760e5f02793ce6e4a164013daa76bb9bbe02f8e85b42415a5054a473fa68b8aac3722bd88f8f7e4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [3.1.0] - 2018-06-05
|
8
|
+
|
9
|
+
[3.1.0]: https://github.com/DripEmail/drip-ruby/compare/v3.0.0...v3.1.0
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- [#46](https://github.com/DripEmail/drip-ruby/pull/46): Fix verb class equality check - [@marcinbunsch](https://github.com/marcinbunsch)
|
13
|
+
|
14
|
+
### Added
|
15
|
+
- [#43](https://github.com/DripEmail/drip-ruby/pull/43): Additional timeout parameters for client - [@tboyko](https://github.com/tboyko)
|
16
|
+
|
7
17
|
## [3.0.0] - 2018-05-29
|
8
18
|
|
9
19
|
[3.0.0]: https://github.com/DripEmail/drip-ruby/compare/v2.0.0...v3.0.0
|
data/README.md
CHANGED
@@ -122,8 +122,6 @@ as methods on the client object. The following methods are currently available:
|
|
122
122
|
|
123
123
|
#### Orders
|
124
124
|
|
125
|
-
**Note:** The beta purchases endpoint has been deprecated and its methods have been removed from the gem except `create_purchase`, which now sends requests to the Order creation endpoint [here](https://developer.drip.com/#orders)
|
126
|
-
|
127
125
|
| Actions | Methods |
|
128
126
|
| :------------------------- | :--------------------------------------------------- |
|
129
127
|
| Create or update an order | `#create_or_update_order(email, options = {})` |
|
data/lib/drip/client.rb
CHANGED
@@ -37,13 +37,15 @@ module Drip
|
|
37
37
|
|
38
38
|
REDIRECT_LIMIT = 10
|
39
39
|
|
40
|
-
attr_accessor :access_token, :api_key, :account_id, :url_prefix
|
40
|
+
attr_accessor :access_token, :api_key, :account_id, :url_prefix, :http_open_timeout, :http_timeout
|
41
41
|
|
42
42
|
def initialize(options = {})
|
43
43
|
@account_id = options[:account_id]
|
44
44
|
@access_token = options[:access_token]
|
45
45
|
@api_key = options[:api_key]
|
46
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]
|
47
49
|
yield(self) if block_given?
|
48
50
|
end
|
49
51
|
|
@@ -81,14 +83,14 @@ module Drip
|
|
81
83
|
raise TooManyRedirectsError, 'too many HTTP redirects' if step >= REDIRECT_LIMIT
|
82
84
|
|
83
85
|
build_response do
|
84
|
-
Net::HTTP.start(uri.host, uri.port,
|
85
|
-
if verb_klass
|
86
|
+
Net::HTTP.start(uri.host, uri.port, connection_options(uri.scheme)) do |http|
|
87
|
+
if verb_klass == Net::HTTP::Get
|
86
88
|
uri.query = URI.encode_www_form(options)
|
87
89
|
end
|
88
90
|
|
89
91
|
request = verb_klass.new uri
|
90
92
|
|
91
|
-
unless verb_klass
|
93
|
+
unless verb_klass == Net::HTTP::Get
|
92
94
|
request.body = options.to_json
|
93
95
|
end
|
94
96
|
|
@@ -116,5 +118,18 @@ module Drip
|
|
116
118
|
response = yield
|
117
119
|
Drip::Response.new(response.code.to_i, response.body)
|
118
120
|
end
|
121
|
+
|
122
|
+
def connection_options(uri_scheme)
|
123
|
+
options = { use_ssl: uri_scheme == "https" }
|
124
|
+
|
125
|
+
if @http_open_timeout
|
126
|
+
options[:open_timeout] = @http_open_timeout
|
127
|
+
options[:ssl_timeout] = @http_open_timeout
|
128
|
+
end
|
129
|
+
|
130
|
+
options[:read_timeout] = @http_timeout if @http_timeout
|
131
|
+
|
132
|
+
options
|
133
|
+
end
|
119
134
|
end
|
120
135
|
end
|
data/lib/drip/version.rb
CHANGED
data/test/drip/client_test.rb
CHANGED
@@ -44,12 +44,16 @@ class Drip::ClientTest < Drip::TestCase
|
|
44
44
|
client = Drip::Client.new(
|
45
45
|
account_id: "1234567",
|
46
46
|
api_key: "aaaa",
|
47
|
-
access_token: "bbbb"
|
47
|
+
access_token: "bbbb",
|
48
|
+
http_open_timeout: 20,
|
49
|
+
http_timeout: 25
|
48
50
|
)
|
49
51
|
|
50
52
|
assert_equal "1234567", client.account_id
|
51
53
|
assert_equal "aaaa", client.api_key
|
52
54
|
assert_equal "bbbb", client.access_token
|
55
|
+
assert_equal 20, client.http_open_timeout
|
56
|
+
assert_equal 25, client.http_timeout
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
@@ -146,4 +150,34 @@ class Drip::ClientTest < Drip::TestCase
|
|
146
150
|
assert_requested :get, "https://api.example.com/mytestpath", times: 5
|
147
151
|
end
|
148
152
|
end
|
153
|
+
|
154
|
+
context "given a get request" do
|
155
|
+
setup do
|
156
|
+
@client = Drip::Client.new
|
157
|
+
@response = mock
|
158
|
+
@response.stubs(:code).returns('200')
|
159
|
+
@response.stubs(:body).returns('mybody')
|
160
|
+
|
161
|
+
@http = mock
|
162
|
+
@http.expects(:request).returns(@response)
|
163
|
+
|
164
|
+
@request = mock
|
165
|
+
@request.stubs(:[]=)
|
166
|
+
@request.stubs(:basic_auth)
|
167
|
+
end
|
168
|
+
|
169
|
+
should "encode query and not set body" do
|
170
|
+
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
171
|
+
to_return(status: 200, body: "mybody")
|
172
|
+
|
173
|
+
Net::HTTP::Get.expects(:new).returns(@request)
|
174
|
+
Net::HTTP.expects(:start).yields(@http).returns(@response)
|
175
|
+
|
176
|
+
@request.expects(:body=).never
|
177
|
+
URI.expects(:encode_www_form).once
|
178
|
+
|
179
|
+
response = @client.get("testpath")
|
180
|
+
assert_equal "mybody", response.body
|
181
|
+
end
|
182
|
+
end
|
149
183
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drip-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derrick Reimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05
|
11
|
+
date: 2018-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|