Class: AdvancedBilling::AdvanceInvoiceController
- Inherits:
-
BaseController
- Object
- BaseController
- AdvancedBilling::AdvanceInvoiceController
- Defined in:
- lib/advanced_billing/controllers/advance_invoice_controller.rb
Overview
AdvanceInvoiceController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#issue_advance_invoice(subscription_id, body: nil) ⇒ Invoice
Issues an invoice in advance for a subscription's next renewal date.
-
#read_advance_invoice(subscription_id) ⇒ Invoice
Returns the advance invoice generated for a subscription's upcoming renewal.
-
#void_advance_invoice(subscription_id, body: nil) ⇒ Invoice
Voids a subscription's existing advance invoice.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from AdvancedBilling::BaseController
Instance Method Details
#issue_advance_invoice(subscription_id, body: nil) ⇒ Invoice
Issues an invoice in advance for a subscription's next renewal date. For
the most part, advance invoices function like any other invoice, except
they are issued early and have special behavior upon being voided. For
more information on advance invoices, including eligibility for generating
one, see [Issue Invoice In
Advance](https://maxio.zendesk.com/hc/en-us/articles/24252026404749-Issue-
Invoice-In-Advance).
A subscription can only have one advance invoice per billing period.
Attempting to issue an advance invoice when one already exists returns an
error.
Regeneration of the invoice can be forced with the params force: true,
which voids an advance invoice if one exists and generates a new one. If
no advance invoice exists, a new one is generated.
Consider using either the create or preview endpoints for proforma
invoices to preview this advance invoice before using this endpoint to
generate it.
the subscription.
description here
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/advanced_billing/controllers/advance_invoice_controller.rb', line 30 def issue_advance_invoice(subscription_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/advance_invoice/issue.json', Server::PRODUCTION) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Invoice.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .execute end |
#read_advance_invoice(subscription_id) ⇒ Invoice
Returns the advance invoice generated for a subscription's upcoming renewal. There can only be one advance invoice per subscription per billing cycle. the subscription.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/advanced_billing/controllers/advance_invoice_controller.rb', line 63 def read_advance_invoice(subscription_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/subscriptions/{subscription_id}/advance_invoice.json', Server::PRODUCTION) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Invoice.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException)) .execute end |
#void_advance_invoice(subscription_id, body: nil) ⇒ Invoice
Voids a subscription's existing advance invoice. Once voided, it can later
be regenerated if desired.
A reason is required to void, and the invoice must have an open status.
Voiding causes any prepayments and credits that were applied to the
invoice to be returned to the subscription.
For a full overview of the impact of voiding, see Invoice.
the subscription.
description here
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/controllers/advance_invoice_controller.rb', line 93 def void_advance_invoice(subscription_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/subscriptions/{subscription_id}/advance_invoice/void.json', Server::PRODUCTION) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Invoice.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException)) .execute end |