Class: KillBillClient::Model::Account
Constant Summary
collapse
- AUTO_PAY_OFF_ID =
'00000000-0000-0000-0000-000000000001'
- AUTO_INVOICING_ID =
'00000000-0000-0000-0000-000000000002'
- OVERDUE_ENFORCEMENT_OFF_ID =
'00000000-0000-0000-0000-000000000003'
- WRITTEN_OFF_ID =
'00000000-0000-0000-0000-000000000004'
- MANUAL_PAY_ID =
'00000000-0000-0000-0000-000000000005'
- TEST_ID =
'00000000-0000-0000-0000-000000000006'
- KILLBILL_API_ACCOUNTS_PREFIX =
"#{KILLBILL_API_PREFIX}/accounts"
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
-
.find_by_id(account_id, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object
-
.find_in_batches(offset = 0, limit = 100, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object
-
.find_in_batches_by_search_key(search_key, offset = 0, limit = 100, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object
Instance Method Summary
collapse
-
#add_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#auto_invoicing?(options = {}) ⇒ Boolean
-
#auto_pay_off?(options = {}) ⇒ Boolean
-
#bundles(options = {}) ⇒ Object
-
#create(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#invoices(with_items = false, options = {}) ⇒ Object
-
#manual_pay?(options = {}) ⇒ Boolean
-
#overdue(options = {}) ⇒ Object
-
#overdue_enforcement_off?(options = {}) ⇒ Boolean
-
#payments(options = {}) ⇒ Object
-
#remove_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#set_auto_invoicing(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#set_auto_pay_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#set_manual_pay(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#set_overdue_enforcement_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#set_test(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#set_written_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#tags(audit = 'NONE', options = {}) ⇒ Object
-
#test?(options = {}) ⇒ Boolean
-
#written_off?(options = {}) ⇒ Boolean
Methods inherited from Resource
#==, #_to_hash, attribute, create_alias, delete, extract_session_id, from_json, from_response, get, has_many, has_one, #hash, head, instantiate_record_from_json, post, put, #refresh, #to_hash, #to_json
Class Method Details
.find_by_id(account_id, with_balance = false, with_balance_and_cba = false, options = {}) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/killbill_client/models/account.rb', line 28
def find_by_id(account_id, with_balance = false, with_balance_and_cba = false, options = {})
get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}",
{
: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
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/killbill_client/models/account.rb', line 17
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
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/killbill_client/models/account.rb', line 37
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_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/killbill_client/models/account.rb', line 100
def add_tag(tag_name, user = nil, reason = nil, = nil, options = {})
tag_definition = TagDefinition.find_by_name(tag_name, options)
if tag_definition.nil?
tag_definition = TagDefinition.new
tag_definition.name = tag_name
tag_definition.description = "Tag created for account #{@account_id}"
tag_definition = TagDefinition.create(user, options)
end
add_tag_from_definition_id(tag_definition.id, user, reason, , options)
end
|
#auto_invoicing?(options = {}) ⇒ Boolean
136
137
138
|
# File 'lib/killbill_client/models/account.rb', line 136
def auto_invoicing?(options = {})
control_tag_off?(AUTO_INVOICING_ID, options)
end
|
#auto_pay_off?(options = {}) ⇒ Boolean
128
129
130
|
# File 'lib/killbill_client/models/account.rb', line 128
def auto_pay_off?(options = {})
control_tag_off?(AUTO_PAY_OFF_ID, options)
end
|
#bundles(options = {}) ⇒ Object
61
62
63
64
65
66
|
# File 'lib/killbill_client/models/account.rb', line 61
def bundles(options = {})
self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/bundles",
{},
options,
Bundle
end
|
#create(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/killbill_client/models/account.rb', line 49
def create(user = nil, reason = nil, = nil, options = {})
created_account = self.class.post KILLBILL_API_ACCOUNTS_PREFIX,
to_json,
{},
{
:user => user,
:reason => reason,
:comment => ,
}.merge(options)
created_account.refresh(options)
end
|
#invoices(with_items = false, options = {}) ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'lib/killbill_client/models/account.rb', line 68
def invoices(with_items=false, options = {})
self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/invoices",
{
:withItems => with_items
},
options,
Invoice
end
|
#manual_pay?(options = {}) ⇒ Boolean
160
161
162
|
# File 'lib/killbill_client/models/account.rb', line 160
def manual_pay?(options = {})
control_tag_off?(MANUAL_PAY_ID, options)
end
|
#overdue(options = {}) ⇒ Object
84
85
86
87
88
89
|
# File 'lib/killbill_client/models/account.rb', line 84
def overdue(options = {})
self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/overdue",
{},
options,
OverdueStateAttributes
end
|
#overdue_enforcement_off?(options = {}) ⇒ Boolean
144
145
146
|
# File 'lib/killbill_client/models/account.rb', line 144
def overdue_enforcement_off?(options = {})
control_tag_off?(OVERDUE_ENFORCEMENT_OFF_ID, options)
end
|
#payments(options = {}) ⇒ Object
77
78
79
80
81
82
|
# File 'lib/killbill_client/models/account.rb', line 77
def payments(options = {})
self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/payments",
{},
options,
Payment
end
|
#remove_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/killbill_client/models/account.rb', line 112
def remove_tag(tag_name, user = nil, reason = nil, = nil, options = {})
tag_definition = TagDefinition.find_by_name(tag_name)
return nil if tag_definition.nil?
self.class.delete "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/tags",
{
:tagList => tag_definition.id
},
{
:user => user,
:reason => reason,
:comment => ,
}.merge(options)
end
|
#set_auto_invoicing(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
140
141
142
|
# File 'lib/killbill_client/models/account.rb', line 140
def set_auto_invoicing(user = nil, reason = nil, = nil, options = {})
add_tag_from_definition_id(AUTO_INVOICING_ID, user, reason, , options)
end
|
#set_auto_pay_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
132
133
134
|
# File 'lib/killbill_client/models/account.rb', line 132
def set_auto_pay_off(user = nil, reason = nil, = nil, options = {})
add_tag_from_definition_id(AUTO_PAY_OFF_ID, user, reason, , options)
end
|
#set_manual_pay(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
164
165
166
|
# File 'lib/killbill_client/models/account.rb', line 164
def set_manual_pay(user = nil, reason = nil, = nil, options = {})
add_tag_from_definition_id(MANUAL_PAY_ID, user, reason, , options)
end
|
#set_overdue_enforcement_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
148
149
150
|
# File 'lib/killbill_client/models/account.rb', line 148
def set_overdue_enforcement_off(user = nil, reason = nil, = nil, options = {})
add_tag_from_definition_id(OVERDUE_ENFORCEMENT_OFF_ID, user, reason, , options)
end
|
#set_test(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
172
173
174
|
# File 'lib/killbill_client/models/account.rb', line 172
def set_test(user = nil, reason = nil, = nil, options = {})
add_tag_from_definition_id(TEST_ID, user, reason, , options)
end
|
#set_written_off(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
156
157
158
|
# File 'lib/killbill_client/models/account.rb', line 156
def set_written_off( user = nil, reason = nil, = nil, options = {})
add_tag_from_definition_id(WRITTEN_OFF_ID, user, reason, , options)
end
|
91
92
93
94
95
96
97
98
|
# File 'lib/killbill_client/models/account.rb', line 91
def tags(audit = 'NONE', options = {})
self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/tags",
{
:audit => audit
},
options,
Tag
end
|
#test?(options = {}) ⇒ Boolean
168
169
170
|
# File 'lib/killbill_client/models/account.rb', line 168
def test?(options = {})
control_tag_off?(TEST_ID, options)
end
|
#written_off?(options = {}) ⇒ Boolean
152
153
154
|
# File 'lib/killbill_client/models/account.rb', line 152
def written_off?(options = {})
control_tag_off?(WRITTEN_OFF_ID, options)
end
|