Class: FreshBooks::TokenClient

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/freshbooks.rb

Overview

Basic Auth client. uses an account’s API token.

Instance Method Summary collapse

Methods included from Client

#api_url, build_xml, #method_missing, new, #post, post, xml_body

Constructor Details

#initialize(domain, api_token) ⇒ TokenClient

Returns a new instance of TokenClient.



164
165
166
167
168
# File 'lib/freshbooks.rb', line 164

def initialize(domain, api_token)
  @domain = domain
  @username = api_token
  @password = 'X'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FreshBooks::Client

Instance Method Details

#authObject



170
171
172
173
174
# File 'lib/freshbooks.rb', line 170

def auth
  { 'Authorization' =>
    # taken from lib/net/http.rb
    'Basic ' + ["#{@username}:#{@password}"].pack('m').delete("\r\n") }
end