killbill-client 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +5 -13
  2. data/lib/killbill_client/api/api.rb +2 -2
  3. data/lib/killbill_client/api/errors.rb +1 -1
  4. data/lib/killbill_client/api/net_http_adapter.rb +21 -1
  5. data/lib/killbill_client/models/account.rb +60 -112
  6. data/lib/killbill_client/models/account_timeline.rb +1 -1
  7. data/lib/killbill_client/models/bundle.rb +35 -34
  8. data/lib/killbill_client/models/catalog.rb +34 -0
  9. data/lib/killbill_client/models/custom_field.rb +3 -11
  10. data/lib/killbill_client/models/gen/account_attributes.rb +3 -3
  11. data/lib/killbill_client/models/gen/account_email_attributes.rb +3 -3
  12. data/lib/killbill_client/models/gen/account_timeline_attributes.rb +3 -3
  13. data/lib/killbill_client/models/gen/audit_log_attributes.rb +3 -3
  14. data/lib/killbill_client/models/gen/billing_exception_attributes.rb +3 -3
  15. data/lib/killbill_client/models/gen/bundle_attributes.rb +3 -3
  16. data/lib/killbill_client/models/gen/bundle_timeline_attributes.rb +3 -3
  17. data/lib/killbill_client/models/gen/catalog_attributes_simple.rb +3 -3
  18. data/lib/killbill_client/models/gen/credit_attributes.rb +3 -3
  19. data/lib/killbill_client/models/gen/custom_field_attributes.rb +3 -3
  20. data/lib/killbill_client/models/gen/deleted_event_subscription_attributes.rb +3 -3
  21. data/lib/killbill_client/models/gen/direct_payment_attributes.rb +45 -0
  22. data/lib/killbill_client/models/gen/direct_transaction_attributes.rb +47 -0
  23. data/lib/killbill_client/models/gen/event_subscription_attributes.rb +3 -3
  24. data/lib/killbill_client/models/gen/{chargeback_attributes.rb → gateway_notification_attributes.rb} +9 -12
  25. data/lib/killbill_client/models/gen/{refund_attributes.rb → hosted_payment_page_billing_address_attributes.rb} +10 -14
  26. data/lib/killbill_client/models/gen/hosted_payment_page_customer_attributes.rb +36 -0
  27. data/lib/killbill_client/models/gen/hosted_payment_page_fields_attributes.rb +33 -0
  28. data/lib/killbill_client/models/gen/hosted_payment_page_form_descriptor_attributes.rb +37 -0
  29. data/lib/killbill_client/models/gen/invoice_attributes.rb +3 -3
  30. data/lib/killbill_client/models/gen/invoice_email_attributes.rb +3 -3
  31. data/lib/killbill_client/models/gen/invoice_item_attributes.rb +3 -3
  32. data/lib/killbill_client/models/gen/invoice_payment_attributes.rb +46 -0
  33. data/lib/killbill_client/models/gen/invoice_payment_transaction_attributes.rb +49 -0
  34. data/lib/killbill_client/models/gen/new_event_subscription_attributes.rb +3 -3
  35. data/lib/killbill_client/models/gen/notification_attributes.rb +3 -3
  36. data/lib/killbill_client/models/gen/overdue_state_attributes.rb +3 -3
  37. data/lib/killbill_client/models/gen/payment_attributes.rb +11 -16
  38. data/lib/killbill_client/models/gen/payment_method_attributes.rb +4 -3
  39. data/lib/killbill_client/models/gen/payment_method_plugin_detail_attributes.rb +3 -15
  40. data/lib/killbill_client/models/gen/payment_transaction_attributes.rb +47 -0
  41. data/lib/killbill_client/models/gen/phase_attributes.rb +3 -3
  42. data/lib/killbill_client/models/gen/plan_attributes.rb +3 -3
  43. data/lib/killbill_client/models/gen/plan_detail_attributes.rb +3 -3
  44. data/lib/killbill_client/models/gen/{payment_method_properties.rb → plugin_property_attributes.rb} +4 -4
  45. data/lib/killbill_client/models/gen/price_attributes.rb +3 -3
  46. data/lib/killbill_client/models/gen/product_attributes.rb +3 -3
  47. data/lib/killbill_client/models/gen/require_gen.rb +12 -6
  48. data/lib/killbill_client/models/gen/session_attributes.rb +3 -3
  49. data/lib/killbill_client/models/gen/stack_trace_element_attributes.rb +3 -3
  50. data/lib/killbill_client/models/gen/subject_attributes.rb +3 -3
  51. data/lib/killbill_client/models/gen/subscription_attributes.rb +3 -3
  52. data/lib/killbill_client/models/gen/tag_attributes.rb +3 -3
  53. data/lib/killbill_client/models/gen/tag_definition_attributes.rb +3 -3
  54. data/lib/killbill_client/models/gen/tenant_attributes.rb +3 -3
  55. data/lib/killbill_client/models/gen/tenant_key_attributes.rb +3 -3
  56. data/lib/killbill_client/models/gen/usage_attributes.rb +3 -3
  57. data/lib/killbill_client/models/helpers/custom_field_helper.rb +51 -0
  58. data/lib/killbill_client/models/helpers/tag_helper.rb +112 -0
  59. data/lib/killbill_client/models/invoice.rb +30 -13
  60. data/lib/killbill_client/models/invoice_item.rb +37 -5
  61. data/lib/killbill_client/models/invoice_payment.rb +67 -0
  62. data/lib/killbill_client/models/models.rb +10 -2
  63. data/lib/killbill_client/models/payment.rb +5 -32
  64. data/lib/killbill_client/models/payment_method.rb +5 -6
  65. data/lib/killbill_client/models/phase.rb +9 -0
  66. data/lib/killbill_client/models/plan.rb +9 -0
  67. data/lib/killbill_client/models/plan_detail.rb +9 -0
  68. data/lib/killbill_client/models/product.rb +9 -0
  69. data/lib/killbill_client/models/resource.rb +22 -5
  70. data/lib/killbill_client/models/subscription.rb +28 -30
  71. data/lib/killbill_client/models/tag.rb +7 -11
  72. data/lib/killbill_client/models/tag_definition.rb +27 -6
  73. data/lib/killbill_client/models/transaction.rb +104 -0
  74. data/lib/killbill_client/version.rb +1 -1
  75. data/spec/killbill_client/remote/api_spec.rb +1 -1
  76. data/spec/killbill_client/remote/model_spec.rb +38 -23
  77. data/spec/killbill_client/resource_spec.rb +18 -0
  78. data/spec/spec_helper.rb +12 -0
  79. metadata +36 -19
  80. data/lib/killbill_client/models/chargeback.rb +0 -36
  81. data/lib/killbill_client/models/refund.rb +0 -55
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe KillBillClient::Model do
4
- it 'should manipulate accounts' do
4
+ it 'should manipulate accounts', :integration => true do
5
5
  # In case the remote server has lots of data
6
6
  search_limit = 100000
7
7
 
@@ -28,6 +28,7 @@ describe KillBillClient::Model do
28
28
  account = account.create('KillBill Spec test')
29
29
  account.external_key.should == external_key
30
30
  account.account_id.should_not be_nil
31
+ account_id = account.account_id
31
32
 
32
33
  # Try to retrieve it
33
34
  account = KillBillClient::Model::Account.find_by_id account.account_id
@@ -92,11 +93,12 @@ describe KillBillClient::Model do
92
93
  # Add a payment method
93
94
  pm = KillBillClient::Model::PaymentMethod.new
94
95
  pm.account_id = account.account_id
96
+ pm.is_default = true
95
97
  pm.plugin_name = '__EXTERNAL_PAYMENT__'
96
98
  pm.plugin_info = {}
97
99
  pm.payment_method_id.should be_nil
98
100
 
99
- pm = pm.create(true, 'KillBill Spec test')
101
+ pm = pm.create('KillBill Spec test')
100
102
  pm.payment_method_id.should_not be_nil
101
103
 
102
104
  # Try to retrieve it
@@ -133,7 +135,8 @@ describe KillBillClient::Model do
133
135
  invoice_item.currency = account.currency
134
136
  invoice_item.amount = 123.98
135
137
 
136
- invoice = invoice_item.create 'KillBill Spec test'
138
+ invoice_item = invoice_item.create 'KillBill Spec test'
139
+ invoice = KillBillClient::Model::Invoice.find_by_id_or_number invoice_item.invoice_id
137
140
 
138
141
  invoice.balance.should == 123.98
139
142
 
@@ -168,10 +171,10 @@ describe KillBillClient::Model do
168
171
  invoice_with_id.invoice_id.should == invoice_with_number.invoice_id
169
172
  invoice_with_id.invoice_number.should == invoice_with_number.invoice_number
170
173
 
171
- # Create an external payment
172
- payment = KillBillClient::Model::Payment.new
173
- payment.account_id = account.account_id
174
- payment.create true, 'KillBill Spec test'
174
+ # Create an external payment for each unpaid invoice
175
+ invoice_payment = KillBillClient::Model::InvoicePayment.new
176
+ invoice_payment.account_id = account.account_id
177
+ invoice_payment.bulk_create true, 'KillBill Spec test'
175
178
 
176
179
  # Try to retrieve it
177
180
  payments = KillBillClient::Model::Payment.find_in_batches(0, search_limit)
@@ -188,11 +191,13 @@ describe KillBillClient::Model do
188
191
  found.should_not be_nil
189
192
 
190
193
  # Try to retrieve it (bis repetita placent)
191
- payment = KillBillClient::Model::Payment.find_by_id found.payment_id
192
- payment.account_id.should == account.account_id
194
+ invoice_payment = KillBillClient::Model::InvoicePayment.find_by_id found.payment_id
195
+ invoice_payment.account_id.should == account.account_id
193
196
 
194
197
  # Try to retrieve it
195
- payments = KillBillClient::Model::Payment.find_all_by_invoice_id found.invoice_id
198
+ invoice = KillBillClient::Model::Invoice.new
199
+ invoice.invoice_id = invoice_payment.target_invoice_id
200
+ payments = invoice.payments
196
201
  payments.size.should == 1
197
202
  payments.first.account_id.should == account.account_id
198
203
 
@@ -203,27 +208,31 @@ describe KillBillClient::Model do
203
208
  # Verify the timeline
204
209
  timeline = KillBillClient::Model::AccountTimeline.find_by_account_id account.account_id
205
210
  timeline.payments.should_not be_empty
206
- payment = timeline.payments.first
207
- payment.refunds.should be_empty
211
+ invoice_payment = timeline.payments.first
212
+ timeline.payments.first.transactions.size.should == 1
213
+ timeline.payments.first.transactions.first.transaction_type.should == 'PURCHASE'
214
+ invoice_payment.auth_amount.should == 0
215
+ invoice_payment.captured_amount.should == 0
216
+ invoice_payment.purchased_amount.should == invoice_payment.purchased_amount
217
+ invoice_payment.refunded_amount.should == 0
218
+ invoice_payment.credited_amount.should == 0
208
219
 
209
220
  # Refund the payment (with item adjustment)
210
221
  invoice_item = KillBillClient::Model::Invoice.find_by_id_or_number(invoice_number, true).items.first
211
- refund = KillBillClient::Model::Refund.new
212
- refund.payment_id = payment.payment_id
213
- refund.amount = payment.amount
214
- refund.adjusted = true
215
222
  item = KillBillClient::Model::InvoiceItem.new
216
223
  item.invoice_item_id = invoice_item.invoice_item_id
217
224
  item.amount = invoice_item.amount
218
- refund.adjustments = [item]
219
- refund.create 'KillBill Spec test'
225
+ refund = KillBillClient::Model::InvoicePayment.refund invoice_payment.payment_id, invoice_payment.purchased_amount, [item], 'KillBill Spec test'
220
226
 
221
227
  # Verify the refund
222
228
  timeline = KillBillClient::Model::AccountTimeline.find_by_account_id account.account_id
223
229
  timeline.payments.should_not be_empty
224
- payment = timeline.payments.first
225
- payment.refunds.should_not be_empty
226
- payment.refunds.first.amount.should == invoice_item.amount
230
+ timeline.payments.size.should == 1
231
+ timeline.payments.first.transactions.size.should == 2
232
+ timeline.payments.first.transactions.first.transaction_type.should == 'PURCHASE'
233
+ refund = timeline.payments.first.transactions.last
234
+ refund.transaction_type.should == 'REFUND'
235
+ refund.amount.should == invoice_item.amount
227
236
 
228
237
  # Create a credit for invoice
229
238
  new_credit = KillBillClient::Model::Credit.new
@@ -291,8 +300,8 @@ describe KillBillClient::Model do
291
300
  found_tag_definition.is_control_tag.should be_false
292
301
  end
293
302
 
294
- it 'should manipulate tenants' do
295
- api_key = Time.now.to_i.to_s
303
+ it 'should manipulate tenants', :integration => true do
304
+ api_key = Time.now.to_i.to_s + Random.rand(100).to_s
296
305
  api_secret = 'S4cr3333333t!!!!!!lolz'
297
306
 
298
307
  tenant = KillBillClient::Model::Tenant.new
@@ -313,6 +322,12 @@ describe KillBillClient::Model do
313
322
  tenant.api_key.should == api_key
314
323
  end
315
324
 
325
+ it 'should manipulate the catalog', :integration => true do
326
+ plans = KillBillClient::Model::Catalog::available_base_plans
327
+ plans.size.should > 0
328
+ plans[0].plan.should_not be_nil
329
+ end
330
+
316
331
  #it 'should retrieve users permissions' do
317
332
  # # Tough to verify as it depends on the Kill Bill configuration
318
333
  # puts KillBillClient::Model::Security.find_permissions
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe KillBillClient::Model::Resource do
4
+
5
+ it 'should be able to be instantiated from hash' do
6
+ payment1 = KillBillClient::Model::InvoicePayment.new
7
+ payment1.account_id = '1234'
8
+ payment1.target_invoice_id = '5678'
9
+ payment1.purchased_amount = 12.42
10
+
11
+ payment2 = KillBillClient::Model::InvoicePayment.new(payment1.to_hash)
12
+
13
+ payment2.should == payment1
14
+ payment2.account_id.should == '1234'
15
+ payment2.target_invoice_id.should == '5678'
16
+ payment2.purchased_amount.should == 12.42
17
+ end
18
+ end
data/spec/spec_helper.rb CHANGED
@@ -11,10 +11,22 @@ KillBillClient.url = 'http://127.0.0.1:8080'
11
11
  KillBillClient.username = 'admin'
12
12
  KillBillClient.password = 'password'
13
13
 
14
+
14
15
  RSpec.configure do |config|
15
16
  config.color_enabled = true
16
17
  config.tty = true
17
18
  config.formatter = 'documentation'
19
+
20
+ config.before(:each, :integration => true) do
21
+ # Setup a tenant for that test
22
+ KillBillClient.api_key = Time.now.to_i.to_s + Random.rand(100).to_s
23
+ KillBillClient.api_secret = 'S4cr3333333t!!!!!!lolz'
24
+
25
+ tenant = KillBillClient::Model::Tenant.new
26
+ tenant.api_key = KillBillClient.api_key
27
+ tenant.api_secret = KillBillClient.api_secret
28
+ tenant.create('KillBill Spec test')
29
+ end
18
30
  end
19
31
 
20
32
  begin
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
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-04-06 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 10.0.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 10.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.12.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.12.0
55
55
  description: An API client library for Kill Bill.
@@ -58,8 +58,8 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - .gitignore
62
- - .travis.yml
61
+ - ".gitignore"
62
+ - ".travis.yml"
63
63
  - Gemfile
64
64
  - README.md
65
65
  - Rakefile
@@ -73,7 +73,7 @@ files:
73
73
  - lib/killbill_client/models/account_timeline.rb
74
74
  - lib/killbill_client/models/audit_log.rb
75
75
  - lib/killbill_client/models/bundle.rb
76
- - lib/killbill_client/models/chargeback.rb
76
+ - lib/killbill_client/models/catalog.rb
77
77
  - lib/killbill_client/models/credit.rb
78
78
  - lib/killbill_client/models/custom_field.rb
79
79
  - lib/killbill_client/models/event_subscription.rb
@@ -85,27 +85,35 @@ files:
85
85
  - lib/killbill_client/models/gen/bundle_attributes.rb
86
86
  - lib/killbill_client/models/gen/bundle_timeline_attributes.rb
87
87
  - lib/killbill_client/models/gen/catalog_attributes_simple.rb
88
- - lib/killbill_client/models/gen/chargeback_attributes.rb
89
88
  - lib/killbill_client/models/gen/credit_attributes.rb
90
89
  - lib/killbill_client/models/gen/custom_field_attributes.rb
91
90
  - lib/killbill_client/models/gen/deleted_event_subscription_attributes.rb
91
+ - lib/killbill_client/models/gen/direct_payment_attributes.rb
92
+ - lib/killbill_client/models/gen/direct_transaction_attributes.rb
92
93
  - lib/killbill_client/models/gen/event_subscription_attributes.rb
94
+ - lib/killbill_client/models/gen/gateway_notification_attributes.rb
95
+ - lib/killbill_client/models/gen/hosted_payment_page_billing_address_attributes.rb
96
+ - lib/killbill_client/models/gen/hosted_payment_page_customer_attributes.rb
97
+ - lib/killbill_client/models/gen/hosted_payment_page_fields_attributes.rb
98
+ - lib/killbill_client/models/gen/hosted_payment_page_form_descriptor_attributes.rb
93
99
  - lib/killbill_client/models/gen/invoice_attributes.rb
94
100
  - lib/killbill_client/models/gen/invoice_email_attributes.rb
95
101
  - lib/killbill_client/models/gen/invoice_item_attributes.rb
102
+ - lib/killbill_client/models/gen/invoice_payment_attributes.rb
103
+ - lib/killbill_client/models/gen/invoice_payment_transaction_attributes.rb
96
104
  - lib/killbill_client/models/gen/new_event_subscription_attributes.rb
97
105
  - lib/killbill_client/models/gen/notification_attributes.rb
98
106
  - lib/killbill_client/models/gen/overdue_state_attributes.rb
99
107
  - lib/killbill_client/models/gen/payment_attributes.rb
100
108
  - lib/killbill_client/models/gen/payment_method_attributes.rb
101
109
  - lib/killbill_client/models/gen/payment_method_plugin_detail_attributes.rb
102
- - lib/killbill_client/models/gen/payment_method_properties.rb
110
+ - lib/killbill_client/models/gen/payment_transaction_attributes.rb
103
111
  - lib/killbill_client/models/gen/phase_attributes.rb
104
112
  - lib/killbill_client/models/gen/plan_attributes.rb
105
113
  - lib/killbill_client/models/gen/plan_detail_attributes.rb
114
+ - lib/killbill_client/models/gen/plugin_property_attributes.rb
106
115
  - lib/killbill_client/models/gen/price_attributes.rb
107
116
  - lib/killbill_client/models/gen/product_attributes.rb
108
- - lib/killbill_client/models/gen/refund_attributes.rb
109
117
  - lib/killbill_client/models/gen/require_gen.rb
110
118
  - lib/killbill_client/models/gen/session_attributes.rb
111
119
  - lib/killbill_client/models/gen/stack_trace_element_attributes.rb
@@ -116,12 +124,18 @@ files:
116
124
  - lib/killbill_client/models/gen/tenant_attributes.rb
117
125
  - lib/killbill_client/models/gen/tenant_key_attributes.rb
118
126
  - lib/killbill_client/models/gen/usage_attributes.rb
127
+ - lib/killbill_client/models/helpers/custom_field_helper.rb
128
+ - lib/killbill_client/models/helpers/tag_helper.rb
119
129
  - lib/killbill_client/models/invoice.rb
120
130
  - lib/killbill_client/models/invoice_item.rb
131
+ - lib/killbill_client/models/invoice_payment.rb
121
132
  - lib/killbill_client/models/models.rb
122
133
  - lib/killbill_client/models/payment.rb
123
134
  - lib/killbill_client/models/payment_method.rb
124
- - lib/killbill_client/models/refund.rb
135
+ - lib/killbill_client/models/phase.rb
136
+ - lib/killbill_client/models/plan.rb
137
+ - lib/killbill_client/models/plan_detail.rb
138
+ - lib/killbill_client/models/product.rb
125
139
  - lib/killbill_client/models/resource.rb
126
140
  - lib/killbill_client/models/resources.rb
127
141
  - lib/killbill_client/models/security.rb
@@ -129,6 +143,7 @@ files:
129
143
  - lib/killbill_client/models/tag.rb
130
144
  - lib/killbill_client/models/tag_definition.rb
131
145
  - lib/killbill_client/models/tenant.rb
146
+ - lib/killbill_client/models/transaction.rb
132
147
  - lib/killbill_client/models/usage.rb
133
148
  - lib/killbill_client/utils.rb
134
149
  - lib/killbill_client/version.rb
@@ -137,6 +152,7 @@ files:
137
152
  - spec/killbill_client/model_relation_spec.rb
138
153
  - spec/killbill_client/remote/api_spec.rb
139
154
  - spec/killbill_client/remote/model_spec.rb
155
+ - spec/killbill_client/resource_spec.rb
140
156
  - spec/killbill_client/resources_spec.rb
141
157
  - spec/spec_helper.rb
142
158
  homepage: http://www.killbilling.org
@@ -145,18 +161,18 @@ licenses:
145
161
  metadata: {}
146
162
  post_install_message:
147
163
  rdoc_options:
148
- - --exclude
149
- - .
164
+ - "--exclude"
165
+ - "."
150
166
  require_paths:
151
167
  - lib
152
168
  required_ruby_version: !ruby/object:Gem::Requirement
153
169
  requirements:
154
- - - ! '>='
170
+ - - ">="
155
171
  - !ruby/object:Gem::Version
156
172
  version: 1.8.6
157
173
  required_rubygems_version: !ruby/object:Gem::Requirement
158
174
  requirements:
159
- - - ! '>='
175
+ - - ">="
160
176
  - !ruby/object:Gem::Version
161
177
  version: '0'
162
178
  requirements: []
@@ -169,5 +185,6 @@ test_files:
169
185
  - spec/killbill_client/model_relation_spec.rb
170
186
  - spec/killbill_client/remote/api_spec.rb
171
187
  - spec/killbill_client/remote/model_spec.rb
188
+ - spec/killbill_client/resource_spec.rb
172
189
  - spec/killbill_client/resources_spec.rb
173
190
  - spec/spec_helper.rb
@@ -1,36 +0,0 @@
1
- module KillBillClient
2
- module Model
3
- class Chargeback < ChargebackAttributes
4
- has_many :audit_logs, KillBillClient::Model::AuditLog
5
-
6
- KILLBILL_API_CHARGEBACKS_PREFIX = "#{KILLBILL_API_PREFIX}/chargebacks"
7
-
8
- class << self
9
- def find_by_id(chargeback_id, options = {})
10
- get "#{KILLBILL_API_CHARGEBACKS_PREFIX}/#{chargeback_id}",
11
- {},
12
- options
13
- end
14
-
15
- def find_all_by_payment_id(payment_id, options = {})
16
- get "#{Payment::KILLBILL_API_PAYMENTS_PREFIX}/#{payment_id}/chargebacks",
17
- {},
18
- options
19
- end
20
- end
21
-
22
- def create(user = nil, reason = nil, comment = nil, options = {})
23
- created_chargeback = self.class.post KILLBILL_API_CHARGEBACKS_PREFIX,
24
- to_json,
25
- {},
26
- {
27
- :user => user,
28
- :reason => reason,
29
- :comment => comment,
30
- }.merge(options)
31
- created_chargeback.refresh(options)
32
- end
33
-
34
- end
35
- end
36
- end
@@ -1,55 +0,0 @@
1
- module KillBillClient
2
- module Model
3
- class Refund < RefundAttributes
4
- KILLBILL_API_REFUNDS_PREFIX = "#{KILLBILL_API_PREFIX}/refunds"
5
-
6
- has_many :audit_logs, KillBillClient::Model::AuditLog
7
- has_many :adjustments, KillBillClient::Model::InvoiceItem
8
-
9
- class << self
10
- def find_by_id refund_id, options = {}
11
- get "#{KILLBILL_API_REFUNDS_PREFIX}/#{refund_id}",
12
- {},
13
- options
14
- end
15
-
16
- def find_all_by_payment_id payment_id, options = {}
17
- get "#{Payment::KILLBILL_API_PAYMENTS_PREFIX}/#{payment_id}/refunds",
18
- {},
19
- options
20
- end
21
-
22
- def find_in_batches(offset = 0, limit = 100, options = {})
23
- get "#{KILLBILL_API_REFUNDS_PREFIX}/#{Resource::KILLBILL_API_PAGINATION_PREFIX}",
24
- {
25
- :offset => offset,
26
- :limit => limit
27
- },
28
- options
29
- end
30
-
31
- def find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {})
32
- get "#{KILLBILL_API_REFUNDS_PREFIX}/search/#{search_key}",
33
- {
34
- :offset => offset,
35
- :limit => limit
36
- },
37
- options
38
- end
39
- end
40
-
41
- def create(user = nil, reason = nil, comment = nil, options = {})
42
- created_refund = self.class.post "#{Payment::KILLBILL_API_PAYMENTS_PREFIX}/#{@payment_id}/refunds",
43
- to_json,
44
- {},
45
- {
46
- :user => user,
47
- :reason => reason,
48
- :comment => comment,
49
- }.merge(options)
50
-
51
- created_refund.refresh(options)
52
- end
53
- end
54
- end
55
- end