kojn 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/VERSION +1 -1
- data/kojn.gemspec +4 -4
- data/lib/kojn.rb +1 -1
- data/lib/kojn/collection.rb +4 -4
- data/lib/kojn/net.rb +14 -24
- data/lib/kojn/transaction.rb +4 -4
- metadata +7 -7
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/kojn.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "kojn"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeffrey Wilcke", "Maran Hidskes"]
|
@@ -52,7 +52,7 @@ Gem::Specification.new do |s|
|
|
52
52
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
53
|
s.add_runtime_dependency(%q<activemodel>, [">= 3.0"])
|
54
54
|
s.add_runtime_dependency(%q<activesupport>, [">= 3.0"])
|
55
|
-
s.add_runtime_dependency(%q<
|
55
|
+
s.add_runtime_dependency(%q<faraday>, [">= 0"])
|
56
56
|
s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
|
57
57
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
58
58
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
@@ -60,7 +60,7 @@ Gem::Specification.new do |s|
|
|
60
60
|
else
|
61
61
|
s.add_dependency(%q<activemodel>, [">= 3.0"])
|
62
62
|
s.add_dependency(%q<activesupport>, [">= 3.0"])
|
63
|
-
s.add_dependency(%q<
|
63
|
+
s.add_dependency(%q<faraday>, [">= 0"])
|
64
64
|
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
65
65
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
66
66
|
s.add_dependency(%q<rspec>, [">= 0"])
|
@@ -69,7 +69,7 @@ Gem::Specification.new do |s|
|
|
69
69
|
else
|
70
70
|
s.add_dependency(%q<activemodel>, [">= 3.0"])
|
71
71
|
s.add_dependency(%q<activesupport>, [">= 3.0"])
|
72
|
-
s.add_dependency(%q<
|
72
|
+
s.add_dependency(%q<faraday>, [">= 0"])
|
73
73
|
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
74
74
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
75
75
|
s.add_dependency(%q<rspec>, [">= 0"])
|
data/lib/kojn.rb
CHANGED
data/lib/kojn/collection.rb
CHANGED
@@ -12,19 +12,19 @@ module Kojn
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def all(options = {})
|
15
|
-
parse_objects! Kojn::Net::get(self.path).
|
15
|
+
parse_objects! Kojn::Net::get(self.path).body, self.model
|
16
16
|
end
|
17
17
|
|
18
18
|
def create(options = {})
|
19
|
-
parse_object! Kojn::Net::post(self.path, {invoice: options}).
|
19
|
+
parse_object! Kojn::Net::post(self.path, {invoice: options}).body, self.model
|
20
20
|
end
|
21
21
|
|
22
22
|
def find(id, options = {})
|
23
|
-
parse_object! Kojn::Net::get("#{self.path}/#{id}").
|
23
|
+
parse_object! Kojn::Net::get("#{self.path}/#{id}").body, self.model
|
24
24
|
end
|
25
25
|
|
26
26
|
def update(id, options = {})
|
27
|
-
parse_object! Kojn::Net::patch("#{self.path}/#{id}", options).
|
27
|
+
parse_object! Kojn::Net::patch("#{self.path}/#{id}", options).body, self.model
|
28
28
|
end
|
29
29
|
|
30
30
|
protected
|
data/lib/kojn/net.rb
CHANGED
@@ -1,52 +1,42 @@
|
|
1
1
|
module Kojn
|
2
2
|
module Net
|
3
|
-
def self.
|
4
|
-
return "http#{Kojn.ssl ? "s" : ""}://#{Kojn.host}:#{Kojn.port}
|
3
|
+
def self.base_host
|
4
|
+
return "http#{Kojn.ssl ? "s" : ""}://#{Kojn.host}:#{Kojn.port}"
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
c.verbose = Kojn.verbose
|
13
|
-
c.ssl_verify_peer = Kojn.verify_peer_and_host
|
14
|
-
c.ssl_verify_host = Kojn.verify_peer_and_host
|
15
|
-
|
16
|
-
if verb != :GET
|
17
|
-
c.post_body = options.to_json
|
7
|
+
def self.request(verb, path, options={})
|
8
|
+
conn = Faraday.new(:url => self.base_host) do |faraday|
|
9
|
+
faraday.request :url_encoded # form-encode POST params
|
10
|
+
faraday.response :logger # log requests to STDOUT
|
11
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
18
12
|
end
|
13
|
+
conn.basic_auth(Kojn.api_key, '')
|
19
14
|
|
20
|
-
|
21
|
-
c.http_auth_types = :basic
|
22
|
-
c.username = Kojn.api_key
|
23
|
-
c.password = ''
|
24
|
-
|
25
|
-
c.http(verb)
|
15
|
+
response = conn.send(verb.to_s.downcase, path, options)
|
26
16
|
|
27
|
-
return
|
17
|
+
return response
|
28
18
|
end
|
29
19
|
|
30
20
|
def self.get(path, options={})
|
31
|
-
request = self.
|
21
|
+
request = self.request(:GET, path, options)
|
32
22
|
|
33
23
|
return request
|
34
24
|
end
|
35
25
|
|
36
26
|
def self.post(path, options={})
|
37
|
-
request = self.
|
27
|
+
request = self.request(:POST, path, options)
|
38
28
|
|
39
29
|
return request
|
40
30
|
end
|
41
31
|
|
42
32
|
def self.patch(path, options={})
|
43
|
-
request = self.
|
33
|
+
request = self.request(:PATCH, path, options)
|
44
34
|
|
45
35
|
return request
|
46
36
|
end
|
47
37
|
|
48
38
|
def self.delete(path, options={})
|
49
|
-
request = self.
|
39
|
+
request = self.request(:DELETE, path, options)
|
50
40
|
|
51
41
|
return request
|
52
42
|
end
|
data/lib/kojn/transaction.rb
CHANGED
@@ -20,19 +20,19 @@ module Kojn
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def all(options = {})
|
23
|
-
Kojn.parse_objects! Kojn::Net::get('/api/transactions').
|
23
|
+
Kojn.parse_objects! Kojn::Net::get('/api/transactions').body, Kojn::Tx
|
24
24
|
end
|
25
25
|
|
26
26
|
def create(options = {})
|
27
|
-
Kojn.parse_object! Kojn::Net::post('/api/transactions', {transaction: options}).
|
27
|
+
Kojn.parse_object! Kojn::Net::post('/api/transactions', {transaction: options}).body, Kojn::Tx
|
28
28
|
end
|
29
29
|
|
30
30
|
def find(id, options = {})
|
31
|
-
Kojn.parse_object! Kojn::Net::get("/api/transactions/#{id}").
|
31
|
+
Kojn.parse_object! Kojn::Net::get("/api/transactions/#{id}").body, Kojn::Tx
|
32
32
|
end
|
33
33
|
|
34
34
|
def update(id, options = {})
|
35
|
-
Kojn.parse_object! Kojn::Net::patch("/api/transactions/#{id}", options).
|
35
|
+
Kojn.parse_object! Kojn::Net::patch("/api/transactions/#{id}", options).body, Kojn::Tx
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kojn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -45,21 +45,21 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '3.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: faraday
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- - ! '
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
none: false
|
59
59
|
requirements:
|
60
|
-
- - ! '
|
60
|
+
- - ! '>='
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0
|
62
|
+
version: '0'
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: bundler
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
segments:
|
174
174
|
- 0
|
175
|
-
hash: -
|
175
|
+
hash: -4292198967056187689
|
176
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
177
|
none: false
|
178
178
|
requirements:
|