killbill-client 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 33483de38f929a119b1f8fe0397187cd2a1c68a2
4
+ data.tar.gz: b1191889e0ce3bdc4e8ac4e725e46460399f66e4
5
+ SHA512:
6
+ metadata.gz: dc46633af7cda5602fce3ff92914112f3724b5c7ef9531903747e4683983b04e1cc2c80da03e01529b22d06482e00a89051e7c245be15571966ba5a179787643
7
+ data.tar.gz: 625605bd4e11bf53fdb149965737527d5e0c808a88723405852cc020781c89d140c20a783567741514b94a53b418bf29d43347f240fc1eebfe52620b1dff6f04
data/README.md CHANGED
@@ -38,4 +38,5 @@ To run the integration tests:
38
38
  rake test:remote:spec
39
39
  ```
40
40
 
41
- You need to set in spec/spec_helper.rb the url of your instance, e.g. `KillBillClient.url = 'http://127.0.0.1:8080'`.
41
+ You need to set in spec/spec_helper.rb the url of your instance, e.g. `KillBillClient.url = 'http://127.0.0.1:8080'` and the username and password to authenticate the API, e.g. `KillBillClient.username = 'admin'` and `KillBillClient.password = 'password'`
42
+
@@ -29,6 +29,13 @@ module KillBillClient
29
29
  created_account.refresh(options)
30
30
  end
31
31
 
32
+ def bundles(options = {})
33
+ self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/bundles",
34
+ {},
35
+ options,
36
+ Bundle
37
+ end
38
+
32
39
  def invoices(with_items=false, options = {})
33
40
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/invoices",
34
41
  {
@@ -1,7 +1,21 @@
1
1
  module KillBillClient
2
2
  module Model
3
3
  class Credit < CreditAttributes
4
+ KILLBILL_API_CREDITS_PREFIX = "#{KILLBILL_API_PREFIX}/credits"
4
5
  has_many :audit_logs, KillBillClient::Model::AuditLog
6
+
7
+ def create(user = nil, reason = nil, comment = nil, options = {})
8
+ created_credit = self.class.post KILLBILL_API_CREDITS_PREFIX,
9
+ to_json,
10
+ {},
11
+ {
12
+ :user => user,
13
+ :reason => reason,
14
+ :comment => comment,
15
+ }.merge(options)
16
+ created_credit.refresh(options)
17
+ end
18
+
5
19
  end
6
20
  end
7
21
  end
@@ -2,7 +2,7 @@ module KillBillClient
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- PATCH = 4
5
+ PATCH = 5
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
@@ -138,6 +138,41 @@ describe KillBillClient::Model do
138
138
  payment = timeline.payments.first
139
139
  payment.refunds.should_not be_empty
140
140
  payment.refunds.first.amount.should == invoice_item.amount
141
+
142
+ # Create a credit for invoice
143
+ new_credit = KillBillClient::Model::Credit.new
144
+ new_credit.credit_amount = 10.1
145
+ new_credit.invoice_id = invoice_id
146
+ new_credit.effective_date = "2013-09-30"
147
+ new_credit.account_id = account.account_id
148
+ new_credit.create 'KillBill Spec test'
149
+
150
+ # Verify the invoice item of the credit
151
+ invoice = KillBillClient::Model::Invoice.find_by_id_or_number invoice_id
152
+ invoice.items.should_not be_empty
153
+ item = invoice.items.last
154
+ item.invoice_id.should == invoice_id
155
+ item.amount.should == 10.1
156
+ item.account_id.should == account.account_id
157
+
158
+ # Verify the credit
159
+ account = KillBillClient::Model::Account.find_by_id account.account_id, true
160
+ account.account_balance.should == -10.1
161
+
162
+ # Create a subscription
163
+ sub = KillBillClient::Model::Subscription.new
164
+ sub.account_id = account.account_id
165
+ sub.external_key = Time.now.to_i.to_s
166
+ sub.product_name = 'Sports'
167
+ sub.product_category = 'BASE'
168
+ sub.billing_period = 'MONTHLY'
169
+ sub.price_list = 'DEFAULT'
170
+ sub = sub.create 'KillBill Spec test'
171
+
172
+ # Verify we can retrieve it
173
+ account.bundles.size.should == 1
174
+ account.bundles[0].subscriptions.size.should == 1
175
+ account.bundles[0].subscriptions[0].subscription_id.should == sub.subscription_id
141
176
  end
142
177
 
143
178
  it 'should manipulate tag definitions' do
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,8 @@ require 'logger'
8
8
  require 'rspec'
9
9
 
10
10
  KillBillClient.url = 'http://127.0.0.1:8080'
11
+ KillBillClient.username = 'admin'
12
+ KillBillClient.password = 'password'
11
13
 
12
14
  RSpec.configure do |config|
13
15
  config.color_enabled = true
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
5
- prerelease:
4
+ version: 0.4.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Killbill core team
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-25 00:00:00.000000000 Z
11
+ date: 2013-10-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 10.0.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 10.0.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -142,6 +135,7 @@ files:
142
135
  homepage: http://www.killbilling.org
143
136
  licenses:
144
137
  - Apache License (2.0)
138
+ metadata: {}
145
139
  post_install_message:
146
140
  rdoc_options:
147
141
  - --exclude
@@ -149,25 +143,20 @@ rdoc_options:
149
143
  require_paths:
150
144
  - lib
151
145
  required_ruby_version: !ruby/object:Gem::Requirement
152
- none: false
153
146
  requirements:
154
- - - ! '>='
147
+ - - '>='
155
148
  - !ruby/object:Gem::Version
156
149
  version: 1.8.6
157
150
  required_rubygems_version: !ruby/object:Gem::Requirement
158
- none: false
159
151
  requirements:
160
- - - ! '>='
152
+ - - '>='
161
153
  - !ruby/object:Gem::Version
162
154
  version: '0'
163
- segments:
164
- - 0
165
- hash: -2561127530426758978
166
155
  requirements: []
167
156
  rubyforge_project:
168
- rubygems_version: 1.8.25
157
+ rubygems_version: 2.0.3
169
158
  signing_key:
170
- specification_version: 3
159
+ specification_version: 4
171
160
  summary: Kill Bill client library.
172
161
  test_files:
173
162
  - spec/killbill_client/model_relation_spec.rb