Class: NewStoreApi::PriceOverride
- Defined in:
- lib/new_store_api/models/price_override.rb
Overview
A manual price override applied to an item. The overridden amount is carried
by the sibling price field; this object only records why it was applied.
Instance Attribute Summary collapse
-
#note ⇒ String
Optional free-text note explaining the override.
-
#reason_type ⇒ ReasonTypeEnum
Whether the override cites a predefined reason code or a free-text custom reason.
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(reason_type = nil, note = SKIP) ⇒ PriceOverride
constructor
A new instance of PriceOverride.
-
#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(reason_type = nil, note = SKIP) ⇒ PriceOverride
Returns a new instance of PriceOverride.
44 45 46 47 |
# File 'lib/new_store_api/models/price_override.rb', line 44 def initialize(reason_type = nil, note = SKIP) @note = note unless note == SKIP @reason_type = reason_type end |
Instance Attribute Details
#note ⇒ String
Optional free-text note explaining the override.
15 16 17 |
# File 'lib/new_store_api/models/price_override.rb', line 15 def note @note end |
#reason_type ⇒ ReasonTypeEnum
Whether the override cites a predefined reason code or a free-text custom reason.
20 21 22 |
# File 'lib/new_store_api/models/price_override.rb', line 20 def reason_type @reason_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/new_store_api/models/price_override.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. reason_type = hash.key?('reason_type') ? hash['reason_type'] : nil note = hash.key?('note') ? hash['note'] : SKIP # Create object from extracted values. PriceOverride.new(reason_type, note) end |
.names ⇒ Object
A mapping from model property names to API property names.
23 24 25 26 27 28 |
# File 'lib/new_store_api/models/price_override.rb', line 23 def self.names @_hash = {} if @_hash.nil? @_hash['note'] = 'note' @_hash['reason_type'] = 'reason_type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
38 39 40 41 42 |
# File 'lib/new_store_api/models/price_override.rb', line 38 def self.nullables %w[ note ] end |
.optionals ⇒ Object
An array for optional fields
31 32 33 34 35 |
# File 'lib/new_store_api/models/price_override.rb', line 31 def self.optionals %w[ note ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/new_store_api/models/price_override.rb', line 64 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.reason_type, ->(val) { ReasonTypeEnum.validate(val) }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['reason_type'], ->(val) { ReasonTypeEnum.validate(val) }) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
83 84 85 86 |
# File 'lib/new_store_api/models/price_override.rb', line 83 def inspect class_name = self.class.name.split('::').last "<#{class_name} note: #{@note.inspect}, reason_type: #{@reason_type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
77 78 79 80 |
# File 'lib/new_store_api/models/price_override.rb', line 77 def to_s class_name = self.class.name.split('::').last "<#{class_name} note: #{@note}, reason_type: #{@reason_type}>" end |