Class: NewStoreApi::Discount
- Defined in:
- lib/new_store_api/models/discount.rb
Overview
A discount detail.
Instance Attribute Summary collapse
-
#change ⇒ String
The change in price resulting from this discount, with a number of decimals based on currency.
-
#coupon_code ⇒ String
The coupon, if any, associated with this discount.
-
#description ⇒ String
The discount's description.
-
#discount ⇒ String
The value of the discount, with a number of decimals based on currency.
-
#discount_source ⇒ String
The source of the discount.
-
#id ⇒ String
The discount's id.
-
#kind ⇒ String
The discount's kind.
-
#name ⇒ String
The discount's name.
-
#promotion_type ⇒ String
The discount's promotion type e.g.
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(change = nil, coupon_code = nil, description = nil, discount = nil, discount_source = nil, id = nil, kind = nil, name = nil, promotion_type = nil) ⇒ Discount
constructor
A new instance of Discount.
-
#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(change = nil, coupon_code = nil, description = nil, discount = nil, discount_source = nil, id = nil, kind = nil, name = nil, promotion_type = nil) ⇒ Discount
Returns a new instance of Discount.
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/new_store_api/models/discount.rb', line 76 def initialize(change = nil, coupon_code = nil, description = nil, discount = nil, discount_source = nil, id = nil, kind = nil, name = nil, promotion_type = nil) @change = change @coupon_code = coupon_code @description = description @discount = discount @discount_source = discount_source @id = id @kind = kind @name = name @promotion_type = promotion_type end |
Instance Attribute Details
#change ⇒ String
The change in price resulting from this discount, with a number of decimals based on currency
15 16 17 |
# File 'lib/new_store_api/models/discount.rb', line 15 def change @change end |
#coupon_code ⇒ String
The coupon, if any, associated with this discount
19 20 21 |
# File 'lib/new_store_api/models/discount.rb', line 19 def coupon_code @coupon_code end |
#description ⇒ String
The discount's description
23 24 25 |
# File 'lib/new_store_api/models/discount.rb', line 23 def description @description end |
#discount ⇒ String
The value of the discount, with a number of decimals based on currency
27 28 29 |
# File 'lib/new_store_api/models/discount.rb', line 27 def discount @discount end |
#discount_source ⇒ String
The source of the discount. For example, Promotion implies that the
discount is based on automatic promotions, while Coupon refers to
discounts from coupons.
33 34 35 |
# File 'lib/new_store_api/models/discount.rb', line 33 def discount_source @discount_source end |
#id ⇒ String
The discount's id
37 38 39 |
# File 'lib/new_store_api/models/discount.rb', line 37 def id @id end |
#kind ⇒ String
The discount's kind
41 42 43 |
# File 'lib/new_store_api/models/discount.rb', line 41 def kind @kind end |
#name ⇒ String
The discount's name
45 46 47 |
# File 'lib/new_store_api/models/discount.rb', line 45 def name @name end |
#promotion_type ⇒ String
The discount's promotion type e.g. cart level or product level
49 50 51 |
# File 'lib/new_store_api/models/discount.rb', line 49 def promotion_type @promotion_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/new_store_api/models/discount.rb', line 91 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. change = hash.key?('change') ? hash['change'] : nil coupon_code = hash.key?('coupon_code') ? hash['coupon_code'] : nil description = hash.key?('description') ? hash['description'] : nil discount = hash.key?('discount') ? hash['discount'] : nil discount_source = hash.key?('discount_source') ? hash['discount_source'] : nil id = hash.key?('id') ? hash['id'] : nil kind = hash.key?('kind') ? hash['kind'] : nil name = hash.key?('name') ? hash['name'] : nil promotion_type = hash.key?('promotion_type') ? hash['promotion_type'] : nil # Create object from extracted values. Discount.new(change, coupon_code, description, discount, discount_source, id, kind, name, promotion_type) end |
.names ⇒ Object
A mapping from model property names to API property names.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/new_store_api/models/discount.rb', line 52 def self.names @_hash = {} if @_hash.nil? @_hash['change'] = 'change' @_hash['coupon_code'] = 'coupon_code' @_hash['description'] = 'description' @_hash['discount'] = 'discount' @_hash['discount_source'] = 'discount_source' @_hash['id'] = 'id' @_hash['kind'] = 'kind' @_hash['name'] = 'name' @_hash['promotion_type'] = 'promotion_type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
72 73 74 |
# File 'lib/new_store_api/models/discount.rb', line 72 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
67 68 69 |
# File 'lib/new_store_api/models/discount.rb', line 67 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
128 129 130 131 132 133 134 |
# File 'lib/new_store_api/models/discount.rb', line 128 def inspect class_name = self.class.name.split('::').last "<#{class_name} change: #{@change.inspect}, coupon_code: #{@coupon_code.inspect},"\ " description: #{@description.inspect}, discount: #{@discount.inspect}, discount_source:"\ " #{@discount_source.inspect}, id: #{@id.inspect}, kind: #{@kind.inspect}, name:"\ " #{@name.inspect}, promotion_type: #{@promotion_type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
120 121 122 123 124 125 |
# File 'lib/new_store_api/models/discount.rb', line 120 def to_s class_name = self.class.name.split('::').last "<#{class_name} change: #{@change}, coupon_code: #{@coupon_code}, description:"\ " #{@description}, discount: #{@discount}, discount_source: #{@discount_source}, id: #{@id},"\ " kind: #{@kind}, name: #{@name}, promotion_type: #{@promotion_type}>" end |