Class: ShellEv::DataRetrieve
- Defined in:
- lib/shell_ev/models/data_retrieve.rb
Overview
DataRetrieve Model.
Instance Attribute Summary collapse
-
#ema_id ⇒ String
Id of the evse that the user is charging.
-
#evse_id ⇒ String
Ema-id of the charge token that is used.
-
#id ⇒ UUID | String
Id of the session.
-
#session_code ⇒ DataRetrieveSessionCodeEnum
Session code e.g InternalError.
-
#session_message ⇒ String
Session message.
-
#session_state ⇒ DataRetrieveSessionStateEnum
Describes the session state.
-
#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, session_code = SKIP, session_message = SKIP) ⇒ DataRetrieve
constructor
A new instance of DataRetrieve.
- #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, session_code = SKIP, session_message = SKIP) ⇒ DataRetrieve
Returns a new instance of DataRetrieve.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 88 def initialize(id = SKIP, user_id = SKIP, ema_id = SKIP, evse_id = SKIP, started_at = SKIP, stopped_at = SKIP, session_state = SKIP, session_code = SKIP, = 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 @session_code = session_code unless session_code == SKIP @session_message = unless == 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_retrieve.rb', line 23 def ema_id @ema_id end |
#evse_id ⇒ String
Ema-id of the charge token that is used
27 28 29 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 27 def evse_id @evse_id end |
#id ⇒ UUID | String
Id of the session
15 16 17 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 15 def id @id end |
#session_code ⇒ DataRetrieveSessionCodeEnum
Session code e.g InternalError
43 44 45 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 43 def session_code @session_code end |
#session_message ⇒ String
Session message
47 48 49 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 47 def @session_message end |
#session_state ⇒ DataRetrieveSessionStateEnum
Describes the session state
39 40 41 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 39 def session_state @session_state end |
#started_at ⇒ DateTime
When the session is started
31 32 33 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 31 def started_at @started_at end |
#stopped_at ⇒ DateTime
When the session is stopped
35 36 37 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 35 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_retrieve.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.
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 134 135 136 137 138 139 140 141 142 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 109 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 = hash.key?('SessionState') ? hash['SessionState'] : SKIP session_code = hash.key?('SessionCode') ? hash['SessionCode'] : SKIP = hash.key?('SessionMessage') ? hash['SessionMessage'] : SKIP # Create object from extracted values. DataRetrieve.new(id, user_id, ema_id, evse_id, started_at, stopped_at, session_state, session_code, ) end |
.names ⇒ Object
A mapping from model property names to API property names.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 50 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['session_code'] = 'SessionCode' @_hash['session_message'] = 'SessionMessage' @_hash end |
.nullables ⇒ Object
An array for nullable fields
80 81 82 83 84 85 86 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 80 def self.nullables %w[ stopped_at session_code session_message ] end |
.optionals ⇒ Object
An array for optional fields
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 65 def self.optionals %w[ id user_id ema_id evse_id started_at stopped_at session_state session_code session_message ] end |
Instance Method Details
#to_custom_started_at ⇒ Object
144 145 146 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 144 def to_custom_started_at DateTimeHelper.to_rfc3339(started_at) end |
#to_custom_stopped_at ⇒ Object
148 149 150 |
# File 'lib/shell_ev/models/data_retrieve.rb', line 148 def to_custom_stopped_at DateTimeHelper.to_rfc3339(stopped_at) end |