Class: GoogleMapsPlatform::ErrorDetail

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/google_maps_platform/models/error_detail.rb

Overview

ErrorDetail 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(m_type: SKIP, message: SKIP, reason: SKIP, domain: SKIP, metadata: SKIP, field_violations: SKIP, additional_properties: nil) ⇒ ErrorDetail

Returns a new instance of ErrorDetail.



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

def initialize(m_type: SKIP, message: SKIP, reason: SKIP, domain: SKIP,
               metadata: SKIP, field_violations: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @m_type = m_type unless m_type == SKIP
  @message = message unless message == SKIP
  @reason = reason unless reason == SKIP
  @domain = domain unless domain == SKIP
  @metadata =  unless  == SKIP
  @field_violations = field_violations unless field_violations == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#domainString

The domain in which the error occurred.

Returns:

  • (String)


26
27
28
# File 'lib/google_maps_platform/models/error_detail.rb', line 26

def domain
  @domain
end

#field_violationsArray[FieldViolation]

A list of field violations.

Returns:



34
35
36
# File 'lib/google_maps_platform/models/error_detail.rb', line 34

def field_violations
  @field_violations
end

#m_typeString

The type of error.

Returns:

  • (String)


14
15
16
# File 'lib/google_maps_platform/models/error_detail.rb', line 14

def m_type
  @m_type
end

#messageString

A short description of the error.

Returns:

  • (String)


18
19
20
# File 'lib/google_maps_platform/models/error_detail.rb', line 18

def message
  @message
end

#metadataObject

Additional metadata about the error.

Returns:

  • (Object)


30
31
32
# File 'lib/google_maps_platform/models/error_detail.rb', line 30

def 
  @metadata
end

#reasonString

A reason for the error.

Returns:

  • (String)


22
23
24
# File 'lib/google_maps_platform/models/error_detail.rb', line 22

def reason
  @reason
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/google_maps_platform/models/error_detail.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  m_type = hash.key?('@type') ? hash['@type'] : SKIP
  message = hash.key?('message') ? hash['message'] : SKIP
  reason = hash.key?('reason') ? hash['reason'] : SKIP
  domain = hash.key?('domain') ? hash['domain'] : SKIP
   = hash.key?('metadata') ? hash['metadata'] : SKIP
  # Parameter is an array, so we need to iterate through it
  field_violations = nil
  unless hash['fieldViolations'].nil?
    field_violations = []
    hash['fieldViolations'].each do |structure|
      field_violations << (FieldViolation.from_hash(structure) if structure)
    end
  end

  field_violations = SKIP unless hash.key?('fieldViolations')

  # 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.
  ErrorDetail.new(m_type: m_type,
                  message: message,
                  reason: reason,
                  domain: domain,
                  metadata: ,
                  field_violations: field_violations,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/google_maps_platform/models/error_detail.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['m_type'] = '@type'
  @_hash['message'] = 'message'
  @_hash['reason'] = 'reason'
  @_hash['domain'] = 'domain'
  @_hash['metadata'] = 'metadata'
  @_hash['field_violations'] = 'fieldViolations'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/google_maps_platform/models/error_detail.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/google_maps_platform/models/error_detail.rb', line 49

def self.optionals
  %w[
    m_type
    message
    reason
    domain
    metadata
    field_violations
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



127
128
129
130
131
132
133
# File 'lib/google_maps_platform/models/error_detail.rb', line 127

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} m_type: #{@m_type.inspect}, message: #{@message.inspect}, reason:"\
  " #{@reason.inspect}, domain: #{@domain.inspect}, metadata: #{@metadata.inspect},"\
  " field_violations: #{@field_violations.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



119
120
121
122
123
124
# File 'lib/google_maps_platform/models/error_detail.rb', line 119

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} m_type: #{@m_type}, message: #{@message}, reason: #{@reason}, domain:"\
  " #{@domain}, metadata: #{@metadata}, field_violations: #{@field_violations},"\
  " additional_properties: #{@additional_properties}>"
end