Class: Koho::Client
- Inherits:
-
Object
show all
- Includes:
- HTTParty
- Defined in:
- lib/koho.rb
Defined Under Namespace
Classes: Contracts, Customers, InboundInvoices, InvoiceTerms, Invoices
Constant Summary
collapse
- API_BASE_URL =
'https://dev.koho-online.com/api'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(company_id, token) ⇒ Client
Returns a new instance of Client.
16
17
18
19
|
# File 'lib/koho.rb', line 16
def initialize company_id, token
@company_id = company_id
@token = token
end
|
Instance Attribute Details
#company_id ⇒ Object
Returns the value of attribute company_id.
13
14
15
|
# File 'lib/koho.rb', line 13
def company_id
@company_id
end
|
#token ⇒ Object
Returns the value of attribute token.
13
14
15
|
# File 'lib/koho.rb', line 13
def token
@token
end
|
Instance Method Details
#contracts ⇒ Object
41
|
# File 'lib/koho.rb', line 41
def contracts; Contracts.new company_id, token; end
|
#customers ⇒ Object
37
|
# File 'lib/koho.rb', line 37
def customers; Customers.new company_id, token; end
|
#delete(action) ⇒ Object
33
34
35
|
# File 'lib/koho.rb', line 33
def delete action
JSON.parse(self.class.delete action, {method: '_DELETE', body: {company_id: @company_id, token: @token}})
end
|
#get(action, data = {}) ⇒ Object
21
22
23
|
# File 'lib/koho.rb', line 21
def get action, data = {}
JSON.parse(self.class.get action, query: data.merge(company_id: @company_id, token: @token))
end
|
#inbound_invoices ⇒ Object
39
|
# File 'lib/koho.rb', line 39
def inbound_invoices; InboundInvoices.new company_id, token; end
|
#info ⇒ Object
45
46
47
|
# File 'lib/koho.rb', line 45
def info
get '/info'
end
|
#invoice_terms ⇒ Object
40
|
# File 'lib/koho.rb', line 40
def invoice_terms; InvoiceTerms.new company_id, token; end
|
#invoices ⇒ Object
38
|
# File 'lib/koho.rb', line 38
def invoices; Invoices.new company_id, token; end
|
#post(action, data = {}) ⇒ Object
25
26
27
|
# File 'lib/koho.rb', line 25
def post action, data = {}
JSON.parse(self.class.post action, {method: '_POST', body: {company_id: @company_id, token: @token}.merge(data)})
end
|
#put(action, data = {}) ⇒ Object
29
30
31
|
# File 'lib/koho.rb', line 29
def put action, data = {}
JSON.parse(self.class.put action, {method: '_PUT', body: {company_id: @company_id, token: @token}.merge(data)})
end
|