Class: ShellEv::SingleLocationMarker

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

Overview

A Marker is a place on the map that represent a single Location

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(marker_type = nil, unique_key = SKIP, status = SKIP, coordinates = SKIP, evse_count = SKIP, max_power = SKIP, geo_hash = SKIP, location_uid = SKIP, authorization_methods = SKIP, operator_id = SKIP) ⇒ SingleLocationMarker

Returns a new instance of SingleLocationMarker.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/shell_ev/models/single_location_marker.rb', line 92

def initialize(marker_type = nil, unique_key = SKIP, status = SKIP,
               coordinates = SKIP, evse_count = SKIP, max_power = SKIP,
               geo_hash = SKIP, location_uid = SKIP,
               authorization_methods = SKIP, operator_id = SKIP)
  @marker_type = marker_type
  @unique_key = unique_key unless unique_key == SKIP
  @status = status unless status == SKIP
  @coordinates = coordinates unless coordinates == SKIP
  @evse_count = evse_count unless evse_count == SKIP
  @max_power = max_power unless max_power == SKIP
  @geo_hash = geo_hash unless geo_hash == SKIP
  @location_uid = location_uid unless location_uid == SKIP
  @authorization_methods = authorization_methods unless authorization_methods == SKIP
  @operator_id = operator_id unless operator_id == SKIP
end

Instance Attribute Details

#authorization_methodsArray[SingleLocationMarkerAuthorizationMethodsItemsEnum]

Methods that can be used to Authorize sessions on this EVSE



50
51
52
# File 'lib/shell_ev/models/single_location_marker.rb', line 50

def authorization_methods
  @authorization_methods
end

#coordinatesCoordinates1

Minimum of all status values in the Marker, e.g. if at least one Evse in the Marker is available, the value will be available

Returns:



29
30
31
# File 'lib/shell_ev/models/single_location_marker.rb', line 29

def coordinates
  @coordinates
end

#evse_countFloat

Total number of Evse units in Locations that this Marker represents

Returns:

  • (Float)


33
34
35
# File 'lib/shell_ev/models/single_location_marker.rb', line 33

def evse_count
  @evse_count
end

#geo_hashString

GeoHash of marker coordinates

Returns:

  • (String)


42
43
44
# File 'lib/shell_ev/models/single_location_marker.rb', line 42

def geo_hash
  @geo_hash
end

#location_uidFloat

Unique ID of the Location this Marker represents

Returns:

  • (Float)


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

def location_uid
  @location_uid
end

#marker_typeString

Identifies the marker type. If it’s a ‘SingleLocationMarker`, then the value is `SingleLocation`

Returns:

  • (String)


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

def marker_type
  @marker_type
end

#max_powerFloat

Maximum power in kW across all locations grouped in this marker (disregarding availability)

Returns:

  • (Float)


38
39
40
# File 'lib/shell_ev/models/single_location_marker.rb', line 38

def max_power
  @max_power
end

#operator_idString

Unique Id of the operator

Returns:

  • (String)


54
55
56
# File 'lib/shell_ev/models/single_location_marker.rb', line 54

def operator_id
  @operator_id
end

#statusSingleLocationMarkerStatusEnum

Minimum of all status values in the Marker, e.g. if at least one Evse in the Marker is available, the value will be available



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

def status
  @status
end

#unique_keyString

Uniquely identifies the marker object

Returns:

  • (String)


19
20
21
# File 'lib/shell_ev/models/single_location_marker.rb', line 19

def unique_key
  @unique_key
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
# File 'lib/shell_ev/models/single_location_marker.rb', line 109

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  marker_type = hash.key?('markerType') ? hash['markerType'] : nil
  unique_key = hash.key?('uniqueKey') ? hash['uniqueKey'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  coordinates = Coordinates1.from_hash(hash['coordinates']) if hash['coordinates']
  evse_count = hash.key?('evseCount') ? hash['evseCount'] : SKIP
  max_power = hash.key?('maxPower') ? hash['maxPower'] : SKIP
  geo_hash = hash.key?('geoHash') ? hash['geoHash'] : SKIP
  location_uid = hash.key?('locationUid') ? hash['locationUid'] : SKIP
  authorization_methods =
    hash.key?('authorizationMethods') ? hash['authorizationMethods'] : SKIP
  operator_id = hash.key?('operatorId') ? hash['operatorId'] : SKIP

  # Create object from extracted values.
  SingleLocationMarker.new(marker_type,
                           unique_key,
                           status,
                           coordinates,
                           evse_count,
                           max_power,
                           geo_hash,
                           location_uid,
                           authorization_methods,
                           operator_id)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/shell_ev/models/single_location_marker.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['marker_type'] = 'markerType'
  @_hash['unique_key'] = 'uniqueKey'
  @_hash['status'] = 'status'
  @_hash['coordinates'] = 'coordinates'
  @_hash['evse_count'] = 'evseCount'
  @_hash['max_power'] = 'maxPower'
  @_hash['geo_hash'] = 'geoHash'
  @_hash['location_uid'] = 'locationUid'
  @_hash['authorization_methods'] = 'authorizationMethods'
  @_hash['operator_id'] = 'operatorId'
  @_hash
end

.nullablesObject

An array for nullable fields



88
89
90
# File 'lib/shell_ev/models/single_location_marker.rb', line 88

def self.nullables
  []
end

.optionalsObject

An array for optional fields



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/shell_ev/models/single_location_marker.rb', line 73

def self.optionals
  %w[
    unique_key
    status
    coordinates
    evse_count
    max_power
    geo_hash
    location_uid
    authorization_methods
    operator_id
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/shell_ev/models/single_location_marker.rb', line 140

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.marker_type,
                                 ->(val) { val.instance_of? String })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['markerType'],
                        ->(val) { val.instance_of? String })
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



162
163
164
165
166
167
168
169
# File 'lib/shell_ev/models/single_location_marker.rb', line 162

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} marker_type: #{@marker_type.inspect}, unique_key: #{@unique_key.inspect},"\
  " status: #{@status.inspect}, coordinates: #{@coordinates.inspect}, evse_count:"\
  " #{@evse_count.inspect}, max_power: #{@max_power.inspect}, geo_hash: #{@geo_hash.inspect},"\
  " location_uid: #{@location_uid.inspect}, authorization_methods:"\
  " #{@authorization_methods.inspect}, operator_id: #{@operator_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



153
154
155
156
157
158
159
# File 'lib/shell_ev/models/single_location_marker.rb', line 153

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} marker_type: #{@marker_type}, unique_key: #{@unique_key}, status:"\
  " #{@status}, coordinates: #{@coordinates}, evse_count: #{@evse_count}, max_power:"\
  " #{@max_power}, geo_hash: #{@geo_hash}, location_uid: #{@location_uid},"\
  " authorization_methods: #{@authorization_methods}, operator_id: #{@operator_id}>"
end