Class: ShellEv::ConnectorV2

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

Overview

An EVSE can have one or many Connectors. Each Connector will normally have a different socket / cable and only one can be used to charge at a time.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(uid = SKIP, external_id = SKIP, connector_type = SKIP, electrical_properties = SKIP) ⇒ ConnectorV2

Returns a new instance of ConnectorV2.



55
56
57
58
59
60
61
# File 'lib/shell_ev/models/connector_v2.rb', line 55

def initialize(uid = SKIP, external_id = SKIP, connector_type = SKIP,
               electrical_properties = SKIP)
  @uid = uid unless uid == SKIP
  @external_id = external_id unless external_id == SKIP
  @connector_type = connector_type unless connector_type == SKIP
  @electrical_properties = electrical_properties unless electrical_properties == SKIP
end

Instance Attribute Details

#connector_typeConnectorVOConnectorTypeEnum

Type of the connector in the EVSE unit.



24
25
26
# File 'lib/shell_ev/models/connector_v2.rb', line 24

def connector_type
  @connector_type
end

#electrical_propertiesElectricalPropertiesV2

Electrical Properties of the Connector



28
29
30
# File 'lib/shell_ev/models/connector_v2.rb', line 28

def electrical_properties
  @electrical_properties
end

#external_idString

Identifier of the Evse as given by the Operator, unique for the containing EVSE’

Returns:

  • (String)


20
21
22
# File 'lib/shell_ev/models/connector_v2.rb', line 20

def external_id
  @external_id
end

#uidString

Internal identifier used to refer to this Connector

Returns:

  • (String)


15
16
17
# File 'lib/shell_ev/models/connector_v2.rb', line 15

def uid
  @uid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/shell_ev/models/connector_v2.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  uid = hash.key?('uid') ? hash['uid'] : SKIP
  external_id = hash.key?('externalId') ? hash['externalId'] : SKIP
  connector_type = hash.key?('connectorType') ? hash['connectorType'] : SKIP
  electrical_properties = ElectricalPropertiesV2.from_hash(hash['electricalProperties']) if
    hash['electricalProperties']

  # Create object from extracted values.
  ConnectorV2.new(uid,
                  external_id,
                  connector_type,
                  electrical_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['uid'] = 'uid'
  @_hash['external_id'] = 'externalId'
  @_hash['connector_type'] = 'connectorType'
  @_hash['electrical_properties'] = 'electricalProperties'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
# File 'lib/shell_ev/models/connector_v2.rb', line 51

def self.nullables
  []
end

.optionalsObject

An array for optional fields



41
42
43
44
45
46
47
48
# File 'lib/shell_ev/models/connector_v2.rb', line 41

def self.optionals
  %w[
    uid
    external_id
    connector_type
    electrical_properties
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



89
90
91
92
93
# File 'lib/shell_ev/models/connector_v2.rb', line 89

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} uid: #{@uid.inspect}, external_id: #{@external_id.inspect}, connector_type:"\
  " #{@connector_type.inspect}, electrical_properties: #{@electrical_properties.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



82
83
84
85
86
# File 'lib/shell_ev/models/connector_v2.rb', line 82

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} uid: #{@uid}, external_id: #{@external_id}, connector_type:"\
  " #{@connector_type}, electrical_properties: #{@electrical_properties}>"
end