Class: FriendlyShipping::Services::UpsJson::AccessToken

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

Overview

Represents an access token returned by UPS. The access token can be used to make API requests. Once it expires, a new token must be created.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expires_in:, issued_at:, raw_token:) ⇒ AccessToken

Returns a new instance of AccessToken.

Parameters:

  • expires_in (Integer)

    the token's expiration

  • issued_at (Integer)

    the time the token was issued at

  • raw_token (String)

    the raw JWT token



21
22
23
24
25
# File 'lib/friendly_shipping/services/ups_json/access_token.rb', line 21

def initialize(expires_in:, issued_at:, raw_token:)
  @expires_in = expires_in
  @issued_at = issued_at
  @raw_token = raw_token
end

Instance Attribute Details

#expires_inInteger (readonly)

Returns the token's expiration.

Returns:

  • (Integer)

    the token's expiration



10
11
12
# File 'lib/friendly_shipping/services/ups_json/access_token.rb', line 10

def expires_in
  @expires_in
end

#issued_atInteger (readonly)

Returns the epoch time in ms when the token was issued.

Returns:

  • (Integer)

    the epoch time in ms when the token was issued



13
14
15
# File 'lib/friendly_shipping/services/ups_json/access_token.rb', line 13

def issued_at
  @issued_at
end

#raw_tokenString (readonly)

Returns the raw JWT token.

Returns:

  • (String)

    the raw JWT token



16
17
18
# File 'lib/friendly_shipping/services/ups_json/access_token.rb', line 16

def raw_token
  @raw_token
end