Sha256: f8874b5aa93bfb2ff05c1c3cb301664fa82f5d7f1becdec86081f8b70f00782c

Contents?: true

Size: 657 Bytes

Versions: 2

Compression:

Stored size: 657 Bytes

Contents

# frozen_string_literal: true

module FriendlyShipping
  # Represents an access token returned by a carrier.
  class AccessToken
    # @return [Integer] the token's expiration
    attr_reader :expires_in

    # @return [String] the raw token
    attr_reader :raw_token

    # @param expires_in [Integer] the token's expiration
    def initialize(expires_in:, raw_token:)
      @expires_in = expires_in
      @raw_token = raw_token
    end

    # Decodes and returns the raw token (only applicable to JWT tokens).
    # @return [Array<Hash>] the decoded token
    def decoded_token
      @_decoded_token = JWT.decode(raw_token, nil, false)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
friendly_shipping-0.10.1 lib/friendly_shipping/access_token.rb
friendly_shipping-0.10.0 lib/friendly_shipping/access_token.rb