Class: Raas::ItemModel
- Defined in:
- lib/raas/models/item_model.rb
Overview
Represents an item
Instance Attribute Summary collapse
-
#countries ⇒ List of String
The countries this item is valid in.
-
#created_date ⇒ DateTime
The date the item was created.
-
#currency_code ⇒ String
The currency code.
-
#face_value ⇒ Float
The face value of the gift card.
-
#last_update_date ⇒ DateTime
The date the item was last updated.
-
#max_value ⇒ Float
The maximum orderable value (for variable value items).
-
#min_value ⇒ Float
The minimum orderable value (for variable value items).
-
#reward_name ⇒ String
The reward name.
-
#reward_type ⇒ String
The reward type.
-
#status ⇒ String
The item’s status.
-
#utid ⇒ String
The UTID.
-
#value_type ⇒ String
The item’s value type (VARIABLE_VALUE or FIXED_VALUE).
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(utid = nil, reward_name = nil, currency_code = nil, status = nil, value_type = nil, reward_type = nil, created_date = nil, last_update_date = nil, countries = nil, min_value = nil, max_value = nil, face_value = nil) ⇒ ItemModel
constructor
A new instance of ItemModel.
Methods inherited from BaseModel
Constructor Details
#initialize(utid = nil, reward_name = nil, currency_code = nil, status = nil, value_type = nil, reward_type = nil, created_date = nil, last_update_date = nil, countries = nil, min_value = nil, max_value = nil, face_value = nil) ⇒ ItemModel
Returns a new instance of ItemModel.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/raas/models/item_model.rb', line 74 def initialize(utid = nil, reward_name = nil, currency_code = nil, status = nil, value_type = nil, reward_type = nil, created_date = nil, last_update_date = nil, countries = nil, min_value = nil, max_value = nil, face_value = nil) @utid = utid @reward_name = reward_name @currency_code = currency_code @status = status @value_type = value_type @reward_type = reward_type @created_date = created_date @last_update_date = last_update_date @countries = countries @min_value = min_value @max_value = max_value @face_value = face_value end |
Instance Attribute Details
#countries ⇒ List of String
The countries this item is valid in
42 43 44 |
# File 'lib/raas/models/item_model.rb', line 42 def countries @countries end |
#created_date ⇒ DateTime
The date the item was created
34 35 36 |
# File 'lib/raas/models/item_model.rb', line 34 def created_date @created_date end |
#currency_code ⇒ String
The currency code
18 19 20 |
# File 'lib/raas/models/item_model.rb', line 18 def currency_code @currency_code end |
#face_value ⇒ Float
The face value of the gift card
54 55 56 |
# File 'lib/raas/models/item_model.rb', line 54 def face_value @face_value end |
#last_update_date ⇒ DateTime
The date the item was last updated
38 39 40 |
# File 'lib/raas/models/item_model.rb', line 38 def last_update_date @last_update_date end |
#max_value ⇒ Float
The maximum orderable value (for variable value items)
50 51 52 |
# File 'lib/raas/models/item_model.rb', line 50 def max_value @max_value end |
#min_value ⇒ Float
The minimum orderable value (for variable value items)
46 47 48 |
# File 'lib/raas/models/item_model.rb', line 46 def min_value @min_value end |
#reward_name ⇒ String
The reward name
14 15 16 |
# File 'lib/raas/models/item_model.rb', line 14 def reward_name @reward_name end |
#reward_type ⇒ String
The reward type
30 31 32 |
# File 'lib/raas/models/item_model.rb', line 30 def reward_type @reward_type end |
#status ⇒ String
The item’s status
22 23 24 |
# File 'lib/raas/models/item_model.rb', line 22 def status @status end |
#value_type ⇒ String
The item’s value type (VARIABLE_VALUE or FIXED_VALUE)
26 27 28 |
# File 'lib/raas/models/item_model.rb', line 26 def value_type @value_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/raas/models/item_model.rb', line 101 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. utid = hash['utid'] reward_name = hash['rewardName'] currency_code = hash['currencyCode'] status = hash['status'] value_type = hash['valueType'] reward_type = hash['rewardType'] created_date = APIHelper.rfc3339(hash['createdDate']) if hash['createdDate'] last_update_date = APIHelper.rfc3339(hash['lastUpdateDate']) if hash['lastUpdateDate'] countries = hash['countries'] min_value = hash['minValue'] max_value = hash['maxValue'] face_value = hash['faceValue'] # Create object from extracted values. ItemModel.new(utid, reward_name, currency_code, status, value_type, reward_type, created_date, last_update_date, countries, min_value, max_value, face_value) end |
.names ⇒ Object
A mapping from model property names to API property names.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/raas/models/item_model.rb', line 57 def self.names @_hash = {} if @_hash.nil? @_hash['utid'] = 'utid' @_hash['reward_name'] = 'rewardName' @_hash['currency_code'] = 'currencyCode' @_hash['status'] = 'status' @_hash['value_type'] = 'valueType' @_hash['reward_type'] = 'rewardType' @_hash['created_date'] = 'createdDate' @_hash['last_update_date'] = 'lastUpdateDate' @_hash['countries'] = 'countries' @_hash['min_value'] = 'minValue' @_hash['max_value'] = 'maxValue' @_hash['face_value'] = 'faceValue' @_hash end |