kiik 0.1.12 → 0.2.0

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: 5873cc4128b2c4401494183c8fb1e077ffbcd8f2
4
- data.tar.gz: 8a967393d9e04252e0b7009e59f094a7926f28e0
3
+ metadata.gz: 3aa46780669ea29fcb0c21bc4824be339cde036b
4
+ data.tar.gz: fd352f9fbdde22a8a74be62ea635ce6f8bc8b501
5
5
  SHA512:
6
- metadata.gz: 137800cf1d54bdbd8d25fb151dce2540fb95a58d49b89fc5f6740b3d1ef3676a65cc36018aefc674f4e50e1874cf8957980d7ec2c128af4bbb192e63904bfd17
7
- data.tar.gz: 87792305f70e490fb14cf15bd8f398dd1b0ad0c240eb3d423d9b6330b81cc2514c3a79721fe3cb2096d443b10fbca8dd0b3d6923c4a1e77bcfc693ce911059cb
6
+ metadata.gz: 783be33cda49ce5363df1baacf639d01069619275f9031d248ec09eb6a2d0190090e6c0047ad6379c2bc51a76df8d05264bb73296f5b560dc400f4d5c21d2a1e
7
+ data.tar.gz: f8e3723af150b2e60810ee9cdcd7a07279983bd2ba10515101832ffdc896f2048b8e89022e8d34b80388468956bd1ac3fc365a35e25cb000660df0a1e55e3884
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kiik (0.1.7)
4
+ kiik (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  webmock (~> 1.21)
57
57
 
58
58
  BUNDLED WITH
59
- 1.10.6
59
+ 1.11.2
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # KiiK Ruby [![Codeship Status for kiik-payments/kiik_ruby](https://codeship.com/projects/893b1600-608e-0133-73dd-7258394f756c/status?branch=master)](https://codeship.com/projects/112216) [![Inline docs](http://inch-ci.org/github/kiik-payments/kiik-ruby.svg?branch=master)](http://inch-ci.org/github/kiik-payments/kiik-ruby)
1
+ # KiiK Ruby [![Build Status](https://snap-ci.com/kiik-payments/kiik_ruby/branch/master/build_image)](https://snap-ci.com/kiik-payments/kiik_ruby/branch/master) [![Inline docs](http://inch-ci.org/github/kiik-payments/kiik-ruby.svg?branch=master)](http://inch-ci.org/github/kiik-payments/kiik-ruby)
2
2
 
3
3
  Gem for bindings with Kiik API
4
4
 
@@ -2,7 +2,7 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'kiik'
5
- s.version = '0.1.12'
5
+ s.version = '0.2.0'
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']
@@ -3,12 +3,15 @@ require 'httparty'
3
3
 
4
4
  require 'kiik/rest/create'
5
5
  require 'kiik/rest/update'
6
+ require 'kiik/rest/get_all'
6
7
  require 'kiik/util'
7
8
  require 'kiik/resource'
8
9
  require 'kiik/card'
9
10
  require 'kiik/customer'
10
11
  require 'kiik/charge'
12
+ require 'kiik/compensation'
11
13
  require 'kiik/error'
14
+ require 'kiik/paginated'
12
15
 
13
16
  module Kiik
14
17
  relative_config = '../config/kiik.yml'
@@ -0,0 +1,39 @@
1
+ module Kiik
2
+ class Compensation < Resource
3
+ include Kiik::Rest::GetAll
4
+
5
+ attr_accessor :status, :received_at, :history_type, :expected_compensation_date,
6
+ :compensated_at, :charge_id, :amount, :aditional_info, :total
7
+
8
+ class << self
9
+ def consolidated(customer = nil, start_date = nil, end_date = nil)
10
+ url = customer.nil? ? '' : "#{customer}/"
11
+ url += "consolidated"
12
+ params = []
13
+ params << "start_date=#{start_date.strftime('%Y-%m-%d %H:%M:%S')}" if start_date
14
+ params << "end_date=#{end_date.strftime('%Y-%m-%d %H:%M:%S')}" if end_date
15
+ url += "?#{params.join('&')}" if params.length
16
+ result = request(url, {}, :GET, {})
17
+ raise result if result.kind_of? StandardError
18
+ result.total
19
+ end
20
+ end
21
+
22
+ def initialize(attributes = {})
23
+ super(attributes)
24
+ end
25
+
26
+ def to_json
27
+ super.merge!(super([
28
+ :status,
29
+ :received_at,
30
+ :history_type,
31
+ :expected_compensation_date,
32
+ :compensated_at,
33
+ :charge_id,
34
+ :amount,
35
+ :aditional_info
36
+ ]))
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ module Kiik
2
+ class Paginated
3
+ attr_accessor :result, :total, :errors
4
+ end
5
+ end
@@ -25,7 +25,13 @@ module Kiik
25
25
  end
26
26
 
27
27
  def build(data, error = nil)
28
- instance = self.new(data)
28
+ if data['result'] && data['total']
29
+ instance = Kiik::Paginated.new()
30
+ instance.result = data['result'].map { |element| self.new(element) }
31
+ instance.total = data['total']
32
+ else
33
+ instance = self.new(data)
34
+ end
29
35
  instance.errors = error.errors unless error.nil?
30
36
  instance
31
37
  end
@@ -0,0 +1,46 @@
1
+ module Kiik
2
+ module Rest
3
+ module GetAll
4
+ class << self
5
+
6
+ def included(base)
7
+ base.extend(ClassMethods)
8
+ end
9
+
10
+ end
11
+ def get_all
12
+ result = self.class.get_all(self.to_json)
13
+ raise result if result.instance_of? StandardError
14
+
15
+ if result.instance_of? KiikError
16
+ self.errors = result.errors
17
+ return false
18
+ end
19
+
20
+ initialize(result.to_json)
21
+ true
22
+ end
23
+
24
+ module ClassMethods
25
+
26
+ def get_all!(params={}, header={})
27
+ begin
28
+ get_all(params, header)
29
+ rescue KiikError => e
30
+ build(params, e)
31
+ rescue StandardError => e
32
+ e
33
+ end
34
+ end
35
+
36
+ def get_all(params={}, header={})
37
+
38
+ result = request(nil, params, :GET, header)
39
+
40
+ raise result if result.kind_of? StandardError
41
+ result
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Kiik
4
+ class ResourceTest < Test::Unit::TestCase
5
+
6
+ should "" do
7
+ respond = {errors: [{type:"invalid_request_error", param:"name", message:"Param name is required"}]}
8
+ post({}, respond, 422)
9
+ assert_raise KiikError do
10
+ Kiik::Customer.create
11
+ end
12
+ end
13
+
14
+ end
15
+ end
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.12
4
+ version: 0.2.0
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: 2016-03-09 00:00:00.000000000 Z
12
+ date: 2016-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mocha
@@ -100,16 +100,20 @@ files:
100
100
  - lib/kiik.rb
101
101
  - lib/kiik/card.rb
102
102
  - lib/kiik/charge.rb
103
+ - lib/kiik/compensation.rb
103
104
  - lib/kiik/customer.rb
104
105
  - lib/kiik/error.rb
106
+ - lib/kiik/paginated.rb
105
107
  - lib/kiik/resource.rb
106
108
  - lib/kiik/rest/create.rb
109
+ - lib/kiik/rest/get_all.rb
107
110
  - lib/kiik/rest/update.rb
108
111
  - lib/kiik/util.rb
109
112
  - lib/tasks/kiik.rake
110
113
  - test/kiik/card_test.rb
111
114
  - test/kiik/charge_test.rb
112
115
  - test/kiik/customer_test.rb
116
+ - test/kiik/resource_test.rb
113
117
  - test/test_helper.rb
114
118
  - test/test_mock.rb
115
119
  homepage: http://docs.kiik.com
@@ -140,5 +144,6 @@ test_files:
140
144
  - test/kiik/card_test.rb
141
145
  - test/kiik/charge_test.rb
142
146
  - test/kiik/customer_test.rb
147
+ - test/kiik/resource_test.rb
143
148
  - test/test_helper.rb
144
149
  - test/test_mock.rb