Class: Koho::Client
- Inherits:
-
Object
show all
- Includes:
- HTTParty
- Defined in:
- lib/koho.rb
Defined Under Namespace
Classes: Contracts, Customers, 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
36
|
# File 'lib/koho.rb', line 36
def contracts; Contracts.new company_id, token; end
|
#customers ⇒ Object
34
|
# File 'lib/koho.rb', line 34
def customers; Customers.new company_id, token; end
|
#get(action, data = {}) ⇒ Object
22
23
24
|
# File 'lib/koho.rb', line 22
def get action, data = {}
JSON.parse(self.class.get action, query: data.merge(company_id: @company_id, token: @token))
end
|
#info ⇒ Object
40
41
42
|
# File 'lib/koho.rb', line 40
def info
get '/info'
end
|
#invoices ⇒ Object
35
|
# File 'lib/koho.rb', line 35
def invoices; Invoices.new company_id, token; end
|
#post(action, data = {}) ⇒ Object
26
27
28
|
# File 'lib/koho.rb', line 26
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
30
31
32
|
# File 'lib/koho.rb', line 30
def put action, data = {}
JSON.parse(self.class.put action, {method: '_PUT', body: {company_id: @company_id, token: @token}.merge(data)})
end
|