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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f531bd805420e145f1f729d5faf827043c115b8b147185729eaa8492dc237bd0
4
- data.tar.gz: 14797e32effc78a7d0e47a23a23bfbd3c9919919a9394006f615176352951719
3
+ metadata.gz: 45f16a01e7450ae71621e53a850720a9679124c4bc22db243da24916eee09229
4
+ data.tar.gz: 1b67cded77fa55969e1024dfc676f06b5cd77cfd35153a801b9492c980f4e334
5
5
  SHA512:
6
- metadata.gz: f737889019424e1da9559475eead0dabc1edb803da2989937debe45f6e23d07d24f14af2f0042934ad90d8d2419c6c993d4c5dd6106fae4f89b587742f2e9b13
7
- data.tar.gz: 169e133460c50193f8d732c070b67576159f9c1fe32e4b2e319120e86005b1c841e94a59a805b5d77cdd7675796846d84bc51dbe1e5ff3f330b3f55f2c832ce1
6
+ metadata.gz: a859137b06dd2fce7562b8e1f044991e9a53c0f529cb1390e182e5dab67eb30b68d3adec9f55b38d371458438287f64ed81c1b9b7522ee2412981b3e8c35d571
7
+ data.tar.gz: 3b4fe0303298bebe102ea330c4b183f937304bac3ed548e0b0743c704fd92dbf495747c8463dec193d4ae7adb64cf4d7739fb2d62c491962412d4855e1bc23f7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- modulr-api (0.0.45)
4
+ modulr-api (0.0.46)
5
5
  faraday (~> 1.0)
6
6
  faraday_middleware (~> 1.0)
7
7
 
@@ -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
- add_idempotency_headers!(defaults[:headers], method, options) if options
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[:headers][:authorization] = @apikey
97
+ options[:authorization] = @apikey
97
98
  end
98
99
 
99
100
  def auth_options(options)
100
- signature = Auth::Signature.calculate(apikey: @apikey, apisecret: @apisecret)
101
+ nonce = options["x-mod-nonce"]
102
+ signature = Auth::Signature.calculate(apikey: @apikey, apisecret: @apisecret, nonce: nonce)
101
103
 
102
- options[:headers][:authorization] = signature.authorization
103
- options[:headers][:date] = signature.timestamp
104
- options[:headers][:"x-mod-nonce"] ||= signature.nonce
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[:"x-mod-nonce"] = nonce
115
- headers[:"x-mod-retry"] = "true" if nonce && !nonce.empty?
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modulr
4
- VERSION = "0.0.45"
4
+ VERSION = "0.0.46"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulr-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.45
4
+ version: 0.0.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aitor García Rey