class FastTrack::Client

Public Class Methods

new(token, opts = {}) click to toggle source
# File lib/fasttrack-client.rb, line 9
def initialize(token, opts = {})
  @token = token
  @opts = opts
end

Public Instance Methods

get(path, params) click to toggle source

Request to the API endpoint

# File lib/fasttrack-client.rb, line 15
def get(path, params)
  begin
    headers = {
      'Authorization' => 'Token ' + @token,
      'Accept'        => ACCEPT + '; version = ' + VERSION.to_s,
      'params'        => params
    };

    url = 'https://api.fasttrack-intl.com' + path

    response = RestClient.get(url, headers)

    return JSON.parse(response.body)
  rescue RestClient::ExceptionWithResponse => e
    body = nil;
    response = e.response

    begin
      body = JSON.parse(response.body)
    rescue
      body = {}
    end

    exception = exception_for_response(response.code, body['error_code'])
    raise exception, body['detail']
  end
end
get_company(domain) click to toggle source

Retrieve company details with a `domain`

# File lib/fasttrack-client.rb, line 44
def get_company(domain)
  return self.get PATHNAME_COMPANY, {
    'domain' => domain
  }
end
get_contact(email) click to toggle source

Retrieve contact details with an `email`

# File lib/fasttrack-client.rb, line 51
def get_contact(email)
  return self.get PATHNAME_CONTACT, {
    'email' => email
  }
end