Class: ShellEv::TariffV2
- Defined in:
- lib/shell_ev/models/tariff_v2.rb
Overview
Tariff metadata aligned with TariffV2 GraphQL schema
Instance Attribute Summary collapse
-
#created_by ⇒ String
Identifier of the actor who created the tariff.
-
#currency ⇒ String
ISO 4217 Currency Code.
-
#elements ⇒ Array[TariffElement]
ISO 4217 Currency Code.
-
#end_date_time ⇒ DateTime
ISO 4217 Currency Code.
-
#internal_id ⇒ String
Internal identifier used by the platform.
-
#last_updated ⇒ DateTime
ISO 4217 Currency Code.
-
#max_price ⇒ Float
ISO 4217 Currency Code.
-
#min_price ⇒ Float
ISO 4217 Currency Code.
-
#operator_id ⇒ String
Unique identifier of the operator.
-
#power_range ⇒ PowerRange
Tariff type classification.
-
#provider_id ⇒ String
Unique identifier of the provider.
-
#start_date_time ⇒ DateTime
ISO 4217 Currency Code.
-
#tariff_alt_text ⇒ Array[TariffAltText]
ISO 4217 Currency Code.
-
#tariff_id ⇒ String
Unique identifier for the tariff.
-
#tariff_type ⇒ TariffTypeEnum
Tariff type classification.
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(tariff_id = nil, tariff_type = nil, power_range = nil, internal_id = nil, operator_id = nil, provider_id = nil, currency = nil, tariff_alt_text = nil, min_price = nil, max_price = nil, elements = nil, start_date_time = nil, end_date_time = nil, last_updated = nil, created_by = nil) ⇒ TariffV2
constructor
A new instance of TariffV2.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_end_date_time ⇒ Object
- #to_custom_last_updated ⇒ Object
- #to_custom_start_date_time ⇒ 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(tariff_id = nil, tariff_type = nil, power_range = nil, internal_id = nil, operator_id = nil, provider_id = nil, currency = nil, tariff_alt_text = nil, min_price = nil, max_price = nil, elements = nil, start_date_time = nil, end_date_time = nil, last_updated = nil, created_by = nil) ⇒ TariffV2
Returns a new instance of TariffV2.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 106 def initialize(tariff_id = nil, tariff_type = nil, power_range = nil, internal_id = nil, operator_id = nil, provider_id = nil, currency = nil, tariff_alt_text = nil, min_price = nil, max_price = nil, elements = nil, start_date_time = nil, end_date_time = nil, last_updated = nil, created_by = nil) @tariff_id = tariff_id @tariff_type = tariff_type @power_range = power_range @internal_id = internal_id @operator_id = operator_id @provider_id = provider_id @currency = currency @tariff_alt_text = tariff_alt_text @min_price = min_price @max_price = max_price @elements = elements @start_date_time = start_date_time @end_date_time = end_date_time @last_updated = last_updated @created_by = created_by end |
Instance Attribute Details
#created_by ⇒ String
Identifier of the actor who created the tariff
71 72 73 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 71 def created_by @created_by end |
#currency ⇒ String
ISO 4217 Currency Code
39 40 41 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 39 def currency @currency end |
#elements ⇒ Array[TariffElement]
ISO 4217 Currency Code
55 56 57 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 55 def elements @elements end |
#end_date_time ⇒ DateTime
ISO 4217 Currency Code
63 64 65 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 63 def end_date_time @end_date_time end |
#internal_id ⇒ String
Internal identifier used by the platform
27 28 29 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 27 def internal_id @internal_id end |
#last_updated ⇒ DateTime
ISO 4217 Currency Code
67 68 69 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 67 def last_updated @last_updated end |
#max_price ⇒ Float
ISO 4217 Currency Code
51 52 53 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 51 def max_price @max_price end |
#min_price ⇒ Float
ISO 4217 Currency Code
47 48 49 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 47 def min_price @min_price end |
#operator_id ⇒ String
Unique identifier of the operator
31 32 33 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 31 def operator_id @operator_id end |
#power_range ⇒ PowerRange
Tariff type classification
23 24 25 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 23 def power_range @power_range end |
#provider_id ⇒ String
Unique identifier of the provider
35 36 37 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 35 def provider_id @provider_id end |
#start_date_time ⇒ DateTime
ISO 4217 Currency Code
59 60 61 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 59 def start_date_time @start_date_time end |
#tariff_alt_text ⇒ Array[TariffAltText]
ISO 4217 Currency Code
43 44 45 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 43 def tariff_alt_text @tariff_alt_text end |
#tariff_id ⇒ String
Unique identifier for the tariff
15 16 17 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 15 def tariff_id @tariff_id end |
#tariff_type ⇒ TariffTypeEnum
Tariff type classification
19 20 21 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 19 def tariff_type @tariff_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 129 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. tariff_id = hash.key?('tariffId') ? hash['tariffId'] : nil tariff_type = hash.key?('tariffType') ? hash['tariffType'] : nil power_range = PowerRange.from_hash(hash['powerRange']) if hash['powerRange'] internal_id = hash.key?('internalId') ? hash['internalId'] : nil operator_id = hash.key?('operatorId') ? hash['operatorId'] : nil provider_id = hash.key?('providerId') ? hash['providerId'] : nil currency = hash.key?('currency') ? hash['currency'] : nil # Parameter is an array, so we need to iterate through it tariff_alt_text = nil unless hash['tariffAltText'].nil? tariff_alt_text = [] hash['tariffAltText'].each do |structure| tariff_alt_text << (TariffAltText.from_hash(structure) if structure) end end tariff_alt_text = nil unless hash.key?('tariffAltText') min_price = hash.key?('minPrice') ? hash['minPrice'] : nil max_price = hash.key?('maxPrice') ? hash['maxPrice'] : nil # Parameter is an array, so we need to iterate through it elements = nil unless hash['elements'].nil? elements = [] hash['elements'].each do |structure| elements << (TariffElement.from_hash(structure) if structure) end end elements = nil unless hash.key?('elements') start_date_time = if hash.key?('startDateTime') (DateTimeHelper.from_rfc3339(hash['startDateTime']) if hash['startDateTime']) end end_date_time = if hash.key?('endDateTime') (DateTimeHelper.from_rfc3339(hash['endDateTime']) if hash['endDateTime']) end last_updated = if hash.key?('lastUpdated') (DateTimeHelper.from_rfc3339(hash['lastUpdated']) if hash['lastUpdated']) end created_by = hash.key?('createdBy') ? hash['createdBy'] : nil # Create object from extracted values. TariffV2.new(tariff_id, tariff_type, power_range, internal_id, operator_id, provider_id, currency, tariff_alt_text, min_price, max_price, elements, start_date_time, end_date_time, last_updated, created_by) end |
.names ⇒ Object
A mapping from model property names to API property names.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 74 def self.names @_hash = {} if @_hash.nil? @_hash['tariff_id'] = 'tariffId' @_hash['tariff_type'] = 'tariffType' @_hash['power_range'] = 'powerRange' @_hash['internal_id'] = 'internalId' @_hash['operator_id'] = 'operatorId' @_hash['provider_id'] = 'providerId' @_hash['currency'] = 'currency' @_hash['tariff_alt_text'] = 'tariffAltText' @_hash['min_price'] = 'minPrice' @_hash['max_price'] = 'maxPrice' @_hash['elements'] = 'elements' @_hash['start_date_time'] = 'startDateTime' @_hash['end_date_time'] = 'endDateTime' @_hash['last_updated'] = 'lastUpdated' @_hash['created_by'] = 'createdBy' @_hash end |
.nullables ⇒ Object
An array for nullable fields
100 101 102 103 104 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 100 def self.nullables %w[ tariff_alt_text ] end |
.optionals ⇒ Object
An array for optional fields
95 96 97 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 95 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
215 216 217 218 219 220 221 222 223 224 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 215 def inspect class_name = self.class.name.split('::').last "<#{class_name} tariff_id: #{@tariff_id.inspect}, tariff_type: #{@tariff_type.inspect},"\ " power_range: #{@power_range.inspect}, internal_id: #{@internal_id.inspect}, operator_id:"\ " #{@operator_id.inspect}, provider_id: #{@provider_id.inspect}, currency:"\ " #{@currency.inspect}, tariff_alt_text: #{@tariff_alt_text.inspect}, min_price:"\ " #{@min_price.inspect}, max_price: #{@max_price.inspect}, elements: #{@elements.inspect},"\ " start_date_time: #{@start_date_time.inspect}, end_date_time: #{@end_date_time.inspect},"\ " last_updated: #{@last_updated.inspect}, created_by: #{@created_by.inspect}>" end |
#to_custom_end_date_time ⇒ Object
195 196 197 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 195 def to_custom_end_date_time DateTimeHelper.to_rfc3339(end_date_time) end |
#to_custom_last_updated ⇒ Object
199 200 201 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 199 def to_custom_last_updated DateTimeHelper.to_rfc3339(last_updated) end |
#to_custom_start_date_time ⇒ Object
191 192 193 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 191 def to_custom_start_date_time DateTimeHelper.to_rfc3339(start_date_time) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
204 205 206 207 208 209 210 211 212 |
# File 'lib/shell_ev/models/tariff_v2.rb', line 204 def to_s class_name = self.class.name.split('::').last "<#{class_name} tariff_id: #{@tariff_id}, tariff_type: #{@tariff_type}, power_range:"\ " #{@power_range}, internal_id: #{@internal_id}, operator_id: #{@operator_id}, provider_id:"\ " #{@provider_id}, currency: #{@currency}, tariff_alt_text: #{@tariff_alt_text}, min_price:"\ " #{@min_price}, max_price: #{@max_price}, elements: #{@elements}, start_date_time:"\ " #{@start_date_time}, end_date_time: #{@end_date_time}, last_updated: #{@last_updated},"\ " created_by: #{@created_by}>" end |