usps-imis-api 0.11.15 → 0.11.16

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: a832672e225e3d314dd72d58089ddb95650e261a6498281a31db365cbadf2c47
4
- data.tar.gz: edb5fd91281205f91e1b5891e7d6fff16cba99b6851cf53ec89e6c925e502612
3
+ metadata.gz: b6437192db35a0e8a3e80d44d338366c9460060dc7b13d8f53a17c0d0c7ed8b8
4
+ data.tar.gz: 4c4ad6121f1f282e3788e311e78be6d753b56c04f8112a3ac6a23c808e198ca2
5
5
  SHA512:
6
- metadata.gz: fb3943d61228582bdef6e516060e816682f48ee6552188d1306f003cee9eb973e1c2c26db1f7a8025e45d60d885512878e4bb5bfbe99a93f59ede12ad0fa4611
7
- data.tar.gz: ec25020f0a3c138c0f250b5aadfb3e4cdf254172ab430ac587196fe5764a2f8c12a20339dddac2856ad80dade2671aca2eb5f95761461b6fd4b421ca89df8914
6
+ metadata.gz: 5aa9c0cac48c98eb3826c107e9db3a471689c6e30cc3d7fbce138db24f0c01128440b4e1fcc8b46bd3e96bd002ce0f4ce2136e9d678b60023af5b66330e55ceb
7
+ data.tar.gz: 8fa27434be1d69626b27653189636c4daeb1739407752d24a977314c70ac09029ab624f618c007a78669f8f8d8875b8a63646cb22e894ad87cd62a5c3fbeae20
data/lib/usps/imis/api.rb CHANGED
@@ -76,11 +76,14 @@ module Usps
76
76
 
77
77
  # Run requests as DSL, with specific iMIS ID only maintained for this scope
78
78
  #
79
+ # Either +id+ or +certificate+ is required.
80
+ #
79
81
  # While in this block, changes to the value of +imis_id+ are not allowed
80
82
  #
81
83
  # If no block is given, this sets the iMIS ID and returns self.
82
84
  #
83
85
  # @param id [Integer, String] iMIS ID to select for requests within the block
86
+ # @param certificate [String] Certificate number to convert to iMIS ID and select for requests within the block
84
87
  #
85
88
  # @example
86
89
  # with(12345) do
@@ -89,9 +92,12 @@ module Usps
89
92
  #
90
93
  # @return [Usps::Imis::Api]
91
94
  #
92
- def with(id, &)
95
+ def with(id = nil, certificate: nil, &)
96
+ raise ArgumentError, 'Must provide id or certificate' unless id || certificate
97
+
93
98
  old_id = imis_id
94
- self.imis_id = id
99
+
100
+ id.nil? ? imis_id_for(certificate) : self.imis_id = id
95
101
  return self unless block_given?
96
102
 
97
103
  @lock_imis_id = true
@@ -202,7 +208,7 @@ module Usps
202
208
  json = JSON.parse(result.body)
203
209
 
204
210
  @token = json['access_token']
205
- @token_expiration = Time.now - json['expires_in'] - 60
211
+ @token_expiration = Time.now + json['expires_in'] - 60
206
212
  end
207
213
 
208
214
  # URI for the authentication endpoint
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.11.15'
5
+ VERSION = '0.11.16'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-imis-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.15
4
+ version: 0.11.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander