Class: FriendlyShipping::AccessToken

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/access_token.rb

Overview

Represents an access token returned by a carrier.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expires_in:, raw_token:) ⇒ AccessToken

Returns a new instance of AccessToken.

Parameters:

  • expires_in (Integer)

    the token's expiration



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_inInteger (readonly)

Returns the token's expiration.

Returns:

  • (Integer)

    the token's expiration



7
8
9
# File 'lib/friendly_shipping/access_token.rb', line 7

def expires_in
  @expires_in
end

#raw_tokenString (readonly)

Returns the raw token.

Returns:

  • (String)

    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_tokenArray<Hash>

Decodes and returns the raw token (only applicable to JWT tokens).

Returns:

  • (Array<Hash>)

    the decoded token



20
21
22
# File 'lib/friendly_shipping/access_token.rb', line 20

def decoded_token
  @_decoded_token = JWT.decode(raw_token, nil, false)
end