kiik 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc35f97e2e5b4201b86040593b4615a86ab5e4b9
4
- data.tar.gz: 09f7abbdad3b0df36f2e557a8d6f4b5cff2eaf79
3
+ metadata.gz: 012cd04f7c4f5e2e3c3015f3a206b72cde62a2f6
4
+ data.tar.gz: 0dc06a0f8e3b12d9fe9d321640eed7669b580fe5
5
5
  SHA512:
6
- metadata.gz: 85878db1fae575fd44bfd4a04c09f6b50c698a6fd1c3e35a8cab2cdeaafcd998ae0afc951ac026256452f0fbf3ef043be31cef6f9e9d8cdefbe22fadc5932455
7
- data.tar.gz: 35cfec56927bc99612b9283ad683acd71f287a8eca8603710923d294f2a11bb0cb534ad8f20ac1de183d0f5f101bbd10f910394c11850fade751756bce814df6
6
+ metadata.gz: acdad901ce1f0141828b8cdd5f45db37e976cd62db1bc621dddd072a00e4a98b7fa236a7a4d173ea6f22e71469abec78c4baa3d9e3e509f91ee56a9877bb6b97
7
+ data.tar.gz: e8a142d2765dde8a98c5f41d60a268a0488ba6bc01ceedc6b15d6006459c977343d3271b3e2d1e7beebc68903a0019d8baaf1c7664439d365df2112eeeac1169
@@ -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
@@ -1,12 +1,12 @@
1
1
  development:
2
- api_key: payos_kiik
2
+ api_key: payos_test
3
3
  host: http://localhost:8800
4
- version: 0.1.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.1.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.1.0
12
+ version: 0.3
@@ -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.0'
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']
@@ -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
@@ -2,6 +2,6 @@ module Kiik
2
2
  class Charge < Resource
3
3
  include Kiik::Rest::Create
4
4
 
5
- attr_accessor :customer, :amount, :receipt_email, :destination, :description, :statement_descriptor, :status
5
+ attr_accessor :customer_id, :amount, :receipt_email, :destination, :description, :statement_descriptor, :status, :intermediaries
6
6
  end
7
7
  end
@@ -1,6 +1,7 @@
1
1
  module Kiik
2
2
  class Customer < Resource
3
3
  include Kiik::Rest::Create
4
+ include Kiik::Rest::Update
4
5
 
5
6
  attr_accessor :phone, :name, :document, :email, :metadata, :description, :cards
6
7
 
@@ -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
@@ -19,29 +19,33 @@ module Kiik
19
19
  end
20
20
 
21
21
  def create(params={})
22
- result = request(params)
23
- raise result if result.instance_of? StandardError or result.instance_of? KiikError
22
+ result = request_create(params)
23
+ raise result if result.instance_of? StandardError
24
24
  result
25
25
  end
26
26
 
27
- def request(params)
28
- options = opts.merge!({:body => JSON.generate(params)})
29
- response = post url, options
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.request(self.to_json)
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
@@ -19,18 +19,19 @@ module Kiik
19
19
  end
20
20
 
21
21
  def update(params={})
22
- result = request(params)
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 request(params)
28
- options = opts.merge!({:body => JSON.generate(params)})
29
- response = post url + "/" + params[:id], options
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.request(self.to_json)
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.0
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-10-30 00:00:00.000000000 Z
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