Class: Levelup::Endpoints::AccessTokens
- Defined in:
- lib/levelup/endpoints/access_tokens.rb
Overview
The endpoint holding all functions related to the management of access tokens.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
writeonly
The API key assigned to your app.
-
#secret ⇒ Object
writeonly
The client secret assigned to your app.
Instance Method Summary collapse
-
#create_for_app(app_auth_request = nil) ⇒ Object
Generates a new app access token.
-
#create_for_merchant(merchant_auth_request) ⇒ Object
Generates a new merchant access token.
-
#initialize(api_key: nil, secret: nil) ⇒ AccessTokens
constructor
A new instance of AccessTokens.
Constructor Details
#initialize(api_key: nil, secret: nil) ⇒ AccessTokens
Returns a new instance of AccessTokens.
11 12 13 14 |
# File 'lib/levelup/endpoints/access_tokens.rb', line 11 def initialize(api_key: nil, secret: nil) @api_key = api_key @secret = secret end |
Instance Attribute Details
#api_key=(value) ⇒ Object (writeonly)
The API key assigned to your app. Preconfigured key.
7 8 9 |
# File 'lib/levelup/endpoints/access_tokens.rb', line 7 def api_key=(value) @api_key = value end |
#secret=(value) ⇒ Object (writeonly)
The client secret assigned to your app. Preconfigured key.
9 10 11 |
# File 'lib/levelup/endpoints/access_tokens.rb', line 9 def secret=(value) @secret = value end |
Instance Method Details
#create_for_app(app_auth_request = nil) ⇒ Object
Generates a new app access token. If passed no parameters, attempts to pass the preconfigured API key and client secret to the endpoint.
18 19 20 21 22 23 24 |
# File 'lib/levelup/endpoints/access_tokens.rb', line 18 def create_for_app(app_auth_request = nil) request = build_request(app_auth_request || { api_key: @api_key, client_secret: @secret }, Requests::AuthenticateApp) request.send_to_api(:post, endpoint_path) end |
#create_for_merchant(merchant_auth_request) ⇒ Object
Generates a new merchant access token.
27 28 29 30 31 |
# File 'lib/levelup/endpoints/access_tokens.rb', line 27 def create_for_merchant(merchant_auth_request) request = build_request(merchant_auth_request, Requests::AuthenticateMerchant) request.send_to_api(:post, endpoint_path(:v14)) end |