Class: KillBillClient::Model::Invoice
Constant Summary
collapse
- KILLBILL_API_INVOICES_PREFIX =
"#{KILLBILL_API_PREFIX}/invoices"
- KILLBILL_API_DRY_RUN_INVOICES_PREFIX =
"#{KILLBILL_API_INVOICES_PREFIX}/dryRun"
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
-
.as_html(invoice_id, options = {}) ⇒ Object
-
.cancel_subscription_dry_run(account_id, bundle_id, subscription_id, target_date, effective_date, billing_policy, options = {}) ⇒ Object
-
.change_plan_dry_run(account_id, bundle_id, subscription_id, target_date, product_name, product_category, billing_period, price_list_name, effective_date, billing_policy, options = {}) ⇒ Object
-
.create_subscription_dry_run(account_id, bundle_id, target_date, product_name, product_category, billing_period, price_list_name, options = {}) ⇒ Object
-
.find_by_id_or_number(id_or_number, with_items = true, audit = "NONE", options = {}) ⇒ Object
-
.find_in_batches(offset = 0, limit = 100, options = {}) ⇒ Object
-
.find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {}) ⇒ Object
-
.trigger_invoice(account_id, target_date, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
-
.trigger_invoice_dry_run(account_id, target_date, options = {}) ⇒ Object
Instance Method Summary
collapse
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
Class Method Details
.as_html(invoice_id, options = {}) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/killbill_client/models/invoice.rb', line 41
def as_html(invoice_id, options = {})
get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/html",
{},
{
:accept => 'text/html'
}.merge(options)
end
|
.cancel_subscription_dry_run(account_id, bundle_id, subscription_id, target_date, effective_date, billing_policy, options = {}) ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/killbill_client/models/invoice.rb', line 158
def cancel_subscription_dry_run(account_id, bundle_id, subscription_id, target_date,
effective_date, billing_policy, options = {})
query_map = {:accountId => account_id}
query_map[:targetDate] = target_date if !target_date.nil?
dry_run = InvoiceDryRunAttributes.new
dry_run.dry_run_action = 'STOP_BILLING'
dry_run.effective_date = effective_date
dry_run.billing_policy = billing_policy
dry_run.bundle_id = bundle_id
dry_run.subscription_id = subscription_id
begin
res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
dry_run.to_json,
query_map,
{
:user => 'cancel_subscription_dry_run',
:reason => '',
:comment => '',
}.merge(options),
Invoice
res.refresh(options)
rescue KillBillClient::API::NotFound => e
nil
end
end
|
.change_plan_dry_run(account_id, bundle_id, subscription_id, target_date, product_name, product_category, billing_period, price_list_name, effective_date, billing_policy, options = {}) ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/killbill_client/models/invoice.rb', line 124
def change_plan_dry_run(account_id, bundle_id, subscription_id, target_date, product_name, product_category, billing_period, price_list_name,
effective_date, billing_policy, options = {})
query_map = {:accountId => account_id}
query_map[:targetDate] = target_date if !target_date.nil?
dry_run = InvoiceDryRunAttributes.new
dry_run.dry_run_action = 'CHANGE'
dry_run.product_name = product_name
dry_run.product_category = product_category
dry_run.billing_period = billing_period
dry_run.price_list_name = price_list_name
dry_run.effective_date = effective_date
dry_run.billing_policy = billing_policy
dry_run.bundle_id = bundle_id
dry_run.subscription_id = subscription_id
begin
res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
dry_run.to_json,
query_map,
{
:user => 'change_plan_dry_run',
:reason => '',
:comment => '',
}.merge(options),
Invoice
res.refresh(options)
rescue KillBillClient::API::NotFound => e
nil
end
end
|
.create_subscription_dry_run(account_id, bundle_id, target_date, product_name, product_category, billing_period, price_list_name, options = {}) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/killbill_client/models/invoice.rb', line 94
def create_subscription_dry_run(account_id, bundle_id, target_date, product_name, product_category,
billing_period, price_list_name, options = {})
query_map = {:accountId => account_id}
query_map[:targetDate] = target_date if !target_date.nil?
dry_run = InvoiceDryRunAttributes.new
dry_run.dry_run_action = 'START_BILLING'
dry_run.product_name = product_name
dry_run.product_category = product_category
dry_run.billing_period = billing_period
dry_run.price_list_name = price_list_name
dry_run.bundle_id = bundle_id
begin
res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
dry_run.to_json,
query_map,
{
:user => 'create_subscription_dry_run',
:reason => '',
:comment => '',
}.merge(options),
Invoice
res.refresh(options)
rescue KillBillClient::API::NotFound => e
nil
end
end
|
.find_by_id_or_number(id_or_number, with_items = true, audit = "NONE", options = {}) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/killbill_client/models/invoice.rb', line 14
def find_by_id_or_number(id_or_number, with_items = true, audit = "NONE", options = {})
get "#{KILLBILL_API_INVOICES_PREFIX}/#{id_or_number}",
{
:withItems => with_items,
:audit => audit
},
options
end
|
.find_in_batches(offset = 0, limit = 100, options = {}) ⇒ Object
.find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {}) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/killbill_client/models/invoice.rb', line 32
def find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {})
get "#{KILLBILL_API_INVOICES_PREFIX}/search/#{search_key}",
{
:offset => offset,
:limit => limit
},
options
end
|
.trigger_invoice(account_id, target_date, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/killbill_client/models/invoice.rb', line 49
def trigger_invoice(account_id, target_date, user = nil, reason = nil, = nil, options = {})
query_map = {:accountId => account_id}
query_map[:targetDate] = target_date if !target_date.nil?
begin
res = post "#{KILLBILL_API_INVOICES_PREFIX}/",
{},
query_map,
{
:user => user,
:reason => reason,
:comment => ,
}.merge(options),
Invoice
res.refresh(options)
rescue KillBillClient::API::BadRequest => e
end
end
|
.trigger_invoice_dry_run(account_id, target_date, options = {}) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/killbill_client/models/invoice.rb', line 71
def trigger_invoice_dry_run(account_id, target_date, options = {})
query_map = {:accountId => account_id}
query_map[:targetDate] = target_date if !target_date.nil?
begin
res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}",
{},
query_map,
{
:user => 'trigger_invoice_dry_run',
:reason => '',
:comment => '',
}.merge(options),
Invoice
res.refresh(options)
rescue KillBillClient::API::NotFound => e
nil
end
end
|
Instance Method Details
#payments(with_plugin_info = false, audit = 'NONE', options = {}) ⇒ Object
191
192
193
194
195
196
197
198
199
|
# File 'lib/killbill_client/models/invoice.rb', line 191
def payments(with_plugin_info = false, audit = 'NONE', options = {})
self.class.get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/payments",
{
:withPluginInfo => with_plugin_info,
:audit => audit
},
options,
InvoicePayment
end
|