class Admitad::Wrapper

Attributes

client[R]
token[R]

Public Class Methods

new() click to toggle source
# File lib/admitad/wrapper.rb, line 15
def initialize
  create_token
end

Private Instance Methods

create_client() click to toggle source
# File lib/admitad/wrapper.rb, line 27
def create_client
  @client = Client.new(token.try(:access_token))
end
create_token() click to toggle source
# File lib/admitad/wrapper.rb, line 31
def create_token
  @token = Token.create(Client.new.token(grant_type: :client_credentials))
  create_client
end
refresh_token() click to toggle source
# File lib/admitad/wrapper.rb, line 36
def refresh_token
  @token = Token.create(client.token(grant_type: :refresh_token, refresh_token: token.refresh_token))
  create_client
end
verifying_token() { || ... } click to toggle source
# File lib/admitad/wrapper.rb, line 19
def verifying_token
  return token.attributes.stringify_keys if token.error?
  return yield unless token.expired?

  refresh_token
  verifying_token { yield }
end