Class: AdvancedBilling::IssueInvoiceRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/issue_invoice_request.rb

Overview

IssueInvoiceRequest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(on_failed_payment: FailedPaymentAction::LEAVE_OPEN_INVOICE, additional_properties: {}) ⇒ IssueInvoiceRequest

Returns a new instance of IssueInvoiceRequest.



47
48
49
50
51
52
53
54
55
# File 'lib/advanced_billing/models/issue_invoice_request.rb', line 47

def initialize(on_failed_payment: FailedPaymentAction::LEAVE_OPEN_INVOICE,
               additional_properties: {})
  @on_failed_payment = on_failed_payment unless on_failed_payment == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#on_failed_paymentFailedPaymentAction

Action taken when payment for an invoice fails:

  • ‘leave_open_invoice` - prepayments and credits applied to invoice;

invoice status set to “open”; email sent to the customer for the issued invoice (if setting applies); payment failure recorded in the invoice history. This is the default option.

  • ‘rollback_to_pending` - prepayments and credits not applied; invoice

remains in “pending” status; no email sent to the customer; payment failure recorded in the invoice history.

  • ‘initiate_dunning` - prepayments and credits applied to the invoice;

invoice status set to “open”; email sent to the customer for the issued invoice (if setting applies); payment failure recorded in the invoice history; subscription will most likely go into “past_due” or “canceled” state (depending upon net terms and dunning settings).

Returns:



26
27
28
# File 'lib/advanced_billing/models/issue_invoice_request.rb', line 26

def on_failed_payment
  @on_failed_payment
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/advanced_billing/models/issue_invoice_request.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  on_failed_payment =
    hash['on_failed_payment'] ||= FailedPaymentAction::LEAVE_OPEN_INVOICE

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  IssueInvoiceRequest.new(on_failed_payment: on_failed_payment,
                          additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
# File 'lib/advanced_billing/models/issue_invoice_request.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['on_failed_payment'] = 'on_failed_payment'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/advanced_billing/models/issue_invoice_request.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
# File 'lib/advanced_billing/models/issue_invoice_request.rb', line 36

def self.optionals
  %w[
    on_failed_payment
  ]
end