Class: PaypalAPI::AccessToken Private

Inherits:
Object
  • Object
show all
Defined in:
lib/paypal-api/access_token.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

AccessToken object stores authorization string and its expire time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(requested_at:, expires_in:, access_token:, token_type:) ⇒ AccessToken

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes AccessToken object

Parameters:

  • requested_at (Time)

    Time when token was requested

  • expires_in (Integer)

    Count of seconds until token expires

  • access_token (String)

    Aceess token string generated by PayPal

  • token_type (String)

    Aceess token type, which is constantly ‘Bearer`



32
33
34
35
36
37
# File 'lib/paypal-api/access_token.rb', line 32

def initialize(requested_at:, expires_in:, access_token:, token_type:)
  @requested_at = requested_at
  @expires_at = requested_at + expires_in
  @authorization_string = "#{token_type} #{access_token}"
  freeze
end

Instance Attribute Details

#authorization_stringString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Authorization string

Returns:

  • (String)

    Authorization string



20
21
22
# File 'lib/paypal-api/access_token.rb', line 20

def authorization_string
  @authorization_string
end

#expires_atTime (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Time when access token request expires

Returns:

  • (Time)

    Time



16
17
18
# File 'lib/paypal-api/access_token.rb', line 16

def expires_at
  @expires_at
end

#requested_atTime (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Time when access token request was sent

Returns:

  • (Time)

    Time



12
13
14
# File 'lib/paypal-api/access_token.rb', line 12

def requested_at
  @requested_at
end

Instance Method Details

#expired?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Shows if current AccessToken was expired

Returns:

  • (Boolean)


42
43
44
# File 'lib/paypal-api/access_token.rb', line 42

def expired?
  Time.now >= expires_at
end

#inspectString Also known as: to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Instance representation string

Returns:

  • (String)

    Inspect value



51
52
53
# File 'lib/paypal-api/access_token.rb', line 51

def inspect
  "#<#{self.class.name} methods: (requested_at, expires_at, expired?, authorization_string)>"
end