koho 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/koho.gemspec +0 -1
- data/lib/koho/version.rb +1 -1
- data/lib/koho.rb +41 -7
- metadata +2 -2
data/koho.gemspec
CHANGED
data/lib/koho/version.rb
CHANGED
data/lib/koho.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require "koho/version"
|
2
|
+
require 'httparty'
|
2
3
|
|
3
4
|
module Koho
|
4
5
|
|
5
6
|
class Client
|
6
7
|
include HTTParty
|
7
|
-
|
8
|
+
|
9
|
+
API_BASE_URL = 'https://dev.koho-online.com/api'
|
10
|
+
base_uri API_BASE_URL
|
8
11
|
|
9
12
|
attr_accessor :company_id,
|
10
13
|
:token
|
@@ -20,18 +23,26 @@ module Koho
|
|
20
23
|
end
|
21
24
|
|
22
25
|
def post action, data = {}
|
23
|
-
self.class.post action,
|
26
|
+
JSON.parse(self.class.post action, {method: '_POST', body: {company_id: @company_id, token: @token}.merge(data)})
|
24
27
|
end
|
25
28
|
|
26
|
-
|
29
|
+
def put action, data = {}
|
30
|
+
JSON.parse(self.class.put action, {method: '_PUT', body: {company_id: @company_id, token: @token}.merge(data)})
|
31
|
+
end
|
32
|
+
|
33
|
+
def customers; Customers.new company_id, token; end
|
34
|
+
def invoices; Invoices.new company_id, token; end
|
35
|
+
def contracts; Contracts.new company_id, token; end
|
27
36
|
|
28
|
-
|
37
|
+
##########################3
|
29
38
|
|
39
|
+
def info
|
40
|
+
get '/info'
|
30
41
|
end
|
31
42
|
|
32
43
|
class Invoices < Koho::Client
|
33
44
|
|
34
|
-
base_uri '
|
45
|
+
base_uri = API_BASE_URL+'/invoices'
|
35
46
|
|
36
47
|
|
37
48
|
def list
|
@@ -41,13 +52,21 @@ module Koho
|
|
41
52
|
def find id
|
42
53
|
get "/#{id}"
|
43
54
|
end
|
55
|
+
|
56
|
+
def create params
|
57
|
+
post '/', invoice: params
|
58
|
+
end
|
59
|
+
|
60
|
+
def update id, params
|
61
|
+
put "/#{id}", invoice: params
|
62
|
+
end
|
44
63
|
|
45
64
|
|
46
65
|
end
|
47
66
|
|
48
67
|
class Customers < Koho::Client
|
49
68
|
|
50
|
-
base_uri '
|
69
|
+
base_uri = API_BASE_URL+'/customers'
|
51
70
|
|
52
71
|
|
53
72
|
def list
|
@@ -57,13 +76,21 @@ module Koho
|
|
57
76
|
def find id
|
58
77
|
get "/#{id}"
|
59
78
|
end
|
79
|
+
|
80
|
+
def create params
|
81
|
+
post '/', customer: params
|
82
|
+
end
|
83
|
+
|
84
|
+
def update id, params
|
85
|
+
put "/#{id}", customer: params
|
86
|
+
end
|
60
87
|
|
61
88
|
|
62
89
|
end
|
63
90
|
|
64
91
|
class Contracts < Koho::Client
|
65
92
|
|
66
|
-
base_uri '
|
93
|
+
base_uri = API_BASE_URL+'/contracts'
|
67
94
|
|
68
95
|
|
69
96
|
def list
|
@@ -74,6 +101,13 @@ module Koho
|
|
74
101
|
get "/#{id}"
|
75
102
|
end
|
76
103
|
|
104
|
+
def create params
|
105
|
+
post '/', contract: params
|
106
|
+
end
|
107
|
+
|
108
|
+
def update id, params
|
109
|
+
put "/#{id}", contract: params
|
110
|
+
end
|
77
111
|
|
78
112
|
end
|
79
113
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
type: :development
|