killbill-client 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b11bb5f4d2ca2689babcb02b317cf6b2fd435171
4
- data.tar.gz: 25e55679617185f1a4ae6413706eea33b72674c0
3
+ metadata.gz: 6fad164b88b350adc1a485b9a32477c4df272d91
4
+ data.tar.gz: 368270504f8d9598bb91a92e00ef7c9e39e397f1
5
5
  SHA512:
6
- metadata.gz: a72b8c9399474f46d72b4d813aa3fda99aeb15bfbddfaf97c915ecf337b185075e70e9daedfe7561104a5a9a02ee8b955f508746bb47db681b6e493f830b0adf
7
- data.tar.gz: db0d6396de70db7f56c37773ec8363b1946e2762c91150dcd22d7a9352c01544b4526886b89e2df184c2d8cca24e0faaf4ed1ee9a05a75ecb2ab54bebcdf5ab7
6
+ metadata.gz: a8f72141bf452ba5c97e91c7e5e1609a8a04c19c77e0ce5bad82ff229e7533c05b46aba8f3629627bff680888d52f50d41ddff5e4440d8b14c7b070f6679c986
7
+ data.tar.gz: 46c357a8977bf18582e3da97b7fb4d720c320898bf9f64c168de8d0c79afff675024114e776de5abb5750a896e087de0e9fdd6728dd63c53028da4c42edb86ab
@@ -9,6 +9,34 @@ module KillBillClient
9
9
 
10
10
  create_alias :bundle_keys, :external_bundle_keys
11
11
 
12
+ class << self
13
+ def find_by_id(payment_id, with_refunds_and_chargebacks = false, options = {})
14
+ get "#{KILLBILL_API_PAYMENTS_PREFIX}/#{payment_id}",
15
+ {
16
+ :withRefundsAndChargebacks => with_refunds_and_chargebacks
17
+ },
18
+ options
19
+ end
20
+
21
+ def find_in_batches(offset = 0, limit = 100, options = {})
22
+ get "#{KILLBILL_API_PAYMENTS_PREFIX}/#{Resource::KILLBILL_API_PAGINATION_PREFIX}",
23
+ {
24
+ :offset => offset,
25
+ :limit => limit
26
+ },
27
+ options
28
+ end
29
+
30
+ def find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {})
31
+ get "#{KILLBILL_API_PAYMENTS_PREFIX}/search/#{search_key}",
32
+ {
33
+ :offset => offset,
34
+ :limit => limit
35
+ },
36
+ options
37
+ end
38
+ end
39
+
12
40
  def create(external_payment = false, user = nil, reason = nil, comment = nil, options = {})
13
41
  # Nothing to return (nil)
14
42
  self.class.post "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/payments",
@@ -2,7 +2,7 @@ module KillBillClient
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- PATCH = 6
5
+ PATCH = 7
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
@@ -2,6 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe KillBillClient::Model do
4
4
  it 'should manipulate accounts' do
5
+ # In case the remote server has lots of data
6
+ search_limit = 100000
7
+
5
8
  external_key = Time.now.to_i.to_s
6
9
 
7
10
  account = KillBillClient::Model::Account.new
@@ -32,7 +35,7 @@ describe KillBillClient::Model do
32
35
  account.payment_method_id.should be_nil
33
36
 
34
37
  # Try to retrieve it (bis repetita placent)
35
- accounts = KillBillClient::Model::Account.find_in_batches
38
+ accounts = KillBillClient::Model::Account.find_in_batches(0, search_limit)
36
39
  # Can't test equality if the remote server has extra data
37
40
  accounts.pagination_total_nb_records.should >= 1
38
41
  accounts.pagination_max_nb_records.should >= 1
@@ -46,7 +49,7 @@ describe KillBillClient::Model do
46
49
  found.should_not be_nil
47
50
 
48
51
  # Try to retrieve it via the search API
49
- accounts = KillBillClient::Model::Account.find_in_batches_by_search_key(account.name)
52
+ accounts = KillBillClient::Model::Account.find_in_batches_by_search_key(account.name, 0, search_limit)
50
53
  # Can't test equality if the remote server has extra data
51
54
  accounts.pagination_total_nb_records.should >= 1
52
55
  accounts.pagination_max_nb_records.should >= 1
@@ -83,7 +86,7 @@ describe KillBillClient::Model do
83
86
  pm.account_id.should == account.account_id
84
87
 
85
88
  # Try to retrieve it (bis repetita placent)
86
- pms = KillBillClient::Model::PaymentMethod.find_in_batches
89
+ pms = KillBillClient::Model::PaymentMethod.find_in_batches(0, search_limit)
87
90
  # Can't test equality if the remote server has extra data
88
91
  pms.pagination_total_nb_records.should >= 1
89
92
  pms.pagination_max_nb_records.should >= 1
@@ -152,6 +155,24 @@ describe KillBillClient::Model do
152
155
  payment.account_id = account.account_id
153
156
  payment.create true, 'KillBill Spec test'
154
157
 
158
+ # Try to retrieve it
159
+ payments = KillBillClient::Model::Payment.find_in_batches(0, search_limit)
160
+ # Can't test equality if the remote server has extra data
161
+ payments.pagination_total_nb_records.should >= 1
162
+ payments.pagination_max_nb_records.should >= 1
163
+ payments.size.should >= 1
164
+ # If the remote server has lots of data, we need to page through the results (good test!)
165
+ found = nil
166
+ payments.each_in_batches do |p|
167
+ found = p if p.account_id == account.account_id
168
+ break unless found.nil?
169
+ end
170
+ found.should_not be_nil
171
+
172
+ # Try to retrieve it (bis repetita placent)
173
+ payment = KillBillClient::Model::Payment.find_by_id found.payment_id
174
+ payment.account_id.should == account.account_id
175
+
155
176
  # Check the account balance
156
177
  account = KillBillClient::Model::Account.find_by_id account.account_id, true
157
178
  account.account_balance.should == 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Killbill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-03 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json