Class: KillBillClient::Model::Account
Constant Summary
collapse
- 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
-
#bundles(options = {}) ⇒ Object
-
#create(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#invoices(with_items = false, options = {}) ⇒ Object
-
#overdue(options = {}) ⇒ Object
-
#payments(options = {}) ⇒ Object
-
#remove_tag(tag_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
#tags(audit = 'NONE', options = {}) ⇒ Object
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
21
22
23
24
25
26
27
28
|
# File 'lib/killbill_client/models/account.rb', line 21
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
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/killbill_client/models/account.rb', line 10
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
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/killbill_client/models/account.rb', line 30
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/killbill_client/models/account.rb', line 93
def add_tag(tag_name, user = nil, reason = nil, = nil, options = {})
tag_definition = TagDefinition.find_by_name(tag_name)
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
created_tag = self.class.post "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/tags",
{},
{
:tagList => tag_definition.id
},
{
:user => user,
:reason => reason,
:comment => ,
}.merge(options),
Tag
created_tag.refresh(options)
end
|
#bundles(options = {}) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/killbill_client/models/account.rb', line 54
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
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/killbill_client/models/account.rb', line 42
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
61
62
63
64
65
66
67
68
|
# File 'lib/killbill_client/models/account.rb', line 61
def invoices(with_items=false, options = {})
self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/invoices",
{
:withItems => with_items
},
options,
Invoice
end
|
#overdue(options = {}) ⇒ Object
77
78
79
80
81
82
|
# File 'lib/killbill_client/models/account.rb', line 77
def overdue(options = {})
self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/overdue",
{},
options,
OverdueStateAttributes
end
|
#payments(options = {}) ⇒ Object
70
71
72
73
74
75
|
# File 'lib/killbill_client/models/account.rb', line 70
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/killbill_client/models/account.rb', line 116
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
|
84
85
86
87
88
89
90
91
|
# File 'lib/killbill_client/models/account.rb', line 84
def tags(audit = 'NONE', options = {})
self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/tags",
{
:audit => audit
},
options,
Tag
end
|