Class: AdvancedBilling::BillingManifest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::BillingManifest
- Defined in:
- lib/advanced_billing/models/billing_manifest.rb
Overview
BillingManifest Model.
Instance Attribute Summary collapse
-
#end_date ⇒ DateTime
TODO: Write general description for this method.
-
#existing_balance_in_cents ⇒ Integer
TODO: Write general description for this method.
-
#line_items ⇒ Array[BillingManifestItem]
TODO: Write general description for this method.
-
#period_type ⇒ String
TODO: Write general description for this method.
-
#start_date ⇒ DateTime
TODO: Write general description for this method.
-
#subtotal_in_cents ⇒ Integer
TODO: Write general description for this method.
-
#total_discount_in_cents ⇒ Integer
TODO: Write general description for this method.
-
#total_in_cents ⇒ Integer
TODO: Write general description for this method.
-
#total_tax_in_cents ⇒ Integer
TODO: Write general description for this method.
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(line_items: SKIP, total_in_cents: SKIP, total_discount_in_cents: SKIP, total_tax_in_cents: SKIP, subtotal_in_cents: SKIP, start_date: SKIP, end_date: SKIP, period_type: SKIP, existing_balance_in_cents: SKIP, additional_properties: {}) ⇒ BillingManifest
constructor
A new instance of BillingManifest.
- #to_custom_end_date ⇒ Object
- #to_custom_start_date ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(line_items: SKIP, total_in_cents: SKIP, total_discount_in_cents: SKIP, total_tax_in_cents: SKIP, subtotal_in_cents: SKIP, start_date: SKIP, end_date: SKIP, period_type: SKIP, existing_balance_in_cents: SKIP, additional_properties: {}) ⇒ BillingManifest
Returns a new instance of BillingManifest.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 88 def initialize(line_items: SKIP, total_in_cents: SKIP, total_discount_in_cents: SKIP, total_tax_in_cents: SKIP, subtotal_in_cents: SKIP, start_date: SKIP, end_date: SKIP, period_type: SKIP, existing_balance_in_cents: SKIP, additional_properties: {}) @line_items = line_items unless line_items == SKIP @total_in_cents = total_in_cents unless total_in_cents == SKIP @total_discount_in_cents = total_discount_in_cents unless total_discount_in_cents == SKIP @total_tax_in_cents = total_tax_in_cents unless total_tax_in_cents == SKIP @subtotal_in_cents = subtotal_in_cents unless subtotal_in_cents == SKIP @start_date = start_date unless start_date == SKIP @end_date = end_date unless end_date == SKIP @period_type = period_type unless period_type == SKIP unless existing_balance_in_cents == SKIP @existing_balance_in_cents = existing_balance_in_cents end # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#end_date ⇒ DateTime
TODO: Write general description for this method
39 40 41 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 39 def end_date @end_date end |
#existing_balance_in_cents ⇒ Integer
TODO: Write general description for this method
47 48 49 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 47 def existing_balance_in_cents @existing_balance_in_cents end |
#line_items ⇒ Array[BillingManifestItem]
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 15 def line_items @line_items end |
#period_type ⇒ String
TODO: Write general description for this method
43 44 45 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 43 def period_type @period_type end |
#start_date ⇒ DateTime
TODO: Write general description for this method
35 36 37 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 35 def start_date @start_date end |
#subtotal_in_cents ⇒ Integer
TODO: Write general description for this method
31 32 33 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 31 def subtotal_in_cents @subtotal_in_cents end |
#total_discount_in_cents ⇒ Integer
TODO: Write general description for this method
23 24 25 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 23 def total_discount_in_cents @total_discount_in_cents end |
#total_in_cents ⇒ Integer
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 19 def total_in_cents @total_in_cents end |
#total_tax_in_cents ⇒ Integer
TODO: Write general description for this method
27 28 29 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 27 def total_tax_in_cents @total_tax_in_cents end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
113 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 156 157 158 159 160 161 162 163 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 113 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # 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 << (BillingManifestItem.from_hash(structure) if structure) end end line_items = SKIP unless hash.key?('line_items') total_in_cents = hash.key?('total_in_cents') ? hash['total_in_cents'] : SKIP total_discount_in_cents = hash.key?('total_discount_in_cents') ? hash['total_discount_in_cents'] : SKIP total_tax_in_cents = hash.key?('total_tax_in_cents') ? hash['total_tax_in_cents'] : SKIP subtotal_in_cents = hash.key?('subtotal_in_cents') ? hash['subtotal_in_cents'] : SKIP start_date = if hash.key?('start_date') (DateTimeHelper.from_rfc3339(hash['start_date']) if hash['start_date']) else SKIP end end_date = if hash.key?('end_date') (DateTimeHelper.from_rfc3339(hash['end_date']) if hash['end_date']) else SKIP end period_type = hash.key?('period_type') ? hash['period_type'] : SKIP existing_balance_in_cents = hash.key?('existing_balance_in_cents') ? hash['existing_balance_in_cents'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. BillingManifest.new(line_items: line_items, total_in_cents: total_in_cents, total_discount_in_cents: total_discount_in_cents, total_tax_in_cents: total_tax_in_cents, subtotal_in_cents: subtotal_in_cents, start_date: start_date, end_date: end_date, period_type: period_type, existing_balance_in_cents: existing_balance_in_cents, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 50 def self.names @_hash = {} if @_hash.nil? @_hash['line_items'] = 'line_items' @_hash['total_in_cents'] = 'total_in_cents' @_hash['total_discount_in_cents'] = 'total_discount_in_cents' @_hash['total_tax_in_cents'] = 'total_tax_in_cents' @_hash['subtotal_in_cents'] = 'subtotal_in_cents' @_hash['start_date'] = 'start_date' @_hash['end_date'] = 'end_date' @_hash['period_type'] = 'period_type' @_hash['existing_balance_in_cents'] = 'existing_balance_in_cents' @_hash end |
.nullables ⇒ Object
An array for nullable fields
80 81 82 83 84 85 86 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 80 def self.nullables %w[ start_date end_date period_type ] end |
.optionals ⇒ Object
An array for optional fields
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 65 def self.optionals %w[ line_items total_in_cents total_discount_in_cents total_tax_in_cents subtotal_in_cents start_date end_date period_type existing_balance_in_cents ] end |
Instance Method Details
#to_custom_end_date ⇒ Object
169 170 171 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 169 def to_custom_end_date DateTimeHelper.to_rfc3339(end_date) end |
#to_custom_start_date ⇒ Object
165 166 167 |
# File 'lib/advanced_billing/models/billing_manifest.rb', line 165 def to_custom_start_date DateTimeHelper.to_rfc3339(start_date) end |