Class: LoyaltyApIs::SaleItemProduct
- Defined in:
- lib/loyalty_ap_is/models/sale_item_product.rb
Overview
SaleItemProduct Model.
Instance Attribute Summary collapse
-
#additional_product_description ⇒ String
Customer name of the product provided by the partner.
-
#id ⇒ String
Unique Id of the product.
-
#name ⇒ String
Name of the product.
-
#product_code ⇒ String
Product code of gift item (euroShell Forward Code).
-
#product_description ⇒ String
Product code of gift item (euroShell Forward Code).
-
#product_type ⇒ ProductType
Indicating the Type of the product (Fuel, CR, CC, PARTNER, OTHER, GREEN_ENERGY).
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(id:, name:, product_type:, product_code: SKIP, product_description: SKIP, additional_product_description: SKIP, additional_properties: nil) ⇒ SaleItemProduct
constructor
A new instance of SaleItemProduct.
-
#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:, name:, product_type:, product_code: SKIP, product_description: SKIP, additional_product_description: SKIP, additional_properties: nil) ⇒ SaleItemProduct
Returns a new instance of SaleItemProduct.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 66 def initialize(id:, name:, product_type:, product_code: SKIP, product_description: SKIP, additional_product_description: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @name = name @product_type = product_type @product_code = product_code unless product_code == SKIP @product_description = product_description unless product_description == SKIP unless additional_product_description == SKIP @additional_product_description = additional_product_description end @additional_properties = additional_properties end |
Instance Attribute Details
#additional_product_description ⇒ String
Customer name of the product provided by the partner
37 38 39 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 37 def additional_product_description @additional_product_description end |
#id ⇒ String
Unique Id of the product
14 15 16 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 14 def id @id end |
#name ⇒ String
Name of the product
18 19 20 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 18 def name @name end |
#product_code ⇒ String
Product code of gift item (euroShell Forward Code). To be populated with 3 digit Euroshell product code.
28 29 30 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 28 def product_code @product_code end |
#product_description ⇒ String
Product code of gift item (euroShell Forward Code). To be populated with 3 digit Euroshell product code.
33 34 35 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 33 def product_description @product_description end |
#product_type ⇒ ProductType
Indicating the Type of the product (Fuel, CR, CC, PARTNER, OTHER, GREEN_ENERGY).
23 24 25 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 23 def product_type @product_type 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 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 86 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 product_type = hash.key?('productType') ? hash['productType'] : nil product_code = hash.key?('productCode') ? hash['productCode'] : SKIP product_description = hash.key?('productDescription') ? hash['productDescription'] : SKIP additional_product_description = hash.key?('additionalProductDescription') ? hash['additionalProductDescription'] : 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. SaleItemProduct.new(id: id, name: name, product_type: product_type, product_code: product_code, product_description: product_description, additional_product_description: additional_product_description, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 40 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['product_type'] = 'productType' @_hash['product_code'] = 'productCode' @_hash['product_description'] = 'productDescription' @_hash['additional_product_description'] = 'additionalProductDescription' @_hash end |
.nullables ⇒ Object
An array for nullable fields
62 63 64 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 62 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
53 54 55 56 57 58 59 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 53 def self.optionals %w[ product_code product_description additional_product_description ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
126 127 128 129 130 131 132 133 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 126 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, product_type:"\ " #{@product_type.inspect}, product_code: #{@product_code.inspect}, product_description:"\ " #{@product_description.inspect}, additional_product_description:"\ " #{@additional_product_description.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
117 118 119 120 121 122 123 |
# File 'lib/loyalty_ap_is/models/sale_item_product.rb', line 117 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, name: #{@name}, product_type: #{@product_type}, product_code:"\ " #{@product_code}, product_description: #{@product_description},"\ " additional_product_description: #{@additional_product_description}, additional_properties:"\ " #{@additional_properties}>" end |