Class: FriendlyShipping::Services::USPSShip::AccessToken
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::USPSShip::AccessToken
- Defined in:
- lib/friendly_shipping/services/usps_ship/access_token.rb
Overview
Represents an access token returned by USPS Ship. The access token can be used to make API requests. Once it expires, a new token must be created.
Instance Attribute Summary collapse
-
#expires_in ⇒ Integer
readonly
The token's expiration.
-
#raw_token ⇒ String
readonly
The raw JWT token.
-
#token_type ⇒ String
readonly
The token's type.
Instance Method Summary collapse
-
#decoded_token ⇒ Array<Hash>
Decodes and returns the raw JWT token.
-
#initialize(token_type:, expires_in:, raw_token:) ⇒ AccessToken
constructor
A new instance of AccessToken.
Constructor Details
#initialize(token_type:, expires_in:, raw_token:) ⇒ AccessToken
Returns a new instance of AccessToken.
23 24 25 26 27 |
# File 'lib/friendly_shipping/services/usps_ship/access_token.rb', line 23 def initialize(token_type:, expires_in:, raw_token:) @token_type = token_type @expires_in = expires_in @raw_token = raw_token end |
Instance Attribute Details
#expires_in ⇒ Integer (readonly)
Returns the token's expiration.
15 16 17 |
# File 'lib/friendly_shipping/services/usps_ship/access_token.rb', line 15 def expires_in @expires_in end |
#raw_token ⇒ String (readonly)
Returns the raw JWT token.
18 19 20 |
# File 'lib/friendly_shipping/services/usps_ship/access_token.rb', line 18 def raw_token @raw_token end |
#token_type ⇒ String (readonly)
Returns the token's type.
12 13 14 |
# File 'lib/friendly_shipping/services/usps_ship/access_token.rb', line 12 def token_type @token_type end |
Instance Method Details
#decoded_token ⇒ Array<Hash>
Decodes and returns the raw JWT token.
31 32 33 |
# File 'lib/friendly_shipping/services/usps_ship/access_token.rb', line 31 def decoded_token @_decoded_token = JWT.decode(raw_token, nil, false) end |