usps-imis-api 0.9.10.pre.1 → 0.9.10

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: b481e216a4b7c245599a7086834c243178c30aeb2d1891370150e466b5f8ba25
4
- data.tar.gz: cb1b01a149cbe94dac703a2be902a52a1810da7326d06410b159195f5f0bb69b
3
+ metadata.gz: e7d8f711e189075d39920c42cda5cb43f933fc650afc397e40fe7ada92834fa3
4
+ data.tar.gz: '09a9947903c7906987847a46c658778a8a75932de481d944ec172a1da4733578'
5
5
  SHA512:
6
- metadata.gz: 51d505d17d527c20112d7a5b81932bf8e28949a5515ab6ae1c6660687dd2d56227aa4b8d4883111b5724bf24e2f49efe6b37322dd0c627f66587a935b8b6f13b
7
- data.tar.gz: 9878ebd3710155ee8ea752337155d8f88eec75a07d228fc2d2462da8bbd57e2e8e44a80f6fc94965c1cc33435bd0efc585d79db5ee96c26c04d250a236bad83c
6
+ metadata.gz: 8360979d32674bb26403207fa4e539a97c925f32c9dd4dbfe8a43c57614f3383f1de1b5cc184c26f5552acb4de158faf232524836dc1cf71ac2e106d492c5233
7
+ data.tar.gz: cb50db92b18b3f182f563f0718a42f1943e173ee46802e9a66251890b0cc59c1c154a497cac643ce7e3553d0d64540e359c1e4c7b56d309465512db7aedba5e4
data/lib/usps/imis/api.rb CHANGED
@@ -39,7 +39,6 @@ module Usps
39
39
  # @param imis_id [Integer, String] iMIS ID to select immediately on initialization
40
40
  #
41
41
  def initialize(imis_id: nil)
42
- authenticate
43
42
  self.imis_id = imis_id if imis_id
44
43
  end
45
44
 
@@ -169,7 +168,7 @@ module Usps
169
168
  json = JSON.parse(result.body)
170
169
 
171
170
  @token = json['access_token']
172
- @token_expiration = Time.parse(json['.expires'])
171
+ @token_expiration = Time.now - json['expires_in'] - 60
173
172
  end
174
173
 
175
174
  # URI for the authentication endpoint
@@ -30,7 +30,7 @@ module Usps
30
30
  # If the current token is missing/expired, request a new one
31
31
  #
32
32
  def authorize(request)
33
- if token_expiration < Time.now
33
+ if token_expiration.nil? || token_expiration < Time.now
34
34
  logger.debug 'Token expired: re-authenticating with iMIS'
35
35
  authenticate
36
36
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.9.10-1'
5
+ VERSION = '0.9.10'
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.9.10.pre.1
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander