Class: KillBillClient::Model::Invoice
- Inherits:
-
InvoiceAttributes
- Object
- Resource
- InvoiceAttributes
- KillBillClient::Model::Invoice
- Includes:
- CustomFieldHelper
- Defined in:
- lib/killbill_client/models/invoice.rb
Constant Summary collapse
- KILLBILL_API_INVOICES_PREFIX =
"#{KILLBILL_API_PREFIX}/invoices"
- KILLBILL_API_DRY_RUN_INVOICES_PREFIX =
"#{KILLBILL_API_INVOICES_PREFIX}/dryRun"
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
- .get_catalog_translation(locale, options = {}) ⇒ Object
- .get_invoice_template(is_manual_pay, options = {}) ⇒ Object
- .get_invoice_translation(locale, options = {}) ⇒ Object
- .trigger_invoice(account_id, target_date, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- .trigger_invoice_dry_run(account_id, target_date, upcoming_invoice_target_date, options = {}) ⇒ Object
- .upload_catalog_translation(catalog_translation, locale, delete_if_exists, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- .upload_invoice_template(invoice_template, is_manual_pay, delete_if_exists, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- .upload_invoice_translation(invoice_translation, locale, delete_if_exists, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Instance Method Summary collapse
- #commit(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- #payments(with_plugin_info = false, with_attempts = false, audit = 'NONE', options = {}) ⇒ Object
Methods included from CustomFieldHelper
Class Method Details
.as_html(invoice_id, options = {}) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/killbill_client/models/invoice.rb', line 44 def as_html(invoice_id, = {}) get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/html", {}, { :accept => 'text/html' }.merge() end |
.cancel_subscription_dry_run(account_id, bundle_id, subscription_id, target_date, effective_date, billing_policy, options = {}) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/killbill_client/models/invoice.rb', line 167 def cancel_subscription_dry_run(account_id, bundle_id, subscription_id, target_date, effective_date, billing_policy, = {}) query_map = {:accountId => account_id} query_map[:targetDate] = target_date if !target_date.nil? dry_run = InvoiceDryRunAttributes.new dry_run.dry_run_type = 'SUBSCRIPTION_ACTION' 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(), Invoice res.refresh() rescue KillBillClient::API::NotFound 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
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/killbill_client/models/invoice.rb', line 132 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, = {}) query_map = {:accountId => account_id} query_map[:targetDate] = target_date if !target_date.nil? dry_run = InvoiceDryRunAttributes.new dry_run.dry_run_type = 'SUBSCRIPTION_ACTION' 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(), Invoice res.refresh() rescue KillBillClient::API::NotFound nil end end |
.create_subscription_dry_run(account_id, bundle_id, target_date, product_name, product_category, billing_period, price_list_name, options = {}) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/killbill_client/models/invoice.rb', line 101 def create_subscription_dry_run(account_id, bundle_id, target_date, product_name, product_category, billing_period, price_list_name, = {}) query_map = {:accountId => account_id} query_map[:targetDate] = target_date if !target_date.nil? dry_run = InvoiceDryRunAttributes.new dry_run.dry_run_type = 'SUBSCRIPTION_ACTION' 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(), Invoice res.refresh() rescue KillBillClient::API::NotFound nil end end |
.find_by_id_or_number(id_or_number, with_items = true, audit = "NONE", options = {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/killbill_client/models/invoice.rb', line 17 def find_by_id_or_number(id_or_number, with_items = true, audit = "NONE", = {}) get "#{KILLBILL_API_INVOICES_PREFIX}/#{id_or_number}", { :withItems => with_items, :audit => audit }, end |
.find_in_batches(offset = 0, limit = 100, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/killbill_client/models/invoice.rb', line 26 def find_in_batches(offset = 0, limit = 100, = {}) get "#{KILLBILL_API_INVOICES_PREFIX}/#{Resource::KILLBILL_API_PAGINATION_PREFIX}", { :offset => offset, :limit => limit }, end |
.find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/killbill_client/models/invoice.rb', line 35 def find_in_batches_by_search_key(search_key, offset = 0, limit = 100, = {}) get "#{KILLBILL_API_INVOICES_PREFIX}/search/#{search_key}", { :offset => offset, :limit => limit }, end |
.get_catalog_translation(locale, options = {}) ⇒ Object
267 268 269 270 271 272 273 274 275 276 |
# File 'lib/killbill_client/models/invoice.rb', line 267 def get_catalog_translation(locale, = {}) (, "Retrieving a catalog translation is only supported in multi-tenant mode") get "#{KILLBILL_API_INVOICES_PREFIX}/catalogTranslation/#{locale}", {}, { :head => {'Accept' => 'text/plain'}, }.merge() end |
.get_invoice_template(is_manual_pay, options = {}) ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/killbill_client/models/invoice.rb', line 200 def get_invoice_template(is_manual_pay, = {}) (, "Retrieving an invoice template supported in multi-tenant mode") get "#{KILLBILL_API_INVOICES_PREFIX}/#{is_manual_pay ? "manualPayTemplate" : "template"}", {}, { :head => {'Accept' => 'text/html'}, }.merge() end |
.get_invoice_translation(locale, options = {}) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/killbill_client/models/invoice.rb', line 233 def get_invoice_translation(locale, = {}) (, "Retrieving an invoice translation supported in multi-tenant mode") get "#{KILLBILL_API_INVOICES_PREFIX}/translation/#{locale}", {}, { :head => {'Accept' => 'text/plain'}, }.merge() end |
.trigger_invoice(account_id, target_date, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/killbill_client/models/invoice.rb', line 52 def trigger_invoice(account_id, target_date, user = nil, reason = nil, comment = nil, = {}) 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 => comment, }.merge(), Invoice res.refresh() rescue KillBillClient::API::BadRequest # No invoice to generate : TODO parse json to verify this is indeed the case end end |
.trigger_invoice_dry_run(account_id, target_date, upcoming_invoice_target_date, options = {}) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/killbill_client/models/invoice.rb', line 74 def trigger_invoice_dry_run(account_id, target_date, upcoming_invoice_target_date, = {}) dry_run = InvoiceDryRunAttributes.new dry_run.dry_run_type = upcoming_invoice_target_date ? 'UPCOMING_INVOICE' : 'TARGET_DATE' query_map = {:accountId => account_id} query_map[:targetDate] = target_date if target_date != nil begin res = post "#{KILLBILL_API_DRY_RUN_INVOICES_PREFIX}", dry_run.to_json, query_map, { :user => 'trigger_invoice_dry_run', :reason => '', :comment => '', }.merge(), Invoice res.refresh() rescue KillBillClient::API::NotFound nil end end |
.upload_catalog_translation(catalog_translation, locale, delete_if_exists, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/killbill_client/models/invoice.rb', line 278 def upload_catalog_translation(catalog_translation, locale, delete_if_exists, user = nil, reason = nil, comment = nil, = {}) (, "Uploading a catalog translation is only supported in multi-tenant mode") params = {} params[:deleteIfExists] = delete_if_exists if delete_if_exists post "#{KILLBILL_API_INVOICES_PREFIX}/catalogTranslation/#{locale}", catalog_translation, params, { :head => {'Accept' => 'text/plain'}, :content_type => 'text/plain', :user => user, :reason => reason, :comment => comment, }.merge() get_catalog_translation(locale, ) end |
.upload_invoice_template(invoice_template, is_manual_pay, delete_if_exists, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/killbill_client/models/invoice.rb', line 212 def upload_invoice_template(invoice_template, is_manual_pay, delete_if_exists, user = nil, reason = nil, comment = nil, = {}) (, "Uploading a invoice template is only supported in multi-tenant mode") params = {} params[:deleteIfExists] = delete_if_exists if delete_if_exists post "#{KILLBILL_API_INVOICES_PREFIX}/#{is_manual_pay ? "manualPayTemplate" : "template"}", invoice_template, params, { :head => {'Accept' => 'text/html'}, :content_type => 'text/html', :user => user, :reason => reason, :comment => comment, }.merge() get_invoice_template(is_manual_pay, ) end |
.upload_invoice_translation(invoice_translation, locale, delete_if_exists, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/killbill_client/models/invoice.rb', line 245 def upload_invoice_translation(invoice_translation, locale, delete_if_exists, user = nil, reason = nil, comment = nil, = {}) (, "Uploading a invoice translation is only supported in multi-tenant mode") params = {} params[:deleteIfExists] = delete_if_exists if delete_if_exists post "#{KILLBILL_API_INVOICES_PREFIX}/translation/#{locale}", invoice_translation, params, { :head => {'Accept' => 'text/plain'}, :content_type => 'text/plain', :user => user, :reason => reason, :comment => comment, }.merge() get_invoice_translation(locale, ) end |
Instance Method Details
#commit(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/killbill_client/models/invoice.rb', line 302 def commit(user = nil, reason = nil, comment = nil, = {}) self.class.put "#{Invoice::KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/commitInvoice", nil, {}, { :user => user, :reason => reason, :comment => comment, }.merge() end |
#payments(with_plugin_info = false, with_attempts = false, audit = 'NONE', options = {}) ⇒ Object
315 316 317 318 319 320 321 322 323 324 |
# File 'lib/killbill_client/models/invoice.rb', line 315 def payments(with_plugin_info = false, with_attempts = false, audit = 'NONE', = {}) self.class.get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/payments", { :withAttempts => with_attempts, :withPluginInfo => with_plugin_info, :audit => audit }, , InvoicePayment end |