Class: KillBillClient::Model::Account

Inherits:
AccountAttributes show all
Includes:
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 CustomFieldHelper

included

Methods included from TagHelper

#add_tag, #add_tag_from_definition_id, #control_tag_off?, 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, #to_hash, #to_json

Constructor Details

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

Class Method Details

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



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

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



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

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_in_batches(offset = 0, limit = 100, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object



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

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



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

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

Instance Method Details

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



172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/killbill_client/models/account.rb', line 172

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

#auto_invoicing_off?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/killbill_client/models/account.rb', line 112

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

#auto_pay_off?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/killbill_client/models/account.rb', line 100

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

#bundles(options = {}) ⇒ Object



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

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

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



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

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

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



198
199
200
201
202
203
204
205
# File 'lib/killbill_client/models/account.rb', line 198

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

#invoices(with_items = false, options = {}) ⇒ Object



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

def invoices(with_items=false, options = {})
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{}/invoices",
                 {
                     :withItems => with_items
                 },
                 options,
                 Invoice
end

#manual_pay?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


148
149
150
# File 'lib/killbill_client/models/account.rb', line 148

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

#overdue(options = {}) ⇒ Object



93
94
95
96
97
98
# File 'lib/killbill_client/models/account.rb', line 93

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

#overdue_enforcement_off?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/killbill_client/models/account.rb', line 124

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

#payments(options = {}) ⇒ Object



86
87
88
89
90
91
# File 'lib/killbill_client/models/account.rb', line 86

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



120
121
122
# File 'lib/killbill_client/models/account.rb', line 120

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



108
109
110
# File 'lib/killbill_client/models/account.rb', line 108

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

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



187
188
189
190
191
192
193
194
195
196
# File 'lib/killbill_client/models/account.rb', line 187

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



156
157
158
# File 'lib/killbill_client/models/account.rb', line 156

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



132
133
134
# File 'lib/killbill_client/models/account.rb', line 132

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



168
169
170
# File 'lib/killbill_client/models/account.rb', line 168

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



144
145
146
# File 'lib/killbill_client/models/account.rb', line 144

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



116
117
118
# File 'lib/killbill_client/models/account.rb', line 116

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



104
105
106
# File 'lib/killbill_client/models/account.rb', line 104

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_manual_pay(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



152
153
154
# File 'lib/killbill_client/models/account.rb', line 152

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



128
129
130
# File 'lib/killbill_client/models/account.rb', line 128

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



164
165
166
# File 'lib/killbill_client/models/account.rb', line 164

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



140
141
142
# File 'lib/killbill_client/models/account.rb', line 140

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)


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

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

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



207
208
209
210
211
212
213
214
215
216
# File 'lib/killbill_client/models/account.rb', line 207

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

#written_off?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/killbill_client/models/account.rb', line 136

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