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
Generate an invoice in advance for a subscription’s next renewal date.
-
#read_advance_invoice(subscription_id) ⇒ Invoice
Once an advance invoice has been generated for a subscription’s upcoming renewal, it can be viewed through this endpoint.
-
#void_advance_invoice(subscription_id, body: nil) ⇒ Invoice
Void a subscription’s existing advance invoice.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #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
Generate an invoice in advance for a subscription’s next renewal date. [Please see our docs](maxio.zendesk.com/hc/en-us/articles/24252026404749-Issue-Inv oice-In-Advance) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided. A subscription may only have one advance invoice per billing period. Attempting to issue an advance invoice when one already exists will return an error. That said, regeneration of the invoice may be forced with the params ‘force: true`, which will void an advance invoice if one exists and generate a new one. If no advance invoice exists, a new one will be generated. We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it. the subscription
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) new_api_call_builder .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
Once an advance invoice has been generated for a subscription’s upcoming renewal, it can be viewed through this endpoint. 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) new_api_call_builder .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
Void a subscription’s existing advance invoice. Once voided, it can later be regenerated if desired. A ‘reason` is required in order to void, and the invoice must have an open status. Voiding will cause 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, please [see our help docs]($m/Invoice). the subscription
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/advanced_billing/controllers/advance_invoice_controller.rb', line 92 def void_advance_invoice(subscription_id, body: nil) new_api_call_builder .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 |