Class: Peddler::Token
- Inherits:
-
Object
- Object
- Peddler::Token
- Defined in:
- lib/peddler/token.rb
Overview
Requests refresh and access tokens that authorize your application to take actions on behalf of a selling partner.
The refresh token allows you to generate access tokens. Access tokens expire one hour after they are issued.
Constant Summary collapse
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #grant_type ⇒ Object
-
#initialize(client_id: ENV["LWA_CLIENT_ID"], client_secret: ENV["LWA_CLIENT_SECRET"], **options) ⇒ Token
constructor
A new instance of Token.
- #request ⇒ Object
Constructor Details
#initialize(client_id: ENV["LWA_CLIENT_ID"], client_secret: ENV["LWA_CLIENT_SECRET"], **options) ⇒ Token
Returns a new instance of Token.
26 27 28 29 30 |
# File 'lib/peddler/token.rb', line 26 def initialize(client_id: ENV["LWA_CLIENT_ID"], client_secret: ENV["LWA_CLIENT_SECRET"], **) @client_id = client_id @client_secret = client_secret @options = end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
18 19 20 |
# File 'lib/peddler/token.rb', line 18 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
18 19 20 |
# File 'lib/peddler/token.rb', line 18 def client_secret @client_secret end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/peddler/token.rb', line 18 def @options end |
Class Method Details
.request ⇒ Object
21 22 23 |
# File 'lib/peddler/token.rb', line 21 def request(...) new(...).request end |
Instance Method Details
#grant_type ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/peddler/token.rb', line 43 def grant_type if .key?(:grant_type) [:grant_type] elsif .key?(:refresh_token) "refresh_token" elsif .key?(:scope) "client_credentials" elsif .key?(:code) "authorization_code" end end |