easypost 4.1.1 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/VERSION +1 -1
- data/lib/easypost/connection.rb +11 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b2de1c12852ffd59083d6ee132f2071577e7ff774f77cb515b444f75eaf86fc
|
4
|
+
data.tar.gz: 98b1d4bce4a86d9cdf3480f91e818dc362af2963e38f9bccb434b557aebf6bcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97fceef78d0d5706cd0ddb553f6da95ad5a27fe2491069f2eb416dafcb296a158d6e03bab6232ef0efe63f7503a256830635847288e99f17129920adade55eae
|
7
|
+
data.tar.gz: 2d3a0058d85435a3b743ef9f1b3f21e42bd77bf5cf830f5522794369f27315a9ca673f65fb9f3900df718668d2207ed63c295b7f36f415979cd53dae8cfe0110
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v4.1.2 (2022-03-16)
|
4
|
+
|
5
|
+
- Rolls back the original connection behavior of establishing a new connection for every request (restores previous expectations for multithreaded implementations)
|
6
|
+
|
3
7
|
## v4.1.1 (2022-03-14)
|
4
8
|
|
5
9
|
- Fixes a bug that prematurely closed connections when using multithreading by wrapping requests in a mutex (closes #148)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.1.
|
1
|
+
4.1.2
|
data/lib/easypost/connection.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
EasyPost::Connection = Struct.new(:uri, :config, keyword_init: true) do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
# Make an HTTP request with Ruby's {Net::HTTP}
|
5
|
+
#
|
6
|
+
# @param method [Symbol] the HTTP Verb (get, method, put, post, etc.)
|
7
|
+
# @param path [String] URI path of the resource
|
8
|
+
# @param requested_api_key [String] ({EasyPost.api_key}) key set Authorization header.
|
9
|
+
# @param body [String] (nil) body of the request
|
10
|
+
# @raise [EasyPost::Error] if the response has a non-2xx status code
|
11
|
+
# @return [Hash] JSON object parsed from the response body
|
12
|
+
def call(method, path, api_key = nil, body = nil)
|
13
|
+
connection =
|
11
14
|
if config[:proxy]
|
12
15
|
proxy_uri = URI(config[:proxy])
|
13
16
|
Net::HTTP.new(
|
@@ -40,24 +43,14 @@ EasyPost::Connection = Struct.new(:uri, :config, keyword_init: true) do
|
|
40
43
|
|
41
44
|
connection.public_send("#{name}=", value)
|
42
45
|
end
|
43
|
-
end
|
44
46
|
|
45
|
-
# Make an HTTP request with Ruby's {Net::HTTP}
|
46
|
-
#
|
47
|
-
# @param method [Symbol] the HTTP Verb (get, method, put, post, etc.)
|
48
|
-
# @param path [String] URI path of the resource
|
49
|
-
# @param requested_api_key [String] ({EasyPost.api_key}) key set Authorization header.
|
50
|
-
# @param body [String] (nil) body of the request
|
51
|
-
# @raise [EasyPost::Error] if the response has a non-2xx status code
|
52
|
-
# @return [Hash] JSON object parsed from the response body
|
53
|
-
def call(method, path, api_key = nil, body = nil)
|
54
47
|
request = Net::HTTP.const_get(method.capitalize).new(path)
|
55
48
|
request.body = JSON.dump(EasyPost::Util.objects_to_ids(body)) if body
|
56
49
|
|
57
50
|
EasyPost.default_headers.each_pair { |h, v| request[h] = v }
|
58
51
|
request['Authorization'] = EasyPost.authorization(api_key) if api_key
|
59
52
|
|
60
|
-
response =
|
53
|
+
response = connection.request(request)
|
61
54
|
|
62
55
|
EasyPost.parse_response(
|
63
56
|
status: response.code.to_i,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easypost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- EasyPost Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|