modulr-api 0.0.45 → 0.0.46
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/Gemfile.lock +1 -1
- data/lib/modulr/api/service.rb +0 -6
- data/lib/modulr/client.rb +12 -10
- data/lib/modulr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45f16a01e7450ae71621e53a850720a9679124c4bc22db243da24916eee09229
|
|
4
|
+
data.tar.gz: 1b67cded77fa55969e1024dfc676f06b5cd77cfd35153a801b9492c980f4e334
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a859137b06dd2fce7562b8e1f044991e9a53c0f529cb1390e182e5dab67eb30b68d3adec9f55b38d371458438287f64ed81c1b9b7522ee2412981b3e8c35d571
|
|
7
|
+
data.tar.gz: 3b4fe0303298bebe102ea330c4b183f937304bac3ed548e0b0743c704fd92dbf495747c8463dec193d4ae7adb64cf4d7739fb2d62c491962412d4855e1bc23f7
|
data/Gemfile.lock
CHANGED
data/lib/modulr/api/service.rb
CHANGED
|
@@ -9,12 +9,6 @@ module Modulr
|
|
|
9
9
|
@client = client
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def idempotency_headers(options)
|
|
13
|
-
headers = {}
|
|
14
|
-
headers[:idempotency_key] = options[:idempotency_key] if options[:idempotency_key]
|
|
15
|
-
headers
|
|
16
|
-
end
|
|
17
|
-
|
|
18
12
|
def format_datetime(datetime)
|
|
19
13
|
datetime.strftime("%Y-%m-%dT%H:%M:%S%z")
|
|
20
14
|
end
|
data/lib/modulr/client.rb
CHANGED
|
@@ -80,28 +80,30 @@ module Modulr
|
|
|
80
80
|
|
|
81
81
|
def request_options(method, _path, data, options)
|
|
82
82
|
default_options.tap do |defaults|
|
|
83
|
+
add_idempotency_headers!(defaults[:headers], method, options)
|
|
83
84
|
add_auth_options!(defaults)
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
defaults[:body] = JSON.dump(data) if data
|
|
86
87
|
end
|
|
87
88
|
end
|
|
88
89
|
|
|
89
90
|
def add_auth_options!(options)
|
|
90
|
-
return sandbox_auth_options(options) if @base_url.eql?(SANDBOX_URL)
|
|
91
|
+
return sandbox_auth_options(options[:headers]) if @base_url.eql?(SANDBOX_URL)
|
|
91
92
|
|
|
92
|
-
auth_options(options)
|
|
93
|
+
auth_options(options[:headers])
|
|
93
94
|
end
|
|
94
95
|
|
|
95
96
|
def sandbox_auth_options(options)
|
|
96
|
-
options[:
|
|
97
|
+
options[:authorization] = @apikey
|
|
97
98
|
end
|
|
98
99
|
|
|
99
100
|
def auth_options(options)
|
|
100
|
-
|
|
101
|
+
nonce = options["x-mod-nonce"]
|
|
102
|
+
signature = Auth::Signature.calculate(apikey: @apikey, apisecret: @apisecret, nonce: nonce)
|
|
101
103
|
|
|
102
|
-
options[:
|
|
103
|
-
options[:
|
|
104
|
-
options[
|
|
104
|
+
options[:authorization] = signature.authorization
|
|
105
|
+
options[:date] = signature.timestamp
|
|
106
|
+
options["x-mod-nonce"] = signature.nonce
|
|
105
107
|
end
|
|
106
108
|
|
|
107
109
|
private def add_idempotency_headers!(headers, method, options)
|
|
@@ -111,8 +113,8 @@ module Modulr
|
|
|
111
113
|
return unless idempotency_key
|
|
112
114
|
|
|
113
115
|
nonce = self.class.idempotency_nonce(idempotency_key)
|
|
114
|
-
headers[
|
|
115
|
-
headers[
|
|
116
|
+
headers["x-mod-nonce"] = nonce
|
|
117
|
+
headers["x-mod-retry"] = "true"
|
|
116
118
|
end
|
|
117
119
|
|
|
118
120
|
private def merge_query_params(request, method, options)
|
data/lib/modulr/version.rb
CHANGED