class GetAccept::Api

Attributes

client[R]

Public Class Methods

get_token(options = {}) click to toggle source
# File lib/get_accept/api.rb, line 7
def self.get_token(options = {})
  payload = {
              email: options[:email],
              password: options[:password],
              client: options[:client],
              entity_id: options[:entity_id],
            }
  HTTP.post("#{API_BASE}/auth", json: payload)
end
new(options = {}) click to toggle source
# File lib/get_accept/api.rb, line 18
def initialize(options = {})
  @token = options[:token]
  @client = HTTP.auth("Bearer #{@token}").headers('Content-Type' => 'application/json')
end

Public Instance Methods

method_missing(method, *args) click to toggle source
Calls superclass method
# File lib/get_accept/api.rb, line 35
def method_missing(method, *args)
  klass = method.to_s.split('_').collect(&:capitalize).join
  Object.const_get("GetAccept::#{klass}").new(@client)
rescue NameError
  super
end
open_url(url) click to toggle source
# File lib/get_accept/api.rb, line 31
def open_url url
  url = URI.encode("https://app.getaccept.com/auth/sso/login?token=#{@token}&go=#{url}")
end
refresh_token() click to toggle source
# File lib/get_accept/api.rb, line 23
def refresh_token
  client.get("#{API_BASE}/refresh",)
end
respond_to_missing?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/get_accept/api.rb, line 42
def respond_to_missing?(method, include_private = false)
  klass = method.to_s.capitalize
  Object.const_get("GetAccept::#{klass}")
  true
rescue NameError
  super
end
revoke_token() click to toggle source
# File lib/get_accept/api.rb, line 27
def revoke_token
  client.get("#{API_BASE}/revoke")
end