Class: RestfulKashflow::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/restful_kashflow/client.rb

Overview

A class for working with and talking to the Kashflow API

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/restful_kashflow/client.rb', line 5

def initialize(options)
  username = options.delete(:username) || raise('No username given to Restful Kashflow Client')
  password = options.delete(:password) || raise('No password given to Restful Kashflow Client')
  memorable_word = options.delete(:memorable_word) || raise('No memorable word given to Restful Kashflow Client')
  environment = options.delete(:environment) || :live
  @customer = {}

  url = options.delete(:url) || url_for_environment(environment)

  @api_service = ApiService.new(username,
                                password,
                                memorable_word,
                                url,
                                options)
end

Instance Method Details

#customer(customer_id = nil) ⇒ Object



25
26
27
# File 'lib/restful_kashflow/client.rb', line 25

def customer(customer_id = nil)
  @customer[customer_id] ||= Services::Customer.new(@api_service, customer_id)
end

#statusObject



21
22
23
# File 'lib/restful_kashflow/client.rb', line 21

def status
  @api_service.status
end