Class: ShellEv::DataActive
- Defined in:
- lib/shell_ev/models/data_active.rb
Overview
DataActive Model.
Instance Attribute Summary collapse
-
#ema_id ⇒ String
Id of the evse that the user is charging.
-
#evse_id ⇒ String
Electric Vehicle Supply Equipment Identifier.
-
#id ⇒ UUID | String
Id of the session.
-
#last_updated ⇒ String
When the session is stopped.
-
#session_state ⇒ ChargeRetrieveState
When the session is stopped.
-
#started_at ⇒ DateTime
When the session is started.
-
#stopped_at ⇒ DateTime
When the session is stopped.
-
#user_id ⇒ String
Id of the user that started the session.
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 = SKIP, user_id = SKIP, ema_id = SKIP, evse_id = SKIP, started_at = SKIP, stopped_at = SKIP, session_state = SKIP, last_updated = SKIP) ⇒ DataActive
constructor
A new instance of DataActive.
- #to_custom_started_at ⇒ Object
- #to_custom_stopped_at ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(id = SKIP, user_id = SKIP, ema_id = SKIP, evse_id = SKIP, started_at = SKIP, stopped_at = SKIP, session_state = SKIP, last_updated = SKIP) ⇒ DataActive
Returns a new instance of DataActive.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/shell_ev/models/data_active.rb', line 81 def initialize(id = SKIP, user_id = SKIP, ema_id = SKIP, evse_id = SKIP, started_at = SKIP, stopped_at = SKIP, session_state = SKIP, last_updated = SKIP) @id = id unless id == SKIP @user_id = user_id unless user_id == SKIP @ema_id = ema_id unless ema_id == SKIP @evse_id = evse_id unless evse_id == SKIP @started_at = started_at unless started_at == SKIP @stopped_at = stopped_at unless stopped_at == SKIP @session_state = session_state unless session_state == SKIP @last_updated = last_updated unless last_updated == SKIP end |
Instance Attribute Details
#ema_id ⇒ String
Id of the evse that the user is charging
23 24 25 |
# File 'lib/shell_ev/models/data_active.rb', line 23 def ema_id @ema_id end |
#evse_id ⇒ String
Electric Vehicle Supply Equipment Identifier. An EVSEID identifies a Charging Point.
28 29 30 |
# File 'lib/shell_ev/models/data_active.rb', line 28 def evse_id @evse_id end |
#id ⇒ UUID | String
Id of the session
15 16 17 |
# File 'lib/shell_ev/models/data_active.rb', line 15 def id @id end |
#last_updated ⇒ String
When the session is stopped
44 45 46 |
# File 'lib/shell_ev/models/data_active.rb', line 44 def last_updated @last_updated end |
#session_state ⇒ ChargeRetrieveState
When the session is stopped
40 41 42 |
# File 'lib/shell_ev/models/data_active.rb', line 40 def session_state @session_state end |
#started_at ⇒ DateTime
When the session is started
32 33 34 |
# File 'lib/shell_ev/models/data_active.rb', line 32 def started_at @started_at end |
#stopped_at ⇒ DateTime
When the session is stopped
36 37 38 |
# File 'lib/shell_ev/models/data_active.rb', line 36 def stopped_at @stopped_at end |
#user_id ⇒ String
Id of the user that started the session
19 20 21 |
# File 'lib/shell_ev/models/data_active.rb', line 19 def user_id @user_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
95 96 97 98 99 100 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 |
# File 'lib/shell_ev/models/data_active.rb', line 95 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP user_id = hash.key?('userId') ? hash['userId'] : SKIP ema_id = hash.key?('emaId') ? hash['emaId'] : SKIP evse_id = hash.key?('evseId') ? hash['evseId'] : SKIP started_at = if hash.key?('startedAt') (DateTimeHelper.from_rfc3339(hash['startedAt']) if hash['startedAt']) else SKIP end stopped_at = if hash.key?('stoppedAt') (DateTimeHelper.from_rfc3339(hash['stoppedAt']) if hash['stoppedAt']) else SKIP end session_state = ChargeRetrieveState.from_hash(hash['SessionState']) if hash['SessionState'] last_updated = hash.key?('lastUpdated') ? hash['lastUpdated'] : SKIP # Create object from extracted values. DataActive.new(id, user_id, ema_id, evse_id, started_at, stopped_at, session_state, last_updated) end |
.names ⇒ Object
A mapping from model property names to API property names.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/shell_ev/models/data_active.rb', line 47 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['user_id'] = 'userId' @_hash['ema_id'] = 'emaId' @_hash['evse_id'] = 'evseId' @_hash['started_at'] = 'startedAt' @_hash['stopped_at'] = 'stoppedAt' @_hash['session_state'] = 'SessionState' @_hash['last_updated'] = 'lastUpdated' @_hash end |
.nullables ⇒ Object
An array for nullable fields
75 76 77 78 79 |
# File 'lib/shell_ev/models/data_active.rb', line 75 def self.nullables %w[ stopped_at ] end |
.optionals ⇒ Object
An array for optional fields
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/shell_ev/models/data_active.rb', line 61 def self.optionals %w[ id user_id ema_id evse_id started_at stopped_at session_state last_updated ] end |
Instance Method Details
#to_custom_started_at ⇒ Object
127 128 129 |
# File 'lib/shell_ev/models/data_active.rb', line 127 def to_custom_started_at DateTimeHelper.to_rfc3339(started_at) end |
#to_custom_stopped_at ⇒ Object
131 132 133 |
# File 'lib/shell_ev/models/data_active.rb', line 131 def to_custom_stopped_at DateTimeHelper.to_rfc3339(stopped_at) end |