Class: LoyaltyApIs::RedeemedItemProduct
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- LoyaltyApIs::RedeemedItemProduct
- Defined in:
- lib/loyalty_ap_is/models/redeemed_item_product.rb
Overview
RedeemedItemProduct Model.
Instance Attribute Summary collapse
-
#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).
-
#reason_for_redemption ⇒ String
Reason for redemption of points as mentioned by the partner.
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:, reason_for_redemption: SKIP, product_code: SKIP, product_description: SKIP, additional_properties: nil) ⇒ RedeemedItemProduct
constructor
A new instance of RedeemedItemProduct.
-
#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:, reason_for_redemption: SKIP, product_code: SKIP, product_description: SKIP, additional_properties: nil) ⇒ RedeemedItemProduct
Returns a new instance of RedeemedItemProduct.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 67 def initialize(id:, name:, product_type:, reason_for_redemption: SKIP, product_code: SKIP, 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 @reason_for_redemption = reason_for_redemption unless reason_for_redemption == SKIP @product_code = product_code unless product_code == SKIP @product_description = product_description unless product_description == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#id ⇒ String
Unique Id of the product
14 15 16 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 14 def id @id end |
#name ⇒ String
Name of the product
18 19 20 |
# File 'lib/loyalty_ap_is/models/redeemed_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.
34 35 36 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 34 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.
39 40 41 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 39 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/redeemed_item_product.rb', line 23 def product_type @product_type end |
#reason_for_redemption ⇒ String
Reason for redemption of points as mentioned by the partner. reasonForRedemption to be populated only for redeemedItems (not for saleItems) when productType = PARTNER.
29 30 31 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 29 def reason_for_redemption @reason_for_redemption end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
83 84 85 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 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 83 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 reason_for_redemption = hash.key?('reasonForRedemption') ? hash['reasonForRedemption'] : SKIP product_code = hash.key?('productCode') ? hash['productCode'] : SKIP product_description = hash.key?('productDescription') ? hash['productDescription'] : 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. RedeemedItemProduct.new(id: id, name: name, product_type: product_type, reason_for_redemption: reason_for_redemption, product_code: product_code, product_description: product_description, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['product_type'] = 'productType' @_hash['reason_for_redemption'] = 'reasonForRedemption' @_hash['product_code'] = 'productCode' @_hash['product_description'] = 'productDescription' @_hash end |
.nullables ⇒ Object
An array for nullable fields
63 64 65 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 63 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 54 def self.optionals %w[ reason_for_redemption product_code product_description ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
123 124 125 126 127 128 129 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 123 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, product_type:"\ " #{@product_type.inspect}, reason_for_redemption: #{@reason_for_redemption.inspect},"\ " product_code: #{@product_code.inspect}, product_description:"\ " #{@product_description.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
114 115 116 117 118 119 120 |
# File 'lib/loyalty_ap_is/models/redeemed_item_product.rb', line 114 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, name: #{@name}, product_type: #{@product_type},"\ " reason_for_redemption: #{@reason_for_redemption}, product_code: #{@product_code},"\ " product_description: #{@product_description}, additional_properties:"\ " #{@additional_properties}>" end |