Class: FriendlyShipping::Services::TForceFreight::AccessToken
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::TForceFreight::AccessToken
- Defined in:
- lib/friendly_shipping/services/tforce_freight/access_token.rb
Overview
Represents an access token returned by TForce Freight. 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.
-
#ext_expires_in ⇒ Integer
readonly
The token's extended 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:, ext_expires_in:, raw_token:) ⇒ AccessToken
constructor
A new instance of AccessToken.
Constructor Details
#initialize(token_type:, expires_in:, ext_expires_in:, raw_token:) ⇒ AccessToken
Returns a new instance of AccessToken.
28 29 30 31 32 33 |
# File 'lib/friendly_shipping/services/tforce_freight/access_token.rb', line 28 def initialize(token_type:, expires_in:, ext_expires_in:, raw_token:) @token_type = token_type @expires_in = expires_in @ext_expires_in = ext_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/tforce_freight/access_token.rb', line 15 def expires_in @expires_in end |
#ext_expires_in ⇒ Integer (readonly)
Returns the token's extended expiration.
18 19 20 |
# File 'lib/friendly_shipping/services/tforce_freight/access_token.rb', line 18 def ext_expires_in @ext_expires_in end |
#raw_token ⇒ String (readonly)
Returns the raw JWT token.
21 22 23 |
# File 'lib/friendly_shipping/services/tforce_freight/access_token.rb', line 21 def raw_token @raw_token end |
#token_type ⇒ String (readonly)
Returns the token's type.
12 13 14 |
# File 'lib/friendly_shipping/services/tforce_freight/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.
37 38 39 |
# File 'lib/friendly_shipping/services/tforce_freight/access_token.rb', line 37 def decoded_token @_decoded_token = JWT.decode(raw_token, nil, false) end |