Class: KillBillClient::Model::Account

Inherits:
AccountAttributes show all
Includes:
AuditLogWithHistoryHelper, CustomFieldHelper, TagHelper
Defined in:
lib/killbill_client/models/account.rb

Constant Summary collapse

KILLBILL_API_ACCOUNTS_PREFIX =
"#{KILLBILL_API_PREFIX}/accounts"

Constants included from TagHelper

TagHelper::AUTO_INVOICING_OFF_ID, TagHelper::AUTO_PAY_OFF_ID, TagHelper::MANUAL_PAY_ID, TagHelper::OVERDUE_ENFORCEMENT_OFF_ID, TagHelper::TEST_ID, TagHelper::WRITTEN_OFF_ID

Constants inherited from Resource

Resource::KILLBILL_API_PAGINATION_PREFIX, Resource::KILLBILL_API_PREFIX

Instance Attribute Summary

Attributes inherited from Resource

#clazz, #etag, #response, #session_id, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AuditLogWithHistoryHelper

included

Methods included from CustomFieldHelper

included

Methods included from TagHelper

#add_tag, #add_tag_from_definition_id, #control_tag?, included, #remove_tag, #remove_tag_from_definition_id, #set_tags

Methods inherited from Resource

#==, #_to_hash, attribute, create_alias, delete, extract_session_id, from_json, from_response, get, has_many, has_one, #hash, head, #initialize, instantiate_record_from_json, post, put, #refresh, require_multi_tenant_options!, #to_hash, #to_json

Constructor Details

This class inherits a constructor from KillBillClient::Model::Resource

Class Method Details

.blocking_state_audit_logs_with_history(blocking_state_id, options = {}) ⇒ Object



69
70
71
72
73
74
# File 'lib/killbill_client/models/account.rb', line 69

def blocking_state_audit_logs_with_history(blocking_state_id, options = {})
  get "#{KILLBILL_API_ACCOUNTS_PREFIX}/block/#{blocking_state_id}/auditLogsWithHistory",
      {},
      options,
      AuditLog
end

.find_by_external_key(external_key, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/killbill_client/models/account.rb', line 38

def find_by_external_key(external_key, with_balance = false, with_balance_and_cba = false, options = {})
  get "#{KILLBILL_API_ACCOUNTS_PREFIX}",
      {
          :externalKey              => external_key,
          :accountWithBalance       => with_balance,
          :accountWithBalanceAndCBA => with_balance_and_cba
      },
      options
end

.find_by_id(account_id, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/killbill_client/models/account.rb', line 29

def find_by_id(, with_balance = false, with_balance_and_cba = false, options = {})
  get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}",
      {
          :accountWithBalance       => with_balance,
          :accountWithBalanceAndCBA => with_balance_and_cba
      },
      options
end

.find_children(account_id, with_balance = false, with_balance_and_cba = false, audit = 'NONE', options = {}) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/killbill_client/models/account.rb', line 59

def find_children(, with_balance = false, with_balance_and_cba = false, audit='NONE', options = {})
  get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/children",
      {
        :audit                    => audit,
        :accountWithBalance       => with_balance,
        :accountWithBalanceAndCBA => with_balance_and_cba
      },
      options
end

.find_in_batches(offset = 0, limit = 100, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/killbill_client/models/account.rb', line 18

def find_in_batches(offset = 0, limit = 100, with_balance = false, with_balance_and_cba = false, options = {})
  get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{Resource::KILLBILL_API_PAGINATION_PREFIX}",
      {
          :offset                   => offset,
          :limit                    => limit,
          :accountWithBalance       => with_balance,
          :accountWithBalanceAndCBA => with_balance_and_cba
      },
      options
end

.find_in_batches_by_search_key(search_key, offset = 0, limit = 100, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/killbill_client/models/account.rb', line 48

def find_in_batches_by_search_key(search_key, offset = 0, limit = 100, with_balance = false, with_balance_and_cba = false, options = {})
  get "#{KILLBILL_API_ACCOUNTS_PREFIX}/search/#{search_key}",
      {
          :offset                   => offset,
          :limit                    => limit,
          :accountWithBalance       => with_balance,
          :accountWithBalanceAndCBA => with_balance_and_cba
      },
      options
end

.paginated_bundles(account_id, offset = 0, limit = 100, audit = "NONE", options = {}) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/killbill_client/models/account.rb', line 76

def paginated_bundles(, offset = 0, limit = 100, audit = "NONE", options = {})
  get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/bundles/pagination",
                  {
                    :offset => offset,
                    :limit => limit,
                    :audit => audit
                  },
                  options,
                  Bundle
end

.paginated_invoices(account_id, offset = 0, limit = 100, audit = "NONE", options = {}) ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'lib/killbill_client/models/account.rb', line 87

def paginated_invoices(, offset = 0, limit = 100, audit = "NONE", options = {})
  get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/invoices/pagination",
           {
            :offset => offset,
            :limit => limit,
            :audit => audit
           },
           options,
           Invoice
end

Instance Method Details

#add_email(email, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/killbill_client/models/account.rb', line 276

def add_email(email, user = nil, reason = nil, comment = nil, options = {})
  self.class.post "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/emails",
                  {
                      # TODO Required ATM
                      :accountId => ,
                      :email     => email
                  }.to_json,
                  {},
                  {
                      :user    => user,
                      :reason  => reason,
                      :comment => comment,
                  }.merge(options)
end

#all_custom_fields(object_type, audit = 'NONE', options = {}) ⇒ Object



329
330
331
332
333
334
335
336
337
# File 'lib/killbill_client/models/account.rb', line 329

def all_custom_fields(object_type, audit = 'NONE', options = {})
  params = {}
  params[:objectType] = object_type if object_type
  params[:audit] = audit
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/allCustomFields",
                 params,
                 options,
                 CustomField
end

#all_tags(object_type, included_deleted, audit = 'NONE', options = {}) ⇒ Object



318
319
320
321
322
323
324
325
326
327
# File 'lib/killbill_client/models/account.rb', line 318

def all_tags(object_type, included_deleted, audit = 'NONE', options = {})
  params = {}
  params[:objectType] = object_type if object_type
  params[:includedDeleted] = included_deleted if included_deleted
  params[:audit] = audit
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/allTags",
                 params,
                 options,
                 Tag
end

#audit(options = {}) ⇒ Object



396
397
398
399
400
401
# File 'lib/killbill_client/models/account.rb', line 396

def audit(options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/auditLogs",
                 {},
                 options,
                 AuditLog
end

#auto_invoicing_off?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


216
217
218
# File 'lib/killbill_client/models/account.rb', line 216

def auto_invoicing_off?(options = {})
  control_tag?(AUTO_INVOICING_OFF_ID, options)
end

#auto_pay_off?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


204
205
206
# File 'lib/killbill_client/models/account.rb', line 204

def auto_pay_off?(options = {})
  control_tag?(AUTO_PAY_OFF_ID, options)
end

#blocking_states(blocking_state_types, blocking_state_svcs, audit = 'NONE', options = {}) ⇒ Object



339
340
341
342
343
344
345
346
347
348
349
# File 'lib/killbill_client/models/account.rb', line 339

def blocking_states(blocking_state_types, blocking_state_svcs, audit = 'NONE', options = {})
  params = {}
  params[:blockingStateTypes] = blocking_state_types if blocking_state_types
  params[:blockingStateSvcs] = blocking_state_svcs if blocking_state_svcs
  params[:audit] = audit
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/block",
                 params,
                 options,
                 BlockingStateAttributes

end

#bundles(options = {}) ⇒ Object



160
161
162
163
164
165
# File 'lib/killbill_client/models/account.rb', line 160

def bundles(options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/bundles",
                 {},
                 options,
                 Bundle
end

#cba_rebalancing(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



374
375
376
377
378
379
380
381
382
383
# File 'lib/killbill_client/models/account.rb', line 374

def cba_rebalancing(user = nil, reason = nil, comment = nil, options = {})
  self.class.put "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/cbaRebalancing",
                  {},
                  {},
                  {
                      :user    => user,
                      :reason  => reason,
                      :comment => comment,
                  }.merge(options)
end

#children(with_balance = false, with_balance_and_cba = false, audit = 'NONE', options = {}) ⇒ Object



200
201
202
# File 'lib/killbill_client/models/account.rb', line 200

def children(with_balance = false, with_balance_and_cba = false, audit='NONE', options = {})
  Account::find_children(self., with_balance, with_balance_and_cba, audit, options)
end

#close(cancel_subscriptions, writeoff_unpaid_invoices, item_adjust_unpaid_invoices, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/killbill_client/models/account.rb', line 130

def close(cancel_subscriptions, writeoff_unpaid_invoices,  item_adjust_unpaid_invoices, user = nil, reason = nil, comment = nil, options = {})
   = self.class.delete "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}",
                                      {},
                                      {
                                          :cancelAllSubscriptions => cancel_subscriptions,
                                          :writeOffUnpaidInvoices => writeoff_unpaid_invoices,
                                          :itemAdjustUnpaidInvoices => item_adjust_unpaid_invoices
                                      },
                                      {
                                          :user    => user,
                                          :reason  => reason,
                                          :comment => comment,
                                      }.merge(options)
  .refresh(options)
end

#create(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/killbill_client/models/account.rb', line 99

def create(user = nil, reason = nil, comment = nil, options = {})
   = self.class.post KILLBILL_API_ACCOUNTS_PREFIX,
                                    to_json,
                                    {},
                                    {
                                        :user    => user,
                                        :reason  => reason,
                                        :comment => comment,
                                    }.merge(options)
  .refresh(options)
end

#email_audit_logs_with_history(account_email_id, options = {}) ⇒ Object



311
312
313
314
315
316
# File 'lib/killbill_client/models/account.rb', line 311

def email_audit_logs_with_history(, options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/emails/#{}/auditLogsWithHistory",
                 {},
                 options,
                 AuditLog
end

#emails(audit = 'NONE', options = {}) ⇒ Object



302
303
304
305
306
307
308
309
# File 'lib/killbill_client/models/account.rb', line 302

def emails(audit = 'NONE', options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/emails",
                 {
                     :audit => audit
                 },
                 options,
                 AccountEmailAttributes
end

#invoice_payments(audit = 'NONE', with_plugin_info = false, with_attempts = false, options = {}) ⇒ Object



385
386
387
388
389
390
391
392
393
394
# File 'lib/killbill_client/models/account.rb', line 385

def invoice_payments(audit='NONE', with_plugin_info = false, with_attempts = false, options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/invoicePayments",
                 {
                     :audit                    => audit,
                     :withPluginInfo       => with_plugin_info,
                     :withAttempts => with_attempts
                 },
                 options,
                 InvoicePayment
end

#invoices(options = {}) ⇒ Object



167
168
169
170
171
172
173
174
175
# File 'lib/killbill_client/models/account.rb', line 167

def invoices(options = {})
  params_hash = options.delete(:params)
  options_to_merge = params_hash.nil? ? {} : params_hash
  merged_options = { :includeInvoiceComponents => true }.merge(options_to_merge)
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/invoices",
           merged_options,
           options,
           Invoice
end

#manual_pay?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


252
253
254
# File 'lib/killbill_client/models/account.rb', line 252

def manual_pay?(options = {})
  control_tag?(MANUAL_PAY_ID, options)
end

#migration_invoices(options = {}) ⇒ Object



177
178
179
180
181
182
183
184
# File 'lib/killbill_client/models/account.rb', line 177

def migration_invoices(options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/invoices",
                 {
                     :withMigrationInvoices => true
                 },
                 options,
                 Invoice
end

#overdue(options = {}) ⇒ Object



193
194
195
196
197
198
# File 'lib/killbill_client/models/account.rb', line 193

def overdue(options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/overdue",
                 {},
                 options,
                 OverdueStateAttributes
end

#overdue_enforcement_off?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


228
229
230
# File 'lib/killbill_client/models/account.rb', line 228

def overdue_enforcement_off?(options = {})
  control_tag?(OVERDUE_ENFORCEMENT_OFF_ID, options)
end

#payments(options = {}) ⇒ Object



186
187
188
189
190
191
# File 'lib/killbill_client/models/account.rb', line 186

def payments(options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/payments",
                 {},
                 options,
                 Payment
end

#remove_auto_invoicing_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



224
225
226
# File 'lib/killbill_client/models/account.rb', line 224

def remove_auto_invoicing_off(user = nil, reason = nil, comment = nil, options = {})
  remove_tag_from_definition_id(AUTO_INVOICING_OFF_ID, user, reason, comment, options)
end

#remove_auto_pay_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



212
213
214
# File 'lib/killbill_client/models/account.rb', line 212

def remove_auto_pay_off(user = nil, reason = nil, comment = nil, options = {})
  remove_tag_from_definition_id(AUTO_PAY_OFF_ID, user, reason, comment, options)
end

#remove_email(email, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



291
292
293
294
295
296
297
298
299
300
# File 'lib/killbill_client/models/account.rb', line 291

def remove_email(email, user = nil, reason = nil, comment = nil, options = {})
  self.class.delete "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/emails/#{email}",
                    {},
                    {},
                    {
                        :user    => user,
                        :reason  => reason,
                        :comment => comment,
                    }.merge(options)
end

#remove_manual_pay(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



260
261
262
# File 'lib/killbill_client/models/account.rb', line 260

def remove_manual_pay(user = nil, reason = nil, comment = nil, options = {})
  remove_tag_from_definition_id(MANUAL_PAY_ID, user, reason, comment, options)
end

#remove_overdue_enforcement_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



236
237
238
# File 'lib/killbill_client/models/account.rb', line 236

def remove_overdue_enforcement_off(user = nil, reason = nil, comment = nil, options = {})
  remove_tag_from_definition_id(OVERDUE_ENFORCEMENT_OFF_ID, user, reason, comment, options)
end

#remove_test(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



272
273
274
# File 'lib/killbill_client/models/account.rb', line 272

def remove_test(user = nil, reason = nil, comment = nil, options = {})
  remove_tag_from_definition_id(TEST_ID, user, reason, comment, options)
end

#remove_written_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



248
249
250
# File 'lib/killbill_client/models/account.rb', line 248

def remove_written_off(user = nil, reason = nil, comment = nil, options = {})
  remove_tag_from_definition_id(WRITTEN_OFF_ID, user, reason, comment, options)
end

#set_auto_invoicing_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



220
221
222
# File 'lib/killbill_client/models/account.rb', line 220

def set_auto_invoicing_off(user = nil, reason = nil, comment = nil, options = {})
  add_tag_from_definition_id(AUTO_INVOICING_OFF_ID, user, reason, comment, options)
end

#set_auto_pay_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



208
209
210
# File 'lib/killbill_client/models/account.rb', line 208

def set_auto_pay_off(user = nil, reason = nil, comment = nil, options = {})
  add_tag_from_definition_id(AUTO_PAY_OFF_ID, user, reason, comment, options)
end

#set_blocking_state(state_name, service, is_block_change, is_block_entitlement, is_block_billing, requested_date = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/killbill_client/models/account.rb', line 351

def set_blocking_state(state_name, service, is_block_change, is_block_entitlement, is_block_billing, requested_date = nil, user = nil, reason = nil, comment = nil, options = {})

  params = {}
  params[:requestedDate] = requested_date if requested_date

  body = KillBillClient::Model::BlockingStateAttributes.new
  body.state_name = state_name
  body.service = service
  body.is_block_change = is_block_change
  body.is_block_entitlement = is_block_entitlement
  body.is_block_billing = is_block_billing

  self.class.post "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/block",
                  body.to_json,
                  params,
                  {
                      :user => user,
                      :reason => reason,
                      :comment => comment,
                  }.merge(options)
  blocking_states(nil, nil, 'NONE', options)
end

#set_manual_pay(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



256
257
258
# File 'lib/killbill_client/models/account.rb', line 256

def set_manual_pay(user = nil, reason = nil, comment = nil, options = {})
  add_tag_from_definition_id(MANUAL_PAY_ID, user, reason, comment, options)
end

#set_overdue_enforcement_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



232
233
234
# File 'lib/killbill_client/models/account.rb', line 232

def set_overdue_enforcement_off(user = nil, reason = nil, comment = nil, options = {})
  add_tag_from_definition_id(OVERDUE_ENFORCEMENT_OFF_ID, user, reason, comment, options)
end

#set_test(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



268
269
270
# File 'lib/killbill_client/models/account.rb', line 268

def set_test(user = nil, reason = nil, comment = nil, options = {})
  add_tag_from_definition_id(TEST_ID, user, reason, comment, options)
end

#set_written_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



244
245
246
# File 'lib/killbill_client/models/account.rb', line 244

def set_written_off(user = nil, reason = nil, comment = nil, options = {})
  add_tag_from_definition_id(WRITTEN_OFF_ID, user, reason, comment, options)
end

#test?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


264
265
266
# File 'lib/killbill_client/models/account.rb', line 264

def test?(options = {})
  control_tag?(TEST_ID, options)
end

#transfer_child_credit(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



148
149
150
151
152
153
154
155
156
157
# File 'lib/killbill_client/models/account.rb', line 148

def transfer_child_credit(user = nil, reason = nil, comment = nil, options = {})
  self.class.put "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/transferCredit",
                  {},
                  {},
                  {
                      :user    => user,
                      :reason  => reason,
                      :comment => comment,
                  }.merge(options)
end

#update(treat_null_as_reset = false, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/killbill_client/models/account.rb', line 111

def update(treat_null_as_reset = false, user = nil, reason = nil, comment = nil, options = {})

  params = {}
  params[:treatNullAsReset] = treat_null_as_reset

  self.class.put "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}",
                 to_json,
                 params,
                 {
                     :user    => user,
                     :reason  => reason,
                     :comment => comment,
                 }.merge(options)

  self.class.find_by_id(, nil, nil, options)

end

#written_off?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


240
241
242
# File 'lib/killbill_client/models/account.rb', line 240

def written_off?(options = {})
  control_tag?(WRITTEN_OFF_ID, options)
end