killbill-client 2.2.3 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +12 -12
  3. data/lib/killbill_client/models/account.rb +44 -42
  4. data/lib/killbill_client/models/bulk_subscription.rb +1 -1
  5. data/lib/killbill_client/models/bundle.rb +18 -6
  6. data/lib/killbill_client/models/catalog.rb +77 -8
  7. data/lib/killbill_client/models/export.rb +1 -1
  8. data/lib/killbill_client/models/gen/blocking_state_attributes.rb +3 -3
  9. data/lib/killbill_client/models/gen/credit_attributes.rb +1 -0
  10. data/lib/killbill_client/models/gen/invoice_item_attributes.rb +2 -0
  11. data/lib/killbill_client/models/gen/node_command_attributes.rb +1 -1
  12. data/lib/killbill_client/models/gen/overdue_state_attributes.rb +3 -3
  13. data/lib/killbill_client/models/gen/overdue_state_config_attributes.rb +2 -2
  14. data/lib/killbill_client/models/gen/require_gen.rb +53 -54
  15. data/lib/killbill_client/models/gen/stack_trace_element_attributes.rb +1 -1
  16. data/lib/killbill_client/models/gen/{tenant_key_attributes.rb → tenant_key_value_attributes.rb} +1 -1
  17. data/lib/killbill_client/models/helpers/custom_field_helper.rb +21 -0
  18. data/lib/killbill_client/models/helpers/tag_helper.rb +2 -4
  19. data/lib/killbill_client/models/invoice.rb +63 -61
  20. data/lib/killbill_client/models/invoice_item.rb +1 -3
  21. data/lib/killbill_client/models/invoice_payment.rb +18 -3
  22. data/lib/killbill_client/models/nodes_info.rb +1 -1
  23. data/lib/killbill_client/models/overdue.rb +33 -13
  24. data/lib/killbill_client/models/payment_method.rb +1 -1
  25. data/lib/killbill_client/models/resource.rb +3 -1
  26. data/lib/killbill_client/models/subscription.rb +19 -17
  27. data/lib/killbill_client/models/tenant.rb +2 -2
  28. data/lib/killbill_client/models/transaction.rb +2 -0
  29. data/lib/killbill_client/version.rb +2 -2
  30. data/spec/killbill_client/remote/api_spec.rb +1 -1
  31. data/spec/killbill_client/remote/model_spec.rb +6 -6
  32. metadata +3 -3
@@ -31,9 +31,9 @@ module KillBillClient
31
31
  attribute :name
32
32
  attribute :external_message
33
33
  attribute :days_between_payment_retries
34
- attribute :disable_entitlement_and_changes_blocked
35
- attribute :block_changes
36
- attribute :clear_state
34
+ attribute :is_disable_entitlement_and_changes_blocked
35
+ attribute :is_block_changes
36
+ attribute :is_clear_state
37
37
  attribute :reevaluation_interval_days
38
38
  end
39
39
  end
@@ -32,8 +32,8 @@ module KillBillClient
32
32
  attribute :is_clear_state
33
33
  attribute :condition
34
34
  attribute :external_message
35
- attribute :block_changes
36
- attribute :disable_entitlement
35
+ attribute :is_block_changes
36
+ attribute :is_disable_entitlement
37
37
  attribute :subscription_cancellation_policy
38
38
  attribute :auto_reevaluation_interval_days
39
39
  end
@@ -24,40 +24,7 @@
24
24
  # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
25
  #
26
26
 
27
-
28
- require 'killbill_client/models/gen/tenant_attributes'
29
- require 'killbill_client/models/gen/subject_attributes'
30
- require 'killbill_client/models/gen/account_email_attributes'
31
- require 'killbill_client/models/gen/tag_attributes'
32
- require 'killbill_client/models/gen/invoice_attributes'
33
- require 'killbill_client/models/gen/plugin_property_attributes'
34
- require 'killbill_client/models/gen/account_timeline_attributes'
35
- require 'killbill_client/models/gen/overdue_state_attributes'
36
- require 'killbill_client/models/gen/user_roles_attributes'
37
- require 'killbill_client/models/gen/payment_method_plugin_detail_attributes'
38
- require 'killbill_client/models/gen/payment_method_attributes'
39
- require 'killbill_client/models/gen/usage_price_override_attributes'
40
- require 'killbill_client/models/gen/plugin_service_info_attributes'
41
- require 'killbill_client/models/gen/plugin_info_attributes'
42
- require 'killbill_client/models/gen/tag_definition_attributes'
43
- require 'killbill_client/models/gen/account_attributes'
44
- require 'killbill_client/models/gen/hosted_payment_page_form_descriptor_attributes'
45
- require 'killbill_client/models/gen/bulk_subscriptions_bundle_attributes'
46
- require 'killbill_client/models/gen/blocking_state_attributes'
47
- require 'killbill_client/models/gen/invoice_item_attributes'
48
- require 'killbill_client/models/gen/role_definition_attributes'
49
- require 'killbill_client/models/gen/node_command_property_attributes'
50
- require 'killbill_client/models/gen/invoice_payment_transaction_attributes'
51
- require 'killbill_client/models/gen/hosted_payment_page_billing_address_attributes'
52
- require 'killbill_client/models/gen/plan_detail_attributes'
53
- require 'killbill_client/models/gen/custom_field_attributes'
54
- require 'killbill_client/models/gen/tier_price_override_attributes'
55
- require 'killbill_client/models/gen/rolled_up_unit_attributes'
56
- require 'killbill_client/models/gen/rolled_up_usage_attributes'
57
- require 'killbill_client/models/gen/gateway_notification_attributes'
58
- require 'killbill_client/models/gen/event_subscription_attributes'
59
- require 'killbill_client/models/gen/subscription_attributes'
60
- require 'killbill_client/models/gen/notification_attributes'
27
+ require 'killbill_client/models/gen/invoice_dry_run_attributes'
61
28
  require 'killbill_client/models/gen/unit_attributes'
62
29
  require 'killbill_client/models/gen/product_attributes'
63
30
  require 'killbill_client/models/gen/plan_attributes'
@@ -70,35 +37,67 @@ require 'killbill_client/models/gen/price_attributes'
70
37
  require 'killbill_client/models/gen/price_list_attributes'
71
38
  require 'killbill_client/models/gen/duration_attributes'
72
39
  require 'killbill_client/models/gen/catalog_attributes'
73
- require 'killbill_client/models/gen/combo_payment_transaction_attributes'
74
- require 'killbill_client/models/gen/bundle_attributes'
40
+ require 'killbill_client/models/gen/payment_attributes'
41
+ require 'killbill_client/models/gen/tag_definition_attributes'
75
42
  require 'killbill_client/models/gen/payment_transaction_attributes'
43
+ require 'killbill_client/models/gen/bulk_subscriptions_bundle_attributes'
44
+ require 'killbill_client/models/gen/simple_plan_attributes'
45
+ require 'killbill_client/models/gen/node_command_attributes'
46
+ require 'killbill_client/models/gen/hosted_payment_page_customer_attributes'
76
47
  require 'killbill_client/models/gen/invoice_email_attributes'
77
- require 'killbill_client/models/gen/payment_attributes'
48
+ require 'killbill_client/models/gen/invoice_payment_attributes'
49
+ require 'killbill_client/models/gen/stack_trace_element_attributes'
50
+ require 'killbill_client/models/gen/billing_exception_attributes'
51
+ require 'killbill_client/models/gen/usage_price_override_attributes'
52
+ require 'killbill_client/models/gen/tenant_key_value_attributes'
53
+ require 'killbill_client/models/gen/credit_attributes'
54
+ require 'killbill_client/models/gen/account_timeline_attributes'
55
+ require 'killbill_client/models/gen/tag_attributes'
56
+ require 'killbill_client/models/gen/payment_attempt_attributes'
57
+ require 'killbill_client/models/gen/notification_attributes'
58
+ require 'killbill_client/models/gen/overdue_state_attributes'
59
+ require 'killbill_client/models/gen/custom_field_attributes'
60
+ require 'killbill_client/models/gen/role_definition_attributes'
61
+ require 'killbill_client/models/gen/tier_price_override_attributes'
62
+ require 'killbill_client/models/gen/invoice_item_attributes'
63
+ require 'killbill_client/models/gen/plugin_property_attributes'
64
+ require 'killbill_client/models/gen/admin_payment_attributes'
65
+ require 'killbill_client/models/gen/event_subscription_attributes'
66
+ require 'killbill_client/models/gen/subscription_attributes'
67
+ require 'killbill_client/models/gen/tenant_attributes'
78
68
  require 'killbill_client/models/gen/unit_usage_record_attributes'
79
69
  require 'killbill_client/models/gen/usage_record_attributes'
80
70
  require 'killbill_client/models/gen/subscription_usage_record_attributes'
81
- require 'killbill_client/models/gen/overdue_attributes'
82
- require 'killbill_client/models/gen/stack_trace_element_attributes'
83
- require 'killbill_client/models/gen/billing_exception_attributes'
71
+ require 'killbill_client/models/gen/gateway_notification_attributes'
84
72
  require 'killbill_client/models/gen/audit_log_attributes'
73
+ require 'killbill_client/models/gen/invoice_payment_transaction_attributes'
74
+ require 'killbill_client/models/gen/account_attributes'
75
+ require 'killbill_client/models/gen/invoice_attributes'
76
+ require 'killbill_client/models/gen/block_price_override_attributes'
85
77
  require 'killbill_client/models/gen/profiling_data_attributes_item'
86
78
  require 'killbill_client/models/gen/profiling_data_attributes'
87
- require 'killbill_client/models/gen/tenant_key_attributes'
88
- require 'killbill_client/models/gen/node_command_attributes'
89
- require 'killbill_client/models/gen/phase_price_override_attributes'
90
- require 'killbill_client/models/gen/session_attributes'
91
- require 'killbill_client/models/gen/hosted_payment_page_customer_attributes'
92
- require 'killbill_client/models/gen/admin_payment_attributes'
93
- require 'killbill_client/models/gen/bundle_timeline_attributes'
94
- require 'killbill_client/models/gen/invoice_dry_run_attributes'
95
- require 'killbill_client/models/gen/payment_attempt_attributes'
79
+ require 'killbill_client/models/gen/combo_payment_transaction_attributes'
96
80
  require 'killbill_client/models/gen/hosted_payment_page_fields_attributes'
97
- require 'killbill_client/models/gen/invoice_payment_attributes'
98
- require 'killbill_client/models/gen/overdue_state_config_attributes'
99
- require 'killbill_client/models/gen/simple_plan_attributes'
81
+ require 'killbill_client/models/gen/bundle_attributes'
100
82
  require 'killbill_client/models/gen/combo_hosted_payment_page_attributes'
101
- require 'killbill_client/models/gen/credit_attributes'
83
+ require 'killbill_client/models/gen/plan_detail_attributes'
84
+ require 'killbill_client/models/gen/overdue_attributes'
85
+ require 'killbill_client/models/gen/user_roles_attributes'
86
+ require 'killbill_client/models/gen/bundle_timeline_attributes'
87
+ require 'killbill_client/models/gen/plugin_service_info_attributes'
88
+ require 'killbill_client/models/gen/plugin_info_attributes'
89
+ require 'killbill_client/models/gen/phase_price_override_attributes'
90
+ require 'killbill_client/models/gen/hosted_payment_page_form_descriptor_attributes'
91
+ require 'killbill_client/models/gen/blocking_state_attributes'
92
+ require 'killbill_client/models/gen/overdue_state_config_attributes'
93
+ require 'killbill_client/models/gen/node_command_property_attributes'
102
94
  require 'killbill_client/models/gen/overdue_condition_attributes'
103
- require 'killbill_client/models/gen/block_price_override_attributes'
95
+ require 'killbill_client/models/gen/hosted_payment_page_billing_address_attributes'
96
+ require 'killbill_client/models/gen/rolled_up_unit_attributes'
97
+ require 'killbill_client/models/gen/rolled_up_usage_attributes'
98
+ require 'killbill_client/models/gen/session_attributes'
104
99
  require 'killbill_client/models/gen/node_info_attributes'
100
+ require 'killbill_client/models/gen/account_email_attributes'
101
+ require 'killbill_client/models/gen/payment_method_plugin_detail_attributes'
102
+ require 'killbill_client/models/gen/payment_method_attributes'
103
+ require 'killbill_client/models/gen/subject_attributes'
@@ -32,7 +32,7 @@ module KillBillClient
32
32
  attribute :file_name
33
33
  attribute :line_number
34
34
  attribute :method_name
35
- attribute :native_method
35
+ attribute :is_native_method
36
36
  end
37
37
  end
38
38
  end
@@ -27,7 +27,7 @@
27
27
 
28
28
  module KillBillClient
29
29
  module Model
30
- class TenantKeyAttributes < Resource
30
+ class TenantKeyValueAttributes < Resource
31
31
  attribute :key
32
32
  attribute :values
33
33
  end
@@ -38,6 +38,27 @@ module KillBillClient
38
38
  custom_field.refresh(options)
39
39
  end
40
40
 
41
+ define_method('modify_custom_field') do |*args|
42
+
43
+ custom_fields = args[0]
44
+ user = args[1]
45
+ reason = args[2]
46
+ comment = args[3]
47
+ options = args[4] || {}
48
+
49
+ body = custom_fields.is_a?(Enumerable) ? custom_fields : [custom_fields]
50
+ custom_field = self.class.put "#{url_prefix}/#{send(id_alias)}/customFields",
51
+ body.to_json,
52
+ {},
53
+ {
54
+ :user => user,
55
+ :reason => reason,
56
+ :comment => comment,
57
+ }.merge(options),
58
+ CustomField
59
+ custom_field.refresh(options)
60
+ end
61
+
41
62
  define_method('remove_custom_field') do |*args|
42
63
 
43
64
  custom_fields = args[0]
@@ -82,10 +82,8 @@ module KillBillClient
82
82
  options = args[4] || {}
83
83
 
84
84
  created_tag = self.class.post "#{url_prefix}/#{send(id_alias)}/tags",
85
+ tag_definition_ids,
85
86
  {},
86
- {
87
- :tagList => tag_definition_ids.join(',')
88
- },
89
87
  {
90
88
  :user => user,
91
89
  :reason => reason,
@@ -106,7 +104,7 @@ module KillBillClient
106
104
  self.class.delete "#{url_prefix}/#{send(id_alias)}/tags",
107
105
  {},
108
106
  {
109
- :tagList => tag_definition_ids.join(',')
107
+ :tagDef => tag_definition_ids
110
108
  },
111
109
  {
112
110
  :user => user,
@@ -16,8 +16,17 @@ module KillBillClient
16
16
  has_tags KILLBILL_API_INVOICES_PREFIX, :invoice_id
17
17
 
18
18
  class << self
19
- def find_by_id_or_number(id_or_number, with_items = true, audit = "NONE", options = {})
20
- get "#{KILLBILL_API_INVOICES_PREFIX}/#{id_or_number}",
19
+ def find_by_id(invoice_id, with_items = true, audit = "NONE", options = {})
20
+ get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}",
21
+ {
22
+ :withItems => with_items,
23
+ :audit => audit
24
+ },
25
+ options
26
+ end
27
+
28
+ def find_by_number(number, with_items = true, audit = "NONE", options = {})
29
+ get "#{KILLBILL_API_INVOICES_PREFIX}/byNumber/#{number}",
21
30
  {
22
31
  :withItems => with_items,
23
32
  :audit => audit
@@ -81,22 +90,19 @@ module KillBillClient
81
90
  query_map = {:accountId => account_id}
82
91
  query_map[:targetDate] = target_date if target_date != nil
83
92
 
84
- begin
85
- res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
86
- dry_run.to_json,
87
- query_map,
88
- {
89
- :user => 'trigger_invoice_dry_run',
90
- :reason => '',
91
- :comment => '',
92
- }.merge(options),
93
- Invoice
93
+ res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
94
+ dry_run.to_json,
95
+ query_map,
96
+ {
97
+ :user => 'trigger_invoice_dry_run',
98
+ :reason => '',
99
+ :comment => '',
100
+ }.merge(options),
101
+ Invoice
94
102
 
95
- res.refresh(options)
96
103
 
97
- rescue KillBillClient::API::NotFound
98
- nil
99
- end
104
+ nothing_to_generate?(res) ? nil : res.refresh(options)
105
+
100
106
  end
101
107
 
102
108
 
@@ -114,21 +120,18 @@ module KillBillClient
114
120
  dry_run.price_list_name = price_list_name
115
121
  dry_run.bundle_id = bundle_id
116
122
 
117
- begin
118
- res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
119
- dry_run.to_json,
120
- query_map,
121
- {
122
- :user => 'create_subscription_dry_run',
123
- :reason => '',
124
- :comment => '',
125
- }.merge(options),
126
- Invoice
123
+ res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
124
+ dry_run.to_json,
125
+ query_map,
126
+ {
127
+ :user => 'create_subscription_dry_run',
128
+ :reason => '',
129
+ :comment => '',
130
+ }.merge(options),
131
+ Invoice
132
+
133
+ nothing_to_generate?(res) ? nil : res.refresh(options)
127
134
 
128
- res.refresh(options)
129
- rescue KillBillClient::API::NotFound
130
- nil
131
- end
132
135
  end
133
136
 
134
137
  def change_plan_dry_run(account_id, bundle_id, subscription_id, target_date, product_name, product_category, billing_period, price_list_name,
@@ -148,21 +151,19 @@ module KillBillClient
148
151
  dry_run.bundle_id = bundle_id
149
152
  dry_run.subscription_id = subscription_id
150
153
 
151
- begin
152
- res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
153
- dry_run.to_json,
154
- query_map,
155
- {
156
- :user => 'change_plan_dry_run',
157
- :reason => '',
158
- :comment => '',
159
- }.merge(options),
160
- Invoice
161
154
 
162
- res.refresh(options)
163
- rescue KillBillClient::API::NotFound
164
- nil
165
- end
155
+ res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
156
+ dry_run.to_json,
157
+ query_map,
158
+ {
159
+ :user => 'change_plan_dry_run',
160
+ :reason => '',
161
+ :comment => '',
162
+ }.merge(options),
163
+ Invoice
164
+
165
+ nothing_to_generate?(res) ? nil : res.refresh(options)
166
+
166
167
  end
167
168
 
168
169
 
@@ -180,31 +181,27 @@ module KillBillClient
180
181
  dry_run.subscription_id = subscription_id
181
182
 
182
183
 
183
- begin
184
- res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
185
- dry_run.to_json,
186
- query_map,
187
- {
188
- :user => 'cancel_subscription_dry_run',
189
- :reason => '',
190
- :comment => '',
191
- }.merge(options),
192
- Invoice
184
+ res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
185
+ dry_run.to_json,
186
+ query_map,
187
+ {
188
+ :user => 'cancel_subscription_dry_run',
189
+ :reason => '',
190
+ :comment => '',
191
+ }.merge(options),
192
+ Invoice
193
193
 
194
- res.refresh(options)
194
+ nothing_to_generate?(res) ? nil : res.refresh(options)
195
195
 
196
- rescue KillBillClient::API::NotFound
197
- nil
198
- end
199
196
  end
200
197
 
201
198
 
202
- def get_invoice_template(is_manual_pay, options = {})
199
+ def get_invoice_template(is_manual_pay, locale = nil, options = {})
203
200
 
204
201
  require_multi_tenant_options!(options, "Retrieving an invoice template supported in multi-tenant mode")
205
202
 
206
203
 
207
- get "#{KILLBILL_API_INVOICES_PREFIX}/#{is_manual_pay ? "manualPayTemplate" : "template"}",
204
+ get "#{KILLBILL_API_INVOICES_PREFIX}/#{is_manual_pay ? "manualPayTemplate/#{locale}" : "template"}",
208
205
  {},
209
206
  {
210
207
  :head => {'Accept' => 'text/html'},
@@ -229,7 +226,7 @@ module KillBillClient
229
226
  :reason => reason,
230
227
  :comment => comment,
231
228
  }.merge(options)
232
- get_invoice_template(is_manual_pay, options)
229
+ get_invoice_template(is_manual_pay, nil, options)
233
230
  end
234
231
 
235
232
  def get_invoice_translation(locale, options = {})
@@ -360,7 +357,12 @@ module KillBillClient
360
357
  :comment => comment,
361
358
  }.merge(options)
362
359
  end
360
+ private
363
361
 
362
+ def self.nothing_to_generate?(invoice)
363
+ return true if invoice.nil? || invoice.response.nil?
364
+ invoice.response.code.to_i == 204
365
+ end
364
366
  end
365
367
  end
366
368
  end
@@ -28,10 +28,8 @@ module KillBillClient
28
28
  # DO NOT DELETE THIS METHOD
29
29
  def add_tags_from_definition_ids(tag_definition_ids, user, reason, comment, options)
30
30
  created_tag = self.class.post "#{KILLBILL_API_INVOICE_ITEMS_PREFIX}/#{invoice_item_id}/tags",
31
+ tag_definition_ids,
31
32
  {},
32
- {
33
- :tagList => tag_definition_ids.join(',')
34
- },
35
33
  {
36
34
  :user => user,
37
35
  :reason => reason,
@@ -74,6 +74,20 @@ module KillBillClient
74
74
  }.merge(options)
75
75
  invoice_payment.refresh(options)
76
76
  end
77
+
78
+ def complete_invoice_payment_transaction(payment_id, user, reason, comment, options)
79
+ invoice_payment = PaymentTransactionAttributes.new
80
+ invoice_payment.payment_id = payment_id
81
+
82
+ put "#{KILLBILL_API_INVOICE_PAYMENTS_PREFIX}/#{payment_id}",
83
+ invoice_payment.to_json,
84
+ {},
85
+ {
86
+ :user => user,
87
+ :reason => reason,
88
+ :comment => comment
89
+ }.merge(options)
90
+ end
77
91
  end
78
92
 
79
93
  def create(external_payment = false, user = nil, reason = nil, comment = nil, options = {})
@@ -90,13 +104,15 @@ module KillBillClient
90
104
  created_invoice_payment.refresh(options)
91
105
  end
92
106
 
93
- def bulk_create(external_payment = false, user = nil, reason = nil, comment = nil, options = {})
107
+ def bulk_create(external_payment = false, payment_method_id = nil, target_date = nil, user = nil, reason = nil, comment = nil, options = {})
94
108
  # Nothing to return (nil)
95
109
  self.class.post "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/invoicePayments",
96
110
  {},
97
111
  {
98
112
  :externalPayment => external_payment,
99
- :paymentAmount => purchased_amount
113
+ :paymentAmount => purchased_amount,
114
+ :paymentMethodId => payment_method_id,
115
+ :targetDate => target_date
100
116
  },
101
117
  {
102
118
  :user => user,
@@ -104,7 +120,6 @@ module KillBillClient
104
120
  :comment => comment,
105
121
  }.merge(options)
106
122
  end
107
-
108
123
  end
109
124
  end
110
125
  end