Class: FriendlyShipping::AccessToken
- Inherits:
-
Object
- Object
- FriendlyShipping::AccessToken
- Defined in:
- lib/friendly_shipping/access_token.rb
Overview
Represents an access token returned by a carrier.
Direct Known Subclasses
Services::TForceFreight::AccessToken, Services::USPSShip::AccessToken, Services::UpsJson::AccessToken
Instance Attribute Summary collapse
-
#expires_in ⇒ Integer
readonly
The token's expiration.
-
#raw_token ⇒ String
readonly
The raw token.
Instance Method Summary collapse
-
#decoded_token ⇒ Array<Hash>
Decodes and returns the raw token (only applicable to JWT tokens).
-
#initialize(expires_in:, raw_token:) ⇒ AccessToken
constructor
A new instance of AccessToken.
Constructor Details
#initialize(expires_in:, raw_token:) ⇒ AccessToken
Returns a new instance of AccessToken.
13 14 15 16 |
# File 'lib/friendly_shipping/access_token.rb', line 13 def initialize(expires_in:, raw_token:) @expires_in = expires_in @raw_token = raw_token end |
Instance Attribute Details
#expires_in ⇒ Integer (readonly)
Returns the token's expiration.
7 8 9 |
# File 'lib/friendly_shipping/access_token.rb', line 7 def expires_in @expires_in end |
#raw_token ⇒ String (readonly)
Returns the raw token.
10 11 12 |
# File 'lib/friendly_shipping/access_token.rb', line 10 def raw_token @raw_token end |
Instance Method Details
#decoded_token ⇒ Array<Hash>
Decodes and returns the raw token (only applicable to JWT tokens).
20 21 22 |
# File 'lib/friendly_shipping/access_token.rb', line 20 def decoded_token @_decoded_token = JWT.decode(raw_token, nil, false) end |