Class: Koho::Client
- Inherits:
-
Object
show all
- Includes:
- HTTParty
- Defined in:
- lib/koho.rb
Defined Under Namespace
Classes: Contracts, Customers, InboundInvoices, InvoiceTerms, Invoices, ProjectTasks, Projects, WorkSessions
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.
23
24
25
26
|
# File 'lib/koho.rb', line 23
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.
20
21
22
|
# File 'lib/koho.rb', line 20
def company_id
@company_id
end
|
#token ⇒ Object
Returns the value of attribute token.
20
21
22
|
# File 'lib/koho.rb', line 20
def token
@token
end
|
Instance Method Details
#contracts ⇒ Object
48
|
# File 'lib/koho.rb', line 48
def contracts; Contracts.new company_id, token; end
|
#customers ⇒ Object
44
|
# File 'lib/koho.rb', line 44
def customers; Customers.new company_id, token; end
|
#delete(action) ⇒ Object
40
41
42
|
# File 'lib/koho.rb', line 40
def delete action
JSON.parse(self.class.delete action, {method: '_DELETE', body: {company_id: @company_id, token: @token}})
end
|
#get(action, data = {}) ⇒ Object
28
29
30
|
# File 'lib/koho.rb', line 28
def get action, data = {}
JSON.parse(self.class.get action, query: data.merge(company_id: @company_id, token: @token))
end
|
#inbound_invoices ⇒ Object
46
|
# File 'lib/koho.rb', line 46
def inbound_invoices; InboundInvoices.new company_id, token; end
|
#info ⇒ Object
55
56
57
|
# File 'lib/koho.rb', line 55
def info
get '/info'
end
|
#invoice_terms ⇒ Object
47
|
# File 'lib/koho.rb', line 47
def invoice_terms; InvoiceTerms.new company_id, token; end
|
#invoices ⇒ Object
45
|
# File 'lib/koho.rb', line 45
def invoices; Invoices.new company_id, token; end
|
#post(action, data = {}) ⇒ Object
32
33
34
|
# File 'lib/koho.rb', line 32
def post action, data = {}
JSON.parse(self.class.post action, {method: '_POST', body: {company_id: @company_id, token: @token}.merge(data)})
end
|
#project_tasks ⇒ Object
50
|
# File 'lib/koho.rb', line 50
def project_tasks; ProjectTasks.new company_id, token; end
|
#projects ⇒ Object
49
|
# File 'lib/koho.rb', line 49
def projects; Projects.new company_id, token; end
|
#put(action, data = {}) ⇒ Object
36
37
38
|
# File 'lib/koho.rb', line 36
def put action, data = {}
JSON.parse(self.class.put action, {method: '_PUT', body: {company_id: @company_id, token: @token}.merge(data)})
end
|
#work_sessions ⇒ Object
51
|
# File 'lib/koho.rb', line 51
def work_sessions; WorkSessions.new company_id, token; end
|