Class: CyberSourceMergedSpec::VehicleData

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/vehicle_data.rb

Overview

VehicleData Model.

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(connector_type: SKIP, charging_reason_code: SKIP, additional_properties: nil) ⇒ VehicleData

Returns a new instance of VehicleData.



69
70
71
72
73
74
75
76
77
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 69

def initialize(connector_type: SKIP, charging_reason_code: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @connector_type = connector_type unless connector_type == SKIP
  @charging_reason_code = charging_reason_code unless charging_reason_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#charging_reason_codeString

This field will contain charging reason code values for electric vehicle transactions. Possible Values: 010 (Other Error) 011 (Connector Lock Failure) 012 (EV Communication Error) 013 (Ground Failure) 014 (High Temperature) 015 (Internal Error) 016 (Over Current Failure) 017 (Over Voltage) 018 (Power Meter Failure) 019 (Power Switch Failure) 020 (Reader Failure) 021 (Reset Failure) 022 (Under Voltage) 023 (Weak Signal) 100 (No Error) 200 (Payment Related Error)

Returns:

  • (String)


46
47
48
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 46

def charging_reason_code
  @charging_reason_code
end

#connector_typeString

This field will contain connector type values for electric vehicle transactions. Possible Values: 001 (AC - J1772 Type 1) 002 (AC - Mennekes - Type 2) 003 (AC - GB/T) 100 (DC - CCS1) 101 (DC - CHAdeMO) 102 (DC - CCS2) 103 (DC - GB/T) 200 (NACS – Tesla)

Returns:

  • (String)


24
25
26
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 24

def connector_type
  @connector_type
end

Class Method Details

.from_element(root) ⇒ Object



101
102
103
104
105
106
107
108
109
110
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 101

def self.from_element(root)
  connector_type = XmlUtilities.from_element(root, 'connectorType', String)
  charging_reason_code = XmlUtilities.from_element(root,
                                                   'chargingReasonCode',
                                                   String)

  new(connector_type: connector_type,
      charging_reason_code: charging_reason_code,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  connector_type = hash.key?('connectorType') ? hash['connectorType'] : SKIP
  charging_reason_code =
    hash.key?('chargingReasonCode') ? hash['chargingReasonCode'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  VehicleData.new(connector_type: connector_type,
                  charging_reason_code: charging_reason_code,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



49
50
51
52
53
54
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 49

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['connector_type'] = 'connectorType'
  @_hash['charging_reason_code'] = 'chargingReasonCode'
  @_hash
end

.nullablesObject

An array for nullable fields



65
66
67
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 65

def self.nullables
  []
end

.optionalsObject

An array for optional fields



57
58
59
60
61
62
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 57

def self.optionals
  %w[
    connector_type
    charging_reason_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



132
133
134
135
136
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 132

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

#to_sObject

Provides a human-readable string representation of the object.



125
126
127
128
129
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 125

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

#to_xml_element(doc, root_name) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/cyber_source_merged_spec/models/vehicle_data.rb', line 112

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'connectorType', connector_type)
  XmlUtilities.add_as_subelement(doc, root, 'chargingReasonCode',
                                 charging_reason_code)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end