Class: ApiReference::CreditNoteLineItemDiscount
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::CreditNoteLineItemDiscount
- Defined in:
- lib/api_reference/models/credit_note_line_item_discount.rb
Overview
CreditNoteLineItemDiscount Model.
Instance Attribute Summary collapse
-
#amount_applied ⇒ String
TODO: Write general description for this method.
-
#amount_discount ⇒ String
TODO: Write general description for this method.
-
#applies_to_price_ids ⇒ Array[String]
TODO: Write general description for this method.
-
#discount_type ⇒ DiscountType1
TODO: Write general description for this method.
-
#id ⇒ String
TODO: Write general description for this method.
-
#percentage_discount ⇒ Float
TODO: Write general description for this method.
-
#reason ⇒ String
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id:, discount_type:, percentage_discount:, amount_applied:, applies_to_price_ids:, amount_discount: SKIP, reason: SKIP, additional_properties: nil) ⇒ CreditNoteLineItemDiscount
constructor
A new instance of CreditNoteLineItemDiscount.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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:, discount_type:, percentage_discount:, amount_applied:, applies_to_price_ids:, amount_discount: SKIP, reason: SKIP, additional_properties: nil) ⇒ CreditNoteLineItemDiscount
Returns a new instance of CreditNoteLineItemDiscount.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 69 def initialize(id:, discount_type:, percentage_discount:, amount_applied:, applies_to_price_ids:, amount_discount: SKIP, reason: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @discount_type = discount_type @percentage_discount = percentage_discount @amount_discount = amount_discount unless amount_discount == SKIP @amount_applied = amount_applied @reason = reason unless reason == SKIP @applies_to_price_ids = applies_to_price_ids @additional_properties = additional_properties end |
Instance Attribute Details
#amount_applied ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 30 def amount_applied @amount_applied end |
#amount_discount ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 26 def amount_discount @amount_discount end |
#applies_to_price_ids ⇒ Array[String]
TODO: Write general description for this method
38 39 40 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 38 def applies_to_price_ids @applies_to_price_ids end |
#discount_type ⇒ DiscountType1
TODO: Write general description for this method
18 19 20 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 18 def discount_type @discount_type end |
#id ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 14 def id @id end |
#percentage_discount ⇒ Float
TODO: Write general description for this method
22 23 24 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 22 def percentage_discount @percentage_discount end |
#reason ⇒ String
TODO: Write general description for this method
34 35 36 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 34 def reason @reason end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
86 87 88 89 90 91 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 118 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 86 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil discount_type = hash.key?('discount_type') ? hash['discount_type'] : nil percentage_discount = hash.key?('percentage_discount') ? hash['percentage_discount'] : nil amount_applied = hash.key?('amount_applied') ? hash['amount_applied'] : nil applies_to_price_ids = hash.key?('applies_to_price_ids') ? hash['applies_to_price_ids'] : nil amount_discount = hash.key?('amount_discount') ? hash['amount_discount'] : SKIP reason = hash.key?('reason') ? hash['reason'] : SKIP # 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. CreditNoteLineItemDiscount.new(id: id, discount_type: discount_type, percentage_discount: percentage_discount, amount_applied: amount_applied, applies_to_price_ids: applies_to_price_ids, amount_discount: amount_discount, reason: reason, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['discount_type'] = 'discount_type' @_hash['percentage_discount'] = 'percentage_discount' @_hash['amount_discount'] = 'amount_discount' @_hash['amount_applied'] = 'amount_applied' @_hash['reason'] = 'reason' @_hash['applies_to_price_ids'] = 'applies_to_price_ids' @_hash end |
.nullables ⇒ Object
An array for nullable fields
62 63 64 65 66 67 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 62 def self.nullables %w[ amount_discount reason ] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 54 def self.optionals %w[ amount_discount reason ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
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 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 122 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.discount_type, ->(val) { DiscountType1.validate(val) }) and APIHelper.valid_type?(value.percentage_discount, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.amount_applied, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.applies_to_price_ids, ->(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['discount_type'], ->(val) { DiscountType1.validate(val) }) and APIHelper.valid_type?(value['percentage_discount'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['amount_applied'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['applies_to_price_ids'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
164 165 166 167 168 169 170 171 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 164 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, discount_type: #{@discount_type.inspect},"\ " percentage_discount: #{@percentage_discount.inspect}, amount_discount:"\ " #{@amount_discount.inspect}, amount_applied: #{@amount_applied.inspect}, reason:"\ " #{@reason.inspect}, applies_to_price_ids: #{@applies_to_price_ids.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
155 156 157 158 159 160 161 |
# File 'lib/api_reference/models/credit_note_line_item_discount.rb', line 155 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, discount_type: #{@discount_type}, percentage_discount:"\ " #{@percentage_discount}, amount_discount: #{@amount_discount}, amount_applied:"\ " #{@amount_applied}, reason: #{@reason}, applies_to_price_ids: #{@applies_to_price_ids},"\ " additional_properties: #{@additional_properties}>" end |