kiik 0.1.0 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +59 -0
- data/config/kiik.yml +4 -4
- data/kiik.gemspec +1 -1
- data/lib/kiik.rb +1 -1
- data/lib/kiik/charge.rb +1 -1
- data/lib/kiik/customer.rb +1 -0
- data/lib/kiik/error.rb +2 -2
- data/lib/kiik/rest/create.rb +11 -7
- data/lib/kiik/rest/update.rb +7 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 012cd04f7c4f5e2e3c3015f3a206b72cde62a2f6
|
4
|
+
data.tar.gz: 0dc06a0f8e3b12d9fe9d321640eed7669b580fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acdad901ce1f0141828b8cdd5f45db37e976cd62db1bc621dddd072a00e4a98b7fa236a7a4d173ea6f22e71469abec78c4baa3d9e3e509f91ee56a9877bb6b97
|
7
|
+
data.tar.gz: e8a142d2765dde8a98c5f41d60a268a0488ba6bc01ceedc6b15d6006459c977343d3271b3e2d1e7beebc68903a0019d8baaf1c7664439d365df2112eeeac1169
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kiik (0.1.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (4.2.5)
|
10
|
+
i18n (~> 0.7)
|
11
|
+
json (~> 1.7, >= 1.7.7)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
addressable (2.3.8)
|
16
|
+
crack (0.4.2)
|
17
|
+
safe_yaml (~> 1.0.0)
|
18
|
+
httparty (0.13.7)
|
19
|
+
json (~> 1.8)
|
20
|
+
multi_xml (>= 0.5.2)
|
21
|
+
i18n (0.7.0)
|
22
|
+
json (1.8.3)
|
23
|
+
metaclass (0.0.4)
|
24
|
+
minitest (5.8.2)
|
25
|
+
mocha (0.14.0)
|
26
|
+
metaclass (~> 0.0.1)
|
27
|
+
multi_xml (0.5.5)
|
28
|
+
power_assert (0.2.6)
|
29
|
+
rake (10.4.2)
|
30
|
+
safe_yaml (1.0.4)
|
31
|
+
shoulda (3.5.0)
|
32
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
33
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
34
|
+
shoulda-context (1.2.1)
|
35
|
+
shoulda-matchers (2.8.0)
|
36
|
+
activesupport (>= 3.0.0)
|
37
|
+
test-unit (3.1.5)
|
38
|
+
power_assert
|
39
|
+
thread_safe (0.3.5)
|
40
|
+
tzinfo (1.2.2)
|
41
|
+
thread_safe (~> 0.1)
|
42
|
+
webmock (1.21.0)
|
43
|
+
addressable (>= 2.3.6)
|
44
|
+
crack (>= 0.3.2)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
ruby
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
httparty (>= 0.13.7)
|
51
|
+
kiik!
|
52
|
+
mocha (~> 0.13)
|
53
|
+
rake (~> 10.4)
|
54
|
+
shoulda (~> 3.5)
|
55
|
+
test-unit (~> 3.1)
|
56
|
+
webmock (~> 1.21.0)
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
1.10.6
|
data/config/kiik.yml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
development:
|
2
|
-
api_key:
|
2
|
+
api_key: payos_test
|
3
3
|
host: http://localhost:8800
|
4
|
-
version: 0.
|
4
|
+
version: 0.3
|
5
5
|
staging:
|
6
6
|
api_key: B31DCE74-E768-43ED-86DA-85501612548F
|
7
7
|
host: https://demo.kiik.com
|
8
|
-
version: 0.
|
8
|
+
version: 0.3
|
9
9
|
production:
|
10
10
|
api_key: B31DCE74-E768-43ED-86DA-85501612548F
|
11
11
|
host: https://api.kiik.com
|
12
|
-
version: 0.
|
12
|
+
version: 0.3
|
data/kiik.gemspec
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = 'kiik'
|
5
|
-
s.version = '0.1.
|
5
|
+
s.version = '0.1.4'
|
6
6
|
s.summary = 'Integrate Kiik with your Ruby app'
|
7
7
|
s.description = "KiiK's official gem that helps you to integrate with our services. See https://docs.kiik.com.br for details."
|
8
8
|
s.authors = ['Julien Lucca', 'Esdras Eduardo']
|
data/lib/kiik.rb
CHANGED
@@ -2,6 +2,7 @@ require 'yaml'
|
|
2
2
|
require 'httparty'
|
3
3
|
|
4
4
|
require 'kiik/rest/create'
|
5
|
+
require 'kiik/rest/update'
|
5
6
|
require 'kiik/util'
|
6
7
|
require 'kiik/resource'
|
7
8
|
require 'kiik/card'
|
@@ -28,5 +29,4 @@ module Kiik
|
|
28
29
|
class << self
|
29
30
|
attr_accessor :api_key, :host, :version
|
30
31
|
end
|
31
|
-
|
32
32
|
end
|
data/lib/kiik/charge.rb
CHANGED
@@ -2,6 +2,6 @@ module Kiik
|
|
2
2
|
class Charge < Resource
|
3
3
|
include Kiik::Rest::Create
|
4
4
|
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :customer_id, :amount, :receipt_email, :destination, :description, :statement_descriptor, :status, :intermediaries
|
6
6
|
end
|
7
7
|
end
|
data/lib/kiik/customer.rb
CHANGED
data/lib/kiik/error.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Kiik
|
2
2
|
class KiikError < StandardError
|
3
3
|
attr_reader :errors
|
4
|
-
def initialize(body)
|
5
|
-
@errors = [{attr: body['error']['param'], message: body['error']['message']}]
|
4
|
+
def initialize(body = nil)
|
5
|
+
@errors = body.nil? ? [] : [{attr: body['error']['param'], message: body['error']['message']}]
|
6
6
|
end
|
7
7
|
|
8
8
|
def to_s
|
data/lib/kiik/rest/create.rb
CHANGED
@@ -19,29 +19,33 @@ module Kiik
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def create(params={})
|
22
|
-
result =
|
23
|
-
raise result if result.instance_of? StandardError
|
22
|
+
result = request_create(params)
|
23
|
+
raise result if result.instance_of? StandardError
|
24
24
|
result
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
options = opts.merge!(
|
29
|
-
response = post
|
30
|
-
response.body
|
27
|
+
def request_create(params)
|
28
|
+
options = opts.merge!(body: JSON.generate(params))
|
29
|
+
response = post(url, options)
|
31
30
|
case response.code
|
32
31
|
when 200
|
33
32
|
build(JSON.parse(response.body))
|
33
|
+
when 402
|
34
|
+
result = KiikError.new
|
35
|
+
result.errors << ({attr: 'status', message: 'recused'})
|
36
|
+
build(JSON.parse(response.body), result)
|
34
37
|
when 422
|
35
38
|
KiikError.new(JSON.parse(response.body))
|
36
39
|
else
|
37
40
|
StandardError.new(response.message)
|
38
41
|
end
|
39
42
|
end
|
43
|
+
|
40
44
|
end
|
41
45
|
|
42
46
|
def create
|
43
47
|
created = false
|
44
|
-
result = self.class.
|
48
|
+
result = self.class.request_create(self.to_json)
|
45
49
|
if result.instance_of? KiikError
|
46
50
|
self.errors = result.errors
|
47
51
|
elsif result.instance_of? StandardError
|
data/lib/kiik/rest/update.rb
CHANGED
@@ -19,18 +19,19 @@ module Kiik
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def update(params={})
|
22
|
-
result =
|
22
|
+
result = request_update(params)
|
23
23
|
raise result if result.instance_of? StandardError or result.instance_of? KiikError
|
24
24
|
result
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
options = opts.merge!(
|
29
|
-
response =
|
30
|
-
response.body
|
27
|
+
def request_update(params)
|
28
|
+
options = opts.merge!(body: JSON.generate(params))
|
29
|
+
response = put(url + "/" + params['id'], options)
|
31
30
|
case response.code
|
32
31
|
when 200
|
32
|
+
$stdout.puts "BATEU DO BUILD"
|
33
33
|
build(JSON.parse(response.body))
|
34
|
+
$stdout.puts "BATEU DEPOIS DO BUILD"
|
34
35
|
when 422
|
35
36
|
KiikError.new(JSON.parse(response.body))
|
36
37
|
else
|
@@ -41,7 +42,7 @@ module Kiik
|
|
41
42
|
|
42
43
|
def updated
|
43
44
|
updated = false
|
44
|
-
result = self.class.
|
45
|
+
result = self.class.request_update(self.to_json)
|
45
46
|
if result.instance_of? KiikError
|
46
47
|
self.errors = result.errors
|
47
48
|
elsif result.instance_of? StandardError
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kiik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Lucca
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mocha
|
@@ -92,6 +92,7 @@ extra_rdoc_files: []
|
|
92
92
|
files:
|
93
93
|
- ".gitignore"
|
94
94
|
- Gemfile
|
95
|
+
- Gemfile.lock
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
98
|
- config/kiik.yml
|