killbill-client 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -12
  3. data/killbill_client.gemspec +1 -1
  4. data/lib/killbill_client/api/net_http_adapter.rb +10 -3
  5. data/lib/killbill_client/models/account.rb +13 -0
  6. data/lib/killbill_client/models/bundle.rb +8 -3
  7. data/lib/killbill_client/models/catalog.rb +26 -5
  8. data/lib/killbill_client/models/gen/account_attributes.rb +3 -0
  9. data/lib/killbill_client/models/gen/bulk_base_subscription_and_add_ons_attributes.rb +34 -0
  10. data/lib/killbill_client/models/gen/invoice_attributes.rb +2 -0
  11. data/lib/killbill_client/models/gen/invoice_item_attributes.rb +2 -0
  12. data/lib/killbill_client/models/gen/invoice_payment_attributes.rb +1 -0
  13. data/lib/killbill_client/models/gen/limit_attributes.rb +36 -0
  14. data/lib/killbill_client/models/gen/overdue_attributes.rb +35 -0
  15. data/lib/killbill_client/models/gen/overdue_condition_attributes.rb +39 -0
  16. data/lib/killbill_client/models/gen/overdue_state_config_attributes.rb +41 -0
  17. data/lib/killbill_client/models/gen/payment_attempt_attributes.rb +46 -0
  18. data/lib/killbill_client/models/gen/payment_attributes.rb +1 -0
  19. data/lib/killbill_client/models/gen/phase_attributes.rb +1 -0
  20. data/lib/killbill_client/models/gen/require_gen.rb +10 -0
  21. data/lib/killbill_client/models/gen/simple_plan_attributes.rb +42 -0
  22. data/lib/killbill_client/models/gen/subscription_attributes.rb +1 -0
  23. data/lib/killbill_client/models/gen/tier_attributes.rb +37 -0
  24. data/lib/killbill_client/models/gen/tiered_block_attributes.rb +37 -0
  25. data/lib/killbill_client/models/gen/usage_attributes.rb +35 -0
  26. data/lib/killbill_client/models/invoice.rb +20 -6
  27. data/lib/killbill_client/models/invoice_item.rb +2 -2
  28. data/lib/killbill_client/models/invoice_payment.rb +3 -1
  29. data/lib/killbill_client/models/models.rb +2 -0
  30. data/lib/killbill_client/models/overdue.rb +22 -8
  31. data/lib/killbill_client/models/overdue_condition.rb +10 -0
  32. data/lib/killbill_client/models/overdue_state_config.rb +10 -0
  33. data/lib/killbill_client/models/payment.rb +5 -2
  34. data/lib/killbill_client/models/payment_method.rb +13 -4
  35. data/lib/killbill_client/models/phase.rb +2 -1
  36. data/lib/killbill_client/models/resource.rb +16 -19
  37. data/lib/killbill_client/models/resources.rb +2 -2
  38. data/lib/killbill_client/models/tenant.rb +19 -5
  39. data/lib/killbill_client/models/transaction.rb +20 -2
  40. data/lib/killbill_client/version.rb +1 -1
  41. data/spec/killbill_client/{encoding_spec.rb → http_adapter_spec.rb} +21 -0
  42. data/spec/killbill_client/remote/model_spec.rb +19 -21
  43. data/spec/spec_helper.rb +1 -1
  44. metadata +53 -44
@@ -40,6 +40,7 @@ module KillBillClient
40
40
  attribute :currency
41
41
  attribute :payment_method_id
42
42
  attribute :transactions
43
+ attribute :payment_attempts
43
44
  attribute :audit_logs
44
45
  end
45
46
  end
@@ -32,6 +32,7 @@ module KillBillClient
32
32
  attribute :prices
33
33
  attribute :fixed_prices
34
34
  attribute :duration
35
+ attribute :usages
35
36
  end
36
37
  end
37
38
  end
@@ -33,10 +33,15 @@ require 'killbill_client/models/gen/audit_log_attributes'
33
33
  require 'killbill_client/models/gen/stack_trace_element_attributes'
34
34
  require 'killbill_client/models/gen/billing_exception_attributes'
35
35
  require 'killbill_client/models/gen/blocking_state_attributes'
36
+ require 'killbill_client/models/gen/bulk_base_subscription_and_add_ons_attributes'
36
37
  require 'killbill_client/models/gen/bundle_attributes'
37
38
  require 'killbill_client/models/gen/bundle_timeline_attributes'
38
39
  require 'killbill_client/models/gen/product_attributes'
39
40
  require 'killbill_client/models/gen/plan_attributes'
41
+ require 'killbill_client/models/gen/tiered_block_attributes'
42
+ require 'killbill_client/models/gen/limit_attributes'
43
+ require 'killbill_client/models/gen/tier_attributes'
44
+ require 'killbill_client/models/gen/usage_attributes'
40
45
  require 'killbill_client/models/gen/phase_attributes'
41
46
  require 'killbill_client/models/gen/price_attributes'
42
47
  require 'killbill_client/models/gen/price_list_attributes'
@@ -61,7 +66,11 @@ require 'killbill_client/models/gen/node_command_attributes'
61
66
  require 'killbill_client/models/gen/node_command_property_attributes'
62
67
  require 'killbill_client/models/gen/node_info_attributes'
63
68
  require 'killbill_client/models/gen/notification_attributes'
69
+ require 'killbill_client/models/gen/overdue_condition_attributes'
70
+ require 'killbill_client/models/gen/overdue_attributes'
71
+ require 'killbill_client/models/gen/overdue_state_config_attributes'
64
72
  require 'killbill_client/models/gen/overdue_state_attributes'
73
+ require 'killbill_client/models/gen/payment_attempt_attributes'
65
74
  require 'killbill_client/models/gen/payment_attributes'
66
75
  require 'killbill_client/models/gen/payment_method_plugin_detail_attributes'
67
76
  require 'killbill_client/models/gen/payment_method_attributes'
@@ -77,6 +86,7 @@ require 'killbill_client/models/gen/role_definition_attributes'
77
86
  require 'killbill_client/models/gen/rolled_up_unit_attributes'
78
87
  require 'killbill_client/models/gen/rolled_up_usage_attributes'
79
88
  require 'killbill_client/models/gen/session_attributes'
89
+ require 'killbill_client/models/gen/simple_plan_attributes'
80
90
  require 'killbill_client/models/gen/subject_attributes'
81
91
  require 'killbill_client/models/gen/event_subscription_attributes'
82
92
  require 'killbill_client/models/gen/subscription_attributes'
@@ -0,0 +1,42 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class SimplePlanAttributes < Resource
31
+ attribute :plan_id
32
+ attribute :product_name
33
+ attribute :product_category
34
+ attribute :currency
35
+ attribute :amount
36
+ attribute :billing_period
37
+ attribute :trial_length
38
+ attribute :trial_time_unit
39
+ attribute :available_base_products
40
+ end
41
+ end
42
+ end
@@ -38,6 +38,7 @@ module KillBillClient
38
38
  attribute :billing_period
39
39
  attribute :phase_type
40
40
  attribute :price_list
41
+ attribute :plan_name
41
42
  attribute :state
42
43
  attribute :source_type
43
44
  attribute :cancelled_date
@@ -0,0 +1,37 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class TierAttributes < Resource
31
+ attribute :tiers
32
+ attribute :limits
33
+ attribute :fixed_price
34
+ attribute :recurring_price
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class TieredBlockAttributes < Resource
31
+ attribute :unit
32
+ attribute :size
33
+ attribute :max
34
+ attribute :prices
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,35 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class UsageAttributes < Resource
31
+ attribute :billing_period
32
+ attribute :tiers
33
+ end
34
+ end
35
+ end
@@ -68,7 +68,7 @@ module KillBillClient
68
68
 
69
69
  res.refresh(options)
70
70
 
71
- rescue KillBillClient::API::BadRequest => e
71
+ rescue KillBillClient::API::BadRequest
72
72
  # No invoice to generate : TODO parse json to verify this is indeed the case
73
73
  end
74
74
  end
@@ -94,7 +94,7 @@ module KillBillClient
94
94
 
95
95
  res.refresh(options)
96
96
 
97
- rescue KillBillClient::API::NotFound => e
97
+ rescue KillBillClient::API::NotFound
98
98
  nil
99
99
  end
100
100
  end
@@ -126,7 +126,7 @@ module KillBillClient
126
126
  Invoice
127
127
 
128
128
  res.refresh(options)
129
- rescue KillBillClient::API::NotFound => e
129
+ rescue KillBillClient::API::NotFound
130
130
  nil
131
131
  end
132
132
  end
@@ -160,7 +160,7 @@ module KillBillClient
160
160
  Invoice
161
161
 
162
162
  res.refresh(options)
163
- rescue KillBillClient::API::NotFound => e
163
+ rescue KillBillClient::API::NotFound
164
164
  nil
165
165
  end
166
166
  end
@@ -193,7 +193,7 @@ module KillBillClient
193
193
 
194
194
  res.refresh(options)
195
195
 
196
- rescue KillBillClient::API::NotFound => e
196
+ rescue KillBillClient::API::NotFound
197
197
  nil
198
198
  end
199
199
  end
@@ -301,9 +301,23 @@ module KillBillClient
301
301
 
302
302
  end
303
303
 
304
- def payments(with_plugin_info = false, audit = 'NONE', options = {})
304
+ def commit(user = nil, reason = nil, comment = nil, options = {})
305
+
306
+ self.class.put "#{Invoice::KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/commitInvoice",
307
+ nil,
308
+ {},
309
+ {
310
+ :user => user,
311
+ :reason => reason,
312
+ :comment => comment,
313
+ }.merge(options)
314
+
315
+ end
316
+
317
+ def payments(with_plugin_info = false, with_attempts = false, audit = 'NONE', options = {})
305
318
  self.class.get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/payments",
306
319
  {
320
+ :withAttempts => with_attempts,
307
321
  :withPluginInfo => with_plugin_info,
308
322
  :audit => audit
309
323
  },
@@ -4,10 +4,10 @@ module KillBillClient
4
4
 
5
5
  has_many :audit_logs, KillBillClient::Model::AuditLog
6
6
 
7
- def create(user = nil, reason = nil, comment = nil, options = {})
7
+ def create(auto_commit = false, user = nil, reason = nil, comment = nil, options = {})
8
8
  created_invoice_item = self.class.post "#{Invoice::KILLBILL_API_INVOICES_PREFIX}/charges/#{account_id}",
9
9
  [to_hash].to_json,
10
- {},
10
+ {:autoCommit => auto_commit},
11
11
  {
12
12
  :user => user,
13
13
  :reason => reason,
@@ -4,12 +4,14 @@ module KillBillClient
4
4
  KILLBILL_API_INVOICE_PAYMENTS_PREFIX = "#{KILLBILL_API_PREFIX}/invoicePayments"
5
5
 
6
6
  has_many :transactions, KillBillClient::Model::Transaction
7
+ has_many :payment_attempts, KillBillClient::Model::PaymentAttemptAttributes
7
8
  has_many :audit_logs, KillBillClient::Model::AuditLog
8
9
 
9
10
  class << self
10
- def find_by_id(payment_id, with_plugin_info = false, options = {})
11
+ def find_by_id(payment_id, with_plugin_info = false, with_attempts = false, options = {})
11
12
  get "#{KILLBILL_API_INVOICE_PAYMENTS_PREFIX}/#{payment_id}",
12
13
  {
14
+ :withAttempts => with_attempts,
13
15
  :withPluginInfo => with_plugin_info
14
16
  },
15
17
  options
@@ -20,6 +20,8 @@ require 'killbill_client/models/subscription'
20
20
  require 'killbill_client/models/bundle'
21
21
  require 'killbill_client/models/account'
22
22
  require 'killbill_client/models/invoice'
23
+ require 'killbill_client/models/overdue_condition'
24
+ require 'killbill_client/models/overdue_state_config'
23
25
  require 'killbill_client/models/overdue'
24
26
  require 'killbill_client/models/transaction'
25
27
  require 'killbill_client/models/combo_transaction'
@@ -1,38 +1,52 @@
1
1
  module KillBillClient
2
2
  module Model
3
- class Overdue < OverdueStateAttributes
3
+ class Overdue < OverdueAttributes
4
+
5
+ has_many :overdue_states, KillBillClient::Model::OverdueStateConfig
4
6
 
5
7
  KILLBILL_API_OVERDUE_PREFIX = "#{KILLBILL_API_PREFIX}/overdue"
6
8
 
7
9
  class << self
8
- def get_tenant_overdue_config(options = {})
10
+
11
+ def get_tenant_overdue_config(format, options = {})
9
12
 
10
13
  require_multi_tenant_options!(options, "Retrieving an overdue config is only supported in multi-tenant mode")
11
14
 
12
15
  get KILLBILL_API_OVERDUE_PREFIX,
13
16
  {},
14
17
  {
15
- :head => {'Accept' => 'application/xml'},
18
+ :head => {'Accept' => "application/#{format}"},
19
+ :content_type => "application/#{format}",
16
20
  }.merge(options)
17
21
  end
18
22
 
19
- def upload_tenant_overdue_config(overdue_config_xml, user = nil, reason = nil, comment = nil, options = {})
23
+ def upload_tenant_overdue_config_xml(overdue_config_xml, user = nil, reason = nil, comment = nil, options = {})
24
+ upload_tenant_overdue_config('xml', overdue_config_xml, user, reason, comment, options)
25
+ end
26
+
27
+
28
+ def upload_tenant_overdue_config(format, body, user = nil, reason = nil, comment = nil, options = {})
20
29
 
21
30
  require_multi_tenant_options!(options, "Uploading an overdue config is only supported in multi-tenant mode")
22
31
 
23
32
  post KILLBILL_API_OVERDUE_PREFIX,
24
- overdue_config_xml,
33
+ body,
25
34
  {
26
35
  },
27
36
  {
28
- :head => {'Accept' => 'application/xml'},
29
- :content_type => 'application/xml',
37
+ :head => {'Accept' => "application/#{format}"},
38
+ :content_type => "application/#{format}",
30
39
  :user => user,
31
40
  :reason => reason,
32
41
  :comment => comment,
33
42
  }.merge(options)
34
- get_tenant_overdue_config(options)
43
+ get_tenant_overdue_config(format, options)
35
44
  end
45
+
46
+ end
47
+
48
+ def upload_tenant_overdue_config_json(user = nil, reason = nil, comment = nil, options = {})
49
+ self.class.upload_tenant_overdue_config('json', to_json, user, reason, comment, options)
36
50
  end
37
51
  end
38
52
  end
@@ -0,0 +1,10 @@
1
+ module KillBillClient
2
+ module Model
3
+ class OverdueCondition < OverdueConditionAttributes
4
+
5
+ has_one :time_since_earliest_unpaid_invoice_equals_or_exceeds, KillBillClient::Model::DurationAttributes
6
+
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,10 @@
1
+ module KillBillClient
2
+ module Model
3
+ class OverdueStateConfig < OverdueStateConfigAttributes
4
+
5
+ has_one :condition, KillBillClient::Model::OverdueCondition
6
+
7
+ end
8
+ end
9
+ end
10
+
@@ -7,23 +7,26 @@ module KillBillClient
7
7
  KILLBILL_API_PAYMENTS_PREFIX = "#{KILLBILL_API_PREFIX}/payments"
8
8
 
9
9
  has_many :transactions, KillBillClient::Model::Transaction
10
+ has_many :payment_attempts, KillBillClient::Model::PaymentAttemptAttributes
10
11
  has_many :audit_logs, KillBillClient::Model::AuditLog
11
12
 
12
13
  has_custom_fields KILLBILL_API_PAYMENTS_PREFIX, :payment_id
13
14
 
14
15
  class << self
15
- def find_by_id(payment_id, with_plugin_info = false, options = {})
16
+ def find_by_id(payment_id, with_plugin_info = false, with_attempts = false, options = {})
16
17
  get "#{KILLBILL_API_PAYMENTS_PREFIX}/#{payment_id}",
17
18
  {
19
+ :withAttempts => with_attempts,
18
20
  :withPluginInfo => with_plugin_info
19
21
  },
20
22
  options
21
23
  end
22
24
 
23
- def find_by_external_key(external_key, with_plugin_info = false, options = {})
25
+ def find_by_external_key(external_key, with_plugin_info = false, with_attempts = false, options = {})
24
26
  get "#{KILLBILL_API_PAYMENTS_PREFIX}",
25
27
  {
26
28
  :externalKey => external_key,
29
+ :withAttempts => with_attempts,
27
30
  :withPluginInfo => with_plugin_info
28
31
  },
29
32
  options
@@ -52,10 +52,11 @@ module KillBillClient
52
52
  }.merge(options)
53
53
  end
54
54
 
55
- def destroy(payment_method_id, set_auto_pay_off = false, user = nil, reason = nil, comment = nil, options = {})
55
+ def destroy(payment_method_id, set_auto_pay_off = false, force_default_deletion = false, user = nil, reason = nil, comment = nil, options = {})
56
56
  delete "#{KILLBILL_API_PAYMENT_METHODS_PREFIX}/#{payment_method_id}",
57
57
  {},
58
58
  {
59
+ :forceDefaultPmDeletion => force_default_deletion,
59
60
  :deleteDefaultPmWithAutoPayOff => set_auto_pay_off
60
61
  },
61
62
  {
@@ -64,6 +65,17 @@ module KillBillClient
64
65
  :comment => comment,
65
66
  }.merge(options)
66
67
  end
68
+
69
+ def refresh(account_id, user = nil, reason = nil, comment = nil, options = {})
70
+ post "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/paymentMethods/refresh",
71
+ nil,
72
+ {},
73
+ {
74
+ :user => user,
75
+ :reason => reason,
76
+ :comment => comment,
77
+ }.merge(options)
78
+ end
67
79
  end
68
80
 
69
81
  def create(is_default, user = nil, reason = nil, comment = nil, options = {})
@@ -80,9 +92,6 @@ module KillBillClient
80
92
  created_pm.refresh(options)
81
93
  end
82
94
 
83
- def destroy(set_auto_pay_off = false, user = nil, reason = nil, comment = nil, options = {})
84
- self.class.destroy(payment_method_id, set_auto_pay_off, user, reason, comment, options)
85
- end
86
95
 
87
96
  def plugin_info=(info)
88
97
  @plugin_info = PaymentMethodPluginDetailAttributes.new