Class: KeyPayAPI::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Business, Connection, Employee
Defined in:
lib/keypay_api/client.rb,
lib/keypay_api/client/business.rb,
lib/keypay_api/client/employee.rb,
lib/keypay_api/client/connection.rb

Defined Under Namespace

Modules: Business, Connection, Employee

Instance Method Summary collapse

Methods included from Business

#list_businesses

Methods included from Employee

#create_employee, #get_employee, #get_employee_external_id, #list_employees, #onboard_employee

Methods included from Connection

#delete, #get, #post, #put

Constructor Details

#initialize(api_key = nil) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
# File 'lib/keypay_api/client.rb', line 17

def initialize(api_key = nil)
  api_key ||= ENV["KEYPAY_API_KEY"]
  raise KeyPayAPI::Error('Must pass an API key') if api_key.nil?
  enc_key = Base64.encode64(api_key + ':').gsub(/\n/,'')
  self.class.default_options.merge!(headers: {'Authorization': "Basic #{enc_key}", 'Content-Type': 'application/json'})
end