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 ⇒ DateTime
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, additional_properties: {}) ⇒ RenewalPreview
constructor
A new instance of RenewalPreview.
- #to_custom_next_assessment_at ⇒ Object
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, additional_properties: {}) ⇒ RenewalPreview
Returns a new instance of RenewalPreview.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 92 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, additional_properties: {}) @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 # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#existing_balance_in_cents ⇒ Integer
An integer representing the amount of the subscription’s current balance
39 40 41 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 39 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
55 56 57 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 55 def line_items @line_items end |
#next_assessment_at ⇒ DateTime
The timestamp for the subscription’s next renewal
15 16 17 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 15 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
20 21 22 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 20 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
44 45 46 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 44 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
30 31 32 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 30 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
35 36 37 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 35 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
25 26 27 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 25 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.
50 51 52 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 50 def uncalculated_taxes @uncalculated_taxes end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 120 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. next_assessment_at = if hash.key?('next_assessment_at') (DateTimeHelper.from_rfc3339(hash['next_assessment_at']) if hash['next_assessment_at']) else SKIP end 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') # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. RenewalPreview.new(next_assessment_at: next_assessment_at, subtotal_in_cents: subtotal_in_cents, total_tax_in_cents: total_tax_in_cents, total_discount_in_cents: total_discount_in_cents, total_in_cents: total_in_cents, existing_balance_in_cents: existing_balance_in_cents, total_amount_due_in_cents: total_amount_due_in_cents, uncalculated_taxes: uncalculated_taxes, line_items: line_items, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 58 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
88 89 90 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 88 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 73 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 |
Instance Method Details
#to_custom_next_assessment_at ⇒ Object
170 171 172 |
# File 'lib/advanced_billing/models/renewal_preview.rb', line 170 def to_custom_next_assessment_at DateTimeHelper.to_rfc3339(next_assessment_at) end |