Class: Peddler::LWA
- Inherits:
-
Object
- Object
- Peddler::LWA
- Defined in:
- lib/peddler/lwa.rb,
sig/peddler/lwa.rbs
Overview
Requests Login with Amazon (LWA) access tokens for SP-API authorization
Constant Summary collapse
- URL =
"https://api.amazon.com/auth/o2/token"
Instance Attribute Summary collapse
-
#client_id ⇒ String?
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ String?
readonly
Returns the value of attribute client_secret.
-
#options ⇒ Hash[Symbol, untyped]
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#grant_type ⇒ String?
-
#initialize(client_id: ENV["LWA_CLIENT_ID"], client_secret: ENV["LWA_CLIENT_SECRET"], **options) ⇒ LWA
constructor
A new instance of LWA.
-
#params ⇒ Hash[Symbol, untyped]
-
#request ⇒ Response
Constructor Details
#initialize(client_id: ENV["LWA_CLIENT_ID"], client_secret: ENV["LWA_CLIENT_SECRET"], **options) ⇒ LWA
Returns a new instance of LWA.
25 26 27 28 29 |
# File 'lib/peddler/lwa.rb', line 25 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 ⇒ String? (readonly)
Returns the value of attribute client_id.
17 18 19 |
# File 'lib/peddler/lwa.rb', line 17 def client_id @client_id end |
#client_secret ⇒ String? (readonly)
Returns the value of attribute client_secret.
17 18 19 |
# File 'lib/peddler/lwa.rb', line 17 def client_secret @client_secret end |
#options ⇒ Hash[Symbol, untyped] (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/peddler/lwa.rb', line 17 def @options end |
Class Method Details
.request ⇒ Response
20 21 22 |
# File 'lib/peddler/lwa.rb', line 20 def request(...) new(...).request end |
Instance Method Details
#grant_type ⇒ String?
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/peddler/lwa.rb', line 36 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 |
#params ⇒ Hash[Symbol, untyped]
50 51 52 53 54 55 56 |
# File 'lib/peddler/lwa.rb', line 50 def params { grant_type: grant_type, client_id: client_id, client_secret: client_secret, }.compact.merge() end |