Module: Justifi::OAuth

Defined in:
lib/justifi/oauth.rb

Defined Under Namespace

Modules: OAuthOperations

Class Method Summary collapse

Class Method Details

.get_token(params = {}, headers = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/justifi/oauth.rb', line 15

def get_token(params = {}, headers = {})
  token = Justifi.cache.get(:access_token)
  return token unless token.nil?

  response = OAuthOperations.execute_post_request(
    "/oauth/token", params, headers
  )

  Justifi.cache.set_and_return(:access_token, response.access_token)
end

.get_web_component_token(resources:) ⇒ Object



26
27
28
29
# File 'lib/justifi/oauth.rb', line 26

def get_web_component_token(resources:)
  params = {resources: resources}
  JustifiOperations.execute_post_request("/v1/web_component_tokens", params, {})
end