Class: Levelup::Endpoints::AccessTokens

Inherits:
Base
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(auth_info) ⇒ AccessTokens

Returns a new instance of AccessTokens.



10
11
12
13
# File 'lib/levelup/endpoints/access_tokens.rb', line 10

def initialize(auth_info)
  @api_key = auth_info[:api_key]
  @secret = auth_info[:secret]
end

Instance Attribute Details

#api_key=(value) ⇒ Object (writeonly)

The API key assigned to your app. Preconfigured key.



6
7
8
# File 'lib/levelup/endpoints/access_tokens.rb', line 6

def api_key=(value)
  @api_key = value
end

#secret=(value) ⇒ Object (writeonly)

The client secret assigned to your app. Preconfigured key.



8
9
10
# File 'lib/levelup/endpoints/access_tokens.rb', line 8

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.



17
18
19
20
21
# File 'lib/levelup/endpoints/access_tokens.rb', line 17

def create_for_app(app_auth_request = nil)
  build_request(app_auth_request || { api_key: @api_key, client_secret: @secret },
      Requests::AuthenticateApp).
    send_to_api(:post, endpoint_path)
end

#create_for_merchant(merchant_auth_request) ⇒ Object

Generates a new merchant access token.



24
25
26
27
28
# File 'lib/levelup/endpoints/access_tokens.rb', line 24

def create_for_merchant(merchant_auth_request)
  build_request(merchant_auth_request,
      Requests::AuthenticateMerchant).
    send_to_api(:post, endpoint_path(:v14))
end