Class: ApiReference::CreditNoteLineItem
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::CreditNoteLineItem
- Defined in:
- lib/api_reference/models/credit_note_line_item.rb
Overview
CreditNoteLineItem Model.
Instance Attribute Summary collapse
-
#amount ⇒ String
The amount of the line item, including any line item minimums and discounts.
-
#discounts ⇒ Array[CreditNoteLineItemDiscount]
Any line item discounts from the invoice's line item.
-
#end_time_exclusive ⇒ DateTime
The end time of the service period for this credit note line item.
-
#id ⇒ String
The Orb id of this resource.
-
#item_id ⇒ String
The id of the item associated with this line item.
-
#name ⇒ String
The name of the corresponding invoice line item.
-
#quantity ⇒ Float
An optional quantity credited.
-
#start_time_inclusive ⇒ DateTime
The start time of the service period for this credit note line item.
-
#subtotal ⇒ String
The amount of the line item, excluding any line item minimums and discounts.
-
#tax_amounts ⇒ Array[TaxAmount]
Any tax amounts applied onto the line item.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id:, name:, subtotal:, amount:, quantity:, tax_amounts:, item_id:, discounts: SKIP, start_time_inclusive: SKIP, end_time_exclusive: SKIP, additional_properties: nil) ⇒ CreditNoteLineItem
constructor
A new instance of CreditNoteLineItem.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_end_time_exclusive ⇒ Object
- #to_custom_start_time_inclusive ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id:, name:, subtotal:, amount:, quantity:, tax_amounts:, item_id:, discounts: SKIP, start_time_inclusive: SKIP, end_time_exclusive: SKIP, additional_properties: nil) ⇒ CreditNoteLineItem
Returns a new instance of CreditNoteLineItem.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 89 def initialize(id:, name:, subtotal:, amount:, quantity:, tax_amounts:, item_id:, discounts: SKIP, start_time_inclusive: SKIP, end_time_exclusive: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @name = name @subtotal = subtotal @amount = amount @quantity = quantity @discounts = discounts unless discounts == SKIP @tax_amounts = tax_amounts @item_id = item_id @start_time_inclusive = start_time_inclusive unless start_time_inclusive == SKIP @end_time_exclusive = end_time_exclusive unless end_time_exclusive == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ String
The amount of the line item, including any line item minimums and discounts.
29 30 31 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 29 def amount @amount end |
#discounts ⇒ Array[CreditNoteLineItemDiscount]
Any line item discounts from the invoice's line item.
37 38 39 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 37 def discounts @discounts end |
#end_time_exclusive ⇒ DateTime
The end time of the service period for this credit note line item.
53 54 55 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 53 def end_time_exclusive @end_time_exclusive end |
#id ⇒ String
The Orb id of this resource.
15 16 17 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 15 def id @id end |
#item_id ⇒ String
The id of the item associated with this line item.
45 46 47 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 45 def item_id @item_id end |
#name ⇒ String
The name of the corresponding invoice line item.
19 20 21 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 19 def name @name end |
#quantity ⇒ Float
An optional quantity credited.
33 34 35 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 33 def quantity @quantity end |
#start_time_inclusive ⇒ DateTime
The start time of the service period for this credit note line item.
49 50 51 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 49 def start_time_inclusive @start_time_inclusive end |
#subtotal ⇒ String
The amount of the line item, excluding any line item minimums and discounts.
24 25 26 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 24 def subtotal @subtotal end |
#tax_amounts ⇒ Array[TaxAmount]
Any tax amounts applied onto the line item.
41 42 43 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 41 def tax_amounts @tax_amounts end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
109 110 111 112 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 164 165 166 167 168 169 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 109 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil name = hash.key?('name') ? hash['name'] : nil subtotal = hash.key?('subtotal') ? hash['subtotal'] : nil amount = hash.key?('amount') ? hash['amount'] : nil quantity = hash.key?('quantity') ? hash['quantity'] : nil # Parameter is an array, so we need to iterate through it tax_amounts = nil unless hash['tax_amounts'].nil? tax_amounts = [] hash['tax_amounts'].each do |structure| tax_amounts << (TaxAmount.from_hash(structure) if structure) end end tax_amounts = nil unless hash.key?('tax_amounts') item_id = hash.key?('item_id') ? hash['item_id'] : nil # Parameter is an array, so we need to iterate through it discounts = nil unless hash['discounts'].nil? discounts = [] hash['discounts'].each do |structure| discounts << (CreditNoteLineItemDiscount.from_hash(structure) if structure) end end discounts = SKIP unless hash.key?('discounts') start_time_inclusive = if hash.key?('start_time_inclusive') (DateTimeHelper.from_rfc3339(hash['start_time_inclusive']) if hash['start_time_inclusive']) else SKIP end end_time_exclusive = if hash.key?('end_time_exclusive') (DateTimeHelper.from_rfc3339(hash['end_time_exclusive']) if hash['end_time_exclusive']) else SKIP end # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. CreditNoteLineItem.new(id: id, name: name, subtotal: subtotal, amount: amount, quantity: quantity, tax_amounts: tax_amounts, item_id: item_id, discounts: discounts, start_time_inclusive: start_time_inclusive, end_time_exclusive: end_time_exclusive, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 56 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['subtotal'] = 'subtotal' @_hash['amount'] = 'amount' @_hash['quantity'] = 'quantity' @_hash['discounts'] = 'discounts' @_hash['tax_amounts'] = 'tax_amounts' @_hash['item_id'] = 'item_id' @_hash['start_time_inclusive'] = 'start_time_inclusive' @_hash['end_time_exclusive'] = 'end_time_exclusive' @_hash end |
.nullables ⇒ Object
An array for nullable fields
81 82 83 84 85 86 87 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 81 def self.nullables %w[ quantity start_time_inclusive end_time_exclusive ] end |
.optionals ⇒ Object
An array for optional fields
72 73 74 75 76 77 78 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 72 def self.optionals %w[ discounts start_time_inclusive end_time_exclusive ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 181 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.name, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.subtotal, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.quantity, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.tax_amounts, ->(val) { TaxAmount.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.item_id, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['name'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['subtotal'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['quantity'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['tax_amounts'], ->(val) { TaxAmount.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['item_id'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
235 236 237 238 239 240 241 242 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 235 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, subtotal: #{@subtotal.inspect},"\ " amount: #{@amount.inspect}, quantity: #{@quantity.inspect}, discounts:"\ " #{@discounts.inspect}, tax_amounts: #{@tax_amounts.inspect}, item_id: #{@item_id.inspect},"\ " start_time_inclusive: #{@start_time_inclusive.inspect}, end_time_exclusive:"\ " #{@end_time_exclusive.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_end_time_exclusive ⇒ Object
175 176 177 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 175 def to_custom_end_time_exclusive DateTimeHelper.to_rfc3339(end_time_exclusive) end |
#to_custom_start_time_inclusive ⇒ Object
171 172 173 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 171 def to_custom_start_time_inclusive DateTimeHelper.to_rfc3339(start_time_inclusive) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
226 227 228 229 230 231 232 |
# File 'lib/api_reference/models/credit_note_line_item.rb', line 226 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, name: #{@name}, subtotal: #{@subtotal}, amount: #{@amount},"\ " quantity: #{@quantity}, discounts: #{@discounts}, tax_amounts: #{@tax_amounts}, item_id:"\ " #{@item_id}, start_time_inclusive: #{@start_time_inclusive}, end_time_exclusive:"\ " #{@end_time_exclusive}, additional_properties: #{@additional_properties}>" end |