Class: AdvancedBilling::RenewalPreview
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::RenewalPreview
- Defined in:
- lib/advanced_billing/models/renewal_preview.rb
Overview
RenewalPreview Model.
Instance Attribute Summary collapse
-
#existing_balance_in_cents ⇒ Integer
An integer representing the amount of the subscription’s current balance.
-
#line_items ⇒ Array[RenewalPreviewLineItem]
An array of objects representing the individual transactions that will be created at the next renewal.
-
#next_assessment_at ⇒ String
The timestamp for the subscription’s next renewal.
-
#subtotal_in_cents ⇒ Integer
An integer representing the amount of the total pre-tax, pre-discount charges that will be assessed at the next renewal.
-
#total_amount_due_in_cents ⇒ Integer
An integer representing the existing_balance_in_cents plus the total_in_cents.
-
#total_discount_in_cents ⇒ Integer
An integer representing the amount of the coupon discounts that will be applied to the next renewal.
-
#total_in_cents ⇒ Integer
An integer representing the total amount owed, less any discounts, that will be assessed at the next renewal.
-
#total_tax_in_cents ⇒ Integer
An integer representing the total tax charges that will be assessed at the next renewal.
-
#uncalculated_taxes ⇒ TrueClass | FalseClass
A boolean indicating whether or not additional taxes will be calculated at the time of renewal.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(next_assessment_at = SKIP, subtotal_in_cents = SKIP, total_tax_in_cents = SKIP, total_discount_in_cents = SKIP, total_in_cents = SKIP, existing_balance_in_cents = SKIP, total_amount_due_in_cents = SKIP, uncalculated_taxes = SKIP, line_items = SKIP) ⇒ RenewalPreview
constructor
A new instance of RenewalPreview.
Methods inherited from BaseModel
Constructor Details
#initialize(next_assessment_at = SKIP, subtotal_in_cents = SKIP, total_tax_in_cents = SKIP, total_discount_in_cents = SKIP, total_in_cents = SKIP, existing_balance_in_cents = SKIP, total_amount_due_in_cents = SKIP, uncalculated_taxes = SKIP, line_items = SKIP) ⇒ RenewalPreview
Returns a new instance of RenewalPreview.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 91 def initialize(next_assessment_at = SKIP, subtotal_in_cents = SKIP, total_tax_in_cents = SKIP, total_discount_in_cents = SKIP, total_in_cents = SKIP, existing_balance_in_cents = SKIP, total_amount_due_in_cents = SKIP, uncalculated_taxes = SKIP, line_items = SKIP) @next_assessment_at = next_assessment_at unless next_assessment_at == SKIP @subtotal_in_cents = subtotal_in_cents unless subtotal_in_cents == SKIP @total_tax_in_cents = total_tax_in_cents unless total_tax_in_cents == SKIP @total_discount_in_cents = total_discount_in_cents unless total_discount_in_cents == SKIP @total_in_cents = total_in_cents unless total_in_cents == SKIP unless existing_balance_in_cents == SKIP @existing_balance_in_cents = existing_balance_in_cents end unless total_amount_due_in_cents == SKIP @total_amount_due_in_cents = total_amount_due_in_cents end @uncalculated_taxes = uncalculated_taxes unless uncalculated_taxes == SKIP @line_items = line_items unless line_items == SKIP end |
Instance Attribute Details
#existing_balance_in_cents ⇒ Integer
An integer representing the amount of the subscription’s current balance
38 39 40 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 38 def existing_balance_in_cents @existing_balance_in_cents end |
#line_items ⇒ Array[RenewalPreviewLineItem]
An array of objects representing the individual transactions that will be created at the next renewal
54 55 56 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 54 def line_items @line_items end |
#next_assessment_at ⇒ String
The timestamp for the subscription’s next renewal
14 15 16 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 14 def next_assessment_at @next_assessment_at end |
#subtotal_in_cents ⇒ Integer
An integer representing the amount of the total pre-tax, pre-discount charges that will be assessed at the next renewal
19 20 21 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 19 def subtotal_in_cents @subtotal_in_cents end |
#total_amount_due_in_cents ⇒ Integer
An integer representing the existing_balance_in_cents plus the total_in_cents
43 44 45 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 43 def total_amount_due_in_cents @total_amount_due_in_cents end |
#total_discount_in_cents ⇒ Integer
An integer representing the amount of the coupon discounts that will be applied to the next renewal
29 30 31 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 29 def total_discount_in_cents @total_discount_in_cents end |
#total_in_cents ⇒ Integer
An integer representing the total amount owed, less any discounts, that will be assessed at the next renewal
34 35 36 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 34 def total_in_cents @total_in_cents end |
#total_tax_in_cents ⇒ Integer
An integer representing the total tax charges that will be assessed at the next renewal
24 25 26 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 24 def total_tax_in_cents @total_tax_in_cents end |
#uncalculated_taxes ⇒ TrueClass | FalseClass
A boolean indicating whether or not additional taxes will be calculated at the time of renewal. This will be true if you are using Avalara and the address of the subscription is in one of your defined taxable regions.
49 50 51 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 49 def uncalculated_taxes @uncalculated_taxes end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
114 115 116 117 118 119 120 121 122 123 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/advanced_billing/models/renewal_preview.rb', line 114 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. next_assessment_at = hash.key?('next_assessment_at') ? hash['next_assessment_at'] : SKIP subtotal_in_cents = hash.key?('subtotal_in_cents') ? hash['subtotal_in_cents'] : SKIP total_tax_in_cents = hash.key?('total_tax_in_cents') ? hash['total_tax_in_cents'] : SKIP total_discount_in_cents = hash.key?('total_discount_in_cents') ? hash['total_discount_in_cents'] : SKIP total_in_cents = hash.key?('total_in_cents') ? hash['total_in_cents'] : SKIP existing_balance_in_cents = hash.key?('existing_balance_in_cents') ? hash['existing_balance_in_cents'] : SKIP total_amount_due_in_cents = hash.key?('total_amount_due_in_cents') ? hash['total_amount_due_in_cents'] : SKIP uncalculated_taxes = hash.key?('uncalculated_taxes') ? hash['uncalculated_taxes'] : SKIP # Parameter is an array, so we need to iterate through it line_items = nil unless hash['line_items'].nil? line_items = [] hash['line_items'].each do |structure| line_items << (RenewalPreviewLineItem.from_hash(structure) if structure) end end line_items = SKIP unless hash.key?('line_items') # Create object from extracted values. RenewalPreview.new(next_assessment_at, subtotal_in_cents, total_tax_in_cents, total_discount_in_cents, total_in_cents, existing_balance_in_cents, total_amount_due_in_cents, uncalculated_taxes, line_items) end |
.names ⇒ Object
A mapping from model property names to API property names.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 57 def self.names @_hash = {} if @_hash.nil? @_hash['next_assessment_at'] = 'next_assessment_at' @_hash['subtotal_in_cents'] = 'subtotal_in_cents' @_hash['total_tax_in_cents'] = 'total_tax_in_cents' @_hash['total_discount_in_cents'] = 'total_discount_in_cents' @_hash['total_in_cents'] = 'total_in_cents' @_hash['existing_balance_in_cents'] = 'existing_balance_in_cents' @_hash['total_amount_due_in_cents'] = 'total_amount_due_in_cents' @_hash['uncalculated_taxes'] = 'uncalculated_taxes' @_hash['line_items'] = 'line_items' @_hash end |
.nullables ⇒ Object
An array for nullable fields
87 88 89 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 87 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 72 def self.optionals %w[ next_assessment_at subtotal_in_cents total_tax_in_cents total_discount_in_cents total_in_cents existing_balance_in_cents total_amount_due_in_cents uncalculated_taxes line_items ] end |