Class: ShellEv::ChargeRetrieveState

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shell_ev/models/charge_retrieve_state.rb

Overview

ChargeRetrieveState Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(status = SKIP, error = SKIP) ⇒ ChargeRetrieveState

Returns a new instance of ChargeRetrieveState.



45
46
47
48
# File 'lib/shell_ev/models/charge_retrieve_state.rb', line 45

def initialize(status = SKIP, error = SKIP)
  @status = status unless status == SKIP
  @error = error unless error == SKIP
end

Instance Attribute Details

#errorChargeError

Describes the session state started, stopped, start-requested, stop-requested, failed-to-start, failed-to-stop

Returns:



22
23
24
# File 'lib/shell_ev/models/charge_retrieve_state.rb', line 22

def error
  @error
end

#statusString

Describes the session state started, stopped, start-requested, stop-requested, failed-to-start, failed-to-stop

Returns:

  • (String)


16
17
18
# File 'lib/shell_ev/models/charge_retrieve_state.rb', line 16

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/shell_ev/models/charge_retrieve_state.rb', line 51

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  status = hash.key?('status') ? hash['status'] : SKIP
  error = ChargeError.from_hash(hash['error']) if hash['error']

  # Create object from extracted values.
  ChargeRetrieveState.new(status,
                          error)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
# File 'lib/shell_ev/models/charge_retrieve_state.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['status'] = 'status'
  @_hash['error'] = 'error'
  @_hash
end

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/shell_ev/models/charge_retrieve_state.rb', line 41

def self.nullables
  []
end

.optionalsObject

An array for optional fields



33
34
35
36
37
38
# File 'lib/shell_ev/models/charge_retrieve_state.rb', line 33

def self.optionals
  %w[
    status
    error
  ]
end