Class: Raas::RewardModel
- Defined in:
- lib/raas/models/reward_model.rb
Overview
Represents a Reward
Instance Attribute Summary collapse
-
#credential_list ⇒ List of RewardCredentialModel
An array of reward credentials.
-
#credentials ⇒ Array<String, String>
A map of reward credentials.
-
#redemption_instructions ⇒ String
Reward redemption instructions.
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.
Instance Method Summary collapse
-
#initialize(credentials = nil, credential_list = nil, redemption_instructions = nil) ⇒ RewardModel
constructor
A new instance of RewardModel.
Methods inherited from BaseModel
Constructor Details
#initialize(credentials = nil, credential_list = nil, redemption_instructions = nil) ⇒ RewardModel
Returns a new instance of RewardModel.
28 29 30 31 32 33 34 |
# File 'lib/raas/models/reward_model.rb', line 28 def initialize(credentials = nil, credential_list = nil, redemption_instructions = nil) @credentials = credentials @credential_list = credential_list @redemption_instructions = redemption_instructions end |
Instance Attribute Details
#credential_list ⇒ List of RewardCredentialModel
An array of reward credentials
13 14 15 |
# File 'lib/raas/models/reward_model.rb', line 13 def credential_list @credential_list end |
#credentials ⇒ Array<String, String>
A map of reward credentials
9 10 11 |
# File 'lib/raas/models/reward_model.rb', line 9 def credentials @credentials end |
#redemption_instructions ⇒ String
Reward redemption instructions
17 18 19 |
# File 'lib/raas/models/reward_model.rb', line 17 def redemption_instructions @redemption_instructions end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/raas/models/reward_model.rb', line 37 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. credentials = hash['credentials'] # Parameter is an array, so we need to iterate through it credential_list = nil unless hash['credentialList'].nil? credential_list = [] hash['credentialList'].each do |structure| credential_list << (RewardCredentialModel.from_hash(structure) if structure) end end redemption_instructions = hash['redemptionInstructions'] # Create object from extracted values. RewardModel.new(credentials, credential_list, redemption_instructions) end |
.names ⇒ Object
A mapping from model property names to API property names.
20 21 22 23 24 25 26 |
# File 'lib/raas/models/reward_model.rb', line 20 def self.names @_hash = {} if @_hash.nil? @_hash['credentials'] = 'credentials' @_hash['credential_list'] = 'credentialList' @_hash['redemption_instructions'] = 'redemptionInstructions' @_hash end |