Class: NewStoreApi::InjectedOrderDiscountInfo
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::InjectedOrderDiscountInfo
- Defined in:
- lib/new_store_api/models/injected_order_discount_info.rb
Overview
InjectedOrderDiscountInfo Model.
Instance Attribute Summary collapse
-
#coupon_code ⇒ String
TODO: Write general description for this method.
-
#description ⇒ String
TODO: Write general description for this method.
-
#discount_ref ⇒ String
A string token identifying the discount, e.g.
-
#original_value ⇒ Float
Discount applied.
-
#price_adjustment ⇒ Float
Monetary discount amount applied to the current item.
-
#type ⇒ String
readonly
Monetary discount amount applied to the current 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(discount_ref = nil, original_value = nil, price_adjustment = nil, coupon_code = SKIP, description = SKIP) ⇒ InjectedOrderDiscountInfo
constructor
A new instance of InjectedOrderDiscountInfo.
-
#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(discount_ref = nil, original_value = nil, price_adjustment = nil, coupon_code = SKIP, description = SKIP) ⇒ InjectedOrderDiscountInfo
Returns a new instance of InjectedOrderDiscountInfo.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 63 def initialize(discount_ref = nil, original_value = nil, price_adjustment = nil, coupon_code = SKIP, description = SKIP) @coupon_code = coupon_code unless coupon_code == SKIP @description = description unless description == SKIP @discount_ref = discount_ref @original_value = original_value @price_adjustment = price_adjustment @type = 'fixed' end |
Instance Attribute Details
#coupon_code ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 14 def coupon_code @coupon_code end |
#description ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 18 def description @description end |
#discount_ref ⇒ String
A string token identifying the discount, e.g. BLACK_FRIDAY_SALE.
22 23 24 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 22 def discount_ref @discount_ref end |
#original_value ⇒ Float
Discount applied. In the case of an item_discount_info, the discount is applied to the item itself. In the case of an item_order_discount_info, the discount is applied to the whole order.
28 29 30 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 28 def original_value @original_value end |
#price_adjustment ⇒ Float
Monetary discount amount applied to the current item.
32 33 34 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 32 def price_adjustment @price_adjustment end |
#type ⇒ String (readonly)
Monetary discount amount applied to the current item.
36 37 38 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 36 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 75 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. discount_ref = hash.key?('discount_ref') ? hash['discount_ref'] : nil original_value = hash.key?('original_value') ? hash['original_value'] : nil price_adjustment = hash.key?('price_adjustment') ? hash['price_adjustment'] : nil coupon_code = hash.key?('coupon_code') ? hash['coupon_code'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP # Create object from extracted values. InjectedOrderDiscountInfo.new(discount_ref, original_value, price_adjustment, coupon_code, description) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['coupon_code'] = 'coupon_code' @_hash['description'] = 'description' @_hash['discount_ref'] = 'discount_ref' @_hash['original_value'] = 'original_value' @_hash['price_adjustment'] = 'price_adjustment' @_hash['type'] = 'type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
59 60 61 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 59 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 51 def self.optionals %w[ coupon_code description ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 97 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.discount_ref, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.original_value, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.price_adjustment, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.type, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['discount_ref'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['original_value'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['price_adjustment'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['type'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
134 135 136 137 138 139 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 134 def inspect class_name = self.class.name.split('::').last "<#{class_name} coupon_code: #{@coupon_code.inspect}, description: #{@description.inspect},"\ " discount_ref: #{@discount_ref.inspect}, original_value: #{@original_value.inspect},"\ " price_adjustment: #{@price_adjustment.inspect}, type: #{@type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
126 127 128 129 130 131 |
# File 'lib/new_store_api/models/injected_order_discount_info.rb', line 126 def to_s class_name = self.class.name.split('::').last "<#{class_name} coupon_code: #{@coupon_code}, description: #{@description}, discount_ref:"\ " #{@discount_ref}, original_value: #{@original_value}, price_adjustment:"\ " #{@price_adjustment}, type: #{@type}>" end |