Class: LoyaltyApIs::OfferAssignment
- Defined in:
- lib/loyalty_ap_is/models/offer_assignment.rb
Overview
OfferAssignment Model.
Instance Attribute Summary collapse
-
#consumer_uuid ⇒ UUID | String
SSO uuid of the user signed in with Shell credentials Format: 32 hexadecimal digits grouped the following way: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
-
#offer_id ⇒ String
Offer identifier shared by Shell.
-
#reference_id ⇒ String
Unique Reference ID for the transaction from the partner.
-
#valid_from ⇒ DateTime
Offer validity start date in JSON recommended format: "yyyy-MM-ddTHH:mm:ssZ".
-
#valid_to ⇒ DateTime
Offer validity end date in JSON recommended format: "yyyy-MM-ddTHH:mm:ssZ".
-
#validity_period ⇒ Float
Offer validity period (Number of days) If validityPeriod is greater than zero, validTo will be ignored.
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(reference_id:, consumer_uuid:, offer_id:, valid_from: SKIP, validity_period: SKIP, valid_to: SKIP, additional_properties: nil) ⇒ OfferAssignment
constructor
A new instance of OfferAssignment.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_valid_from ⇒ Object
- #to_custom_valid_to ⇒ Object
-
#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(reference_id:, consumer_uuid:, offer_id:, valid_from: SKIP, validity_period: SKIP, valid_to: SKIP, additional_properties: nil) ⇒ OfferAssignment
Returns a new instance of OfferAssignment.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 94 def initialize(reference_id:, consumer_uuid:, offer_id:, valid_from: SKIP, validity_period: SKIP, valid_to: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @reference_id = reference_id @consumer_uuid = consumer_uuid @offer_id = offer_id @valid_from = valid_from unless valid_from == SKIP @validity_period = validity_period unless validity_period == SKIP @valid_to = valid_to unless valid_to == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#consumer_uuid ⇒ UUID | String
SSO uuid of the user signed in with Shell credentials Format: 32 hexadecimal digits grouped the following way: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
22 23 24 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 22 def consumer_uuid @consumer_uuid end |
#offer_id ⇒ String
Offer identifier shared by Shell. Format: string(30)
27 28 29 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 27 def offer_id @offer_id end |
#reference_id ⇒ String
Unique Reference ID for the transaction from the partner. Used to identify duplicate requests.
16 17 18 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 16 def reference_id @reference_id end |
#valid_from ⇒ DateTime
Offer validity start date in JSON recommended format:
"yyyy-MM-ddTHH:mm:ssZ".
The date format must follow ISO_8601. If 'Z' is written immediately after
the time, it is considered UTC.
Time offset from UTC can be appended instead of 'Z' using plus or minus
signs. Negative UTC offsets describe a time zone west of UTC�00:00, where
the civil time is behind (or earlier) than UTC. Positive UTC offsets
describe a time zone east of UTC�00:00, where the civil time is ahead (or
later) than UTC
39 40 41 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 39 def valid_from @valid_from end |
#valid_to ⇒ DateTime
Offer validity end date in JSON recommended format:
"yyyy-MM-ddTHH:mm:ssZ".
Field value is ignored if validityPeriod is bigger than zero.
The date format must follow ISO_8601. If 'Z' is written immediately after
the time, it is considered UTC.
Time offset from UTC can be appended instead of 'Z' using plus or minus
signs. Negative UTC offsets describe a time zone west of UTC�00:00, where
the civil time is behind (or earlier) than UTC. Positive UTC offsets
describe a time zone east of UTC�00:00, where the civil time is ahead (or
later) than UTC
64 65 66 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 64 def valid_to @valid_to end |
#validity_period ⇒ Float
Offer validity period (Number of days) If validityPeriod is greater than zero, validTo will be ignored. The offer will be valid till:
validfrom + validityperiod
If the resulting valid to date would be during the day, then its validity is modified to last until midnight in the timezone of the validFrom date. E.g. If valiFrom is "2021-03-08T17:12:55Z+01:00" (Central European time) and validtyPeriod is 3 then the offer will be valid till "2021-03-11T23:59:59Z+01:00" (Central European Time)
51 52 53 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 51 def validity_period @validity_period end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 110 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. reference_id = hash.key?('referenceId') ? hash['referenceId'] : nil consumer_uuid = hash.key?('consumerUuid') ? hash['consumerUuid'] : nil offer_id = hash.key?('offerId') ? hash['offerId'] : nil valid_from = if hash.key?('validFrom') (DateTimeHelper.from_rfc3339(hash['validFrom']) if hash['validFrom']) else SKIP end validity_period = hash.key?('validityPeriod') ? hash['validityPeriod'] : SKIP valid_to = if hash.key?('validTo') (DateTimeHelper.from_rfc3339(hash['validTo']) if hash['validTo']) else SKIP end # 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. OfferAssignment.new(reference_id: reference_id, consumer_uuid: consumer_uuid, offer_id: offer_id, valid_from: valid_from, validity_period: validity_period, valid_to: valid_to, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 67 def self.names @_hash = {} if @_hash.nil? @_hash['reference_id'] = 'referenceId' @_hash['consumer_uuid'] = 'consumerUuid' @_hash['offer_id'] = 'offerId' @_hash['valid_from'] = 'validFrom' @_hash['validity_period'] = 'validityPeriod' @_hash['valid_to'] = 'validTo' @_hash end |
.nullables ⇒ Object
An array for nullable fields
88 89 90 91 92 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 88 def self.nullables %w[ valid_to ] end |
.optionals ⇒ Object
An array for optional fields
79 80 81 82 83 84 85 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 79 def self.optionals %w[ valid_from validity_period valid_to ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
164 165 166 167 168 169 170 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 164 def inspect class_name = self.class.name.split('::').last "<#{class_name} reference_id: #{@reference_id.inspect}, consumer_uuid:"\ " #{@consumer_uuid.inspect}, offer_id: #{@offer_id.inspect}, valid_from:"\ " #{@valid_from.inspect}, validity_period: #{@validity_period.inspect}, valid_to:"\ " #{@valid_to.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_valid_from ⇒ Object
147 148 149 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 147 def to_custom_valid_from DateTimeHelper.to_rfc3339(valid_from) end |
#to_custom_valid_to ⇒ Object
151 152 153 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 151 def to_custom_valid_to DateTimeHelper.to_rfc3339(valid_to) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
156 157 158 159 160 161 |
# File 'lib/loyalty_ap_is/models/offer_assignment.rb', line 156 def to_s class_name = self.class.name.split('::').last "<#{class_name} reference_id: #{@reference_id}, consumer_uuid: #{@consumer_uuid}, offer_id:"\ " #{@offer_id}, valid_from: #{@valid_from}, validity_period: #{@validity_period}, valid_to:"\ " #{@valid_to}, additional_properties: #{@additional_properties}>" end |