Class: GoogleMapsPlatform::ElevationResponse
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::ElevationResponse
- Defined in:
- lib/google_maps_platform/models/elevation_response.rb
Overview
ElevationResponse Model.
Instance Attribute Summary collapse
-
#error_message ⇒ String
When the service returns a status code other than
OK, there may be an additionalerror_messagefield within the response object. -
#results ⇒ Array[ElevationResult]
Status codes returned by service.
-
#status ⇒ ElevationStatus
Status codes returned by service.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(status:, results:, error_message: SKIP, additional_properties: nil) ⇒ ElevationResponse
constructor
A new instance of ElevationResponse.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(status:, results:, error_message: SKIP, additional_properties: nil) ⇒ ElevationResponse
Returns a new instance of ElevationResponse.
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 75 def initialize(status:, results:, error_message: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? = unless == SKIP @status = status @results = results @additional_properties = additional_properties end |
Instance Attribute Details
#error_message ⇒ String
When the service returns a status code other than OK, there may be an additional error_message field within the response object. This field contains more detailed information about thereasons behind the given status code. This field is not always returned, and its content is subject to change.
18 19 20 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 18 def end |
#results ⇒ Array[ElevationResult]
Status codes returned by service.
-
OKindicating the API request was successful. -
DATA_NOT_AVAILABLEindicating that there’s no available data for the
input locations.
-
INVALID_REQUESTindicating the API request was malformed. -
OVER_DAILY_LIMITindicating any of the following:-
The API key is missing or invalid.
-
Billing has not been enabled on your account.
-
A self-imposed usage cap has been exceeded.
-
The provided method of payment is no longer valid (for example, a
-
credit card has expired).
-
OVER_QUERY_LIMITindicating the requestor has exceeded quota. -
REQUEST_DENIEDindicating the API did not complete the request. -
UNKNOWN_ERRORindicating an unknown error.
52 53 54 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 52 def results @results end |
#status ⇒ ElevationStatus
Status codes returned by service.
-
OKindicating the API request was successful. -
DATA_NOT_AVAILABLEindicating that there’s no available data for the
input locations.
-
INVALID_REQUESTindicating the API request was malformed. -
OVER_DAILY_LIMITindicating any of the following:-
The API key is missing or invalid.
-
Billing has not been enabled on your account.
-
A self-imposed usage cap has been exceeded.
-
The provided method of payment is no longer valid (for example, a
-
credit card has expired).
-
OVER_QUERY_LIMITindicating the requestor has exceeded quota. -
REQUEST_DENIEDindicating the API did not complete the request. -
UNKNOWN_ERRORindicating an unknown error.
35 36 37 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 35 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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/elevation_response.rb', line 87 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. status = hash.key?('status') ? hash['status'] : nil # Parameter is an array, so we need to iterate through it results = nil unless hash['results'].nil? results = [] hash['results'].each do |structure| results << (ElevationResult.from_hash(structure) if structure) end end results = nil unless hash.key?('results') = hash.key?('error_message') ? hash['error_message'] : 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. ElevationResponse.new(status: status, results: results, error_message: , additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
55 56 57 58 59 60 61 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 55 def self.names @_hash = {} if @_hash.nil? @_hash['error_message'] = 'error_message' @_hash['status'] = 'status' @_hash['results'] = 'results' @_hash end |
.nullables ⇒ Object
An array for nullable fields
71 72 73 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 71 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
64 65 66 67 68 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 64 def self.optionals %w[ error_message ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
126 127 128 129 130 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 126 def inspect class_name = self.class.name.split('::').last "<#{class_name} error_message: #{@error_message.inspect}, status: #{@status.inspect},"\ " results: #{@results.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
119 120 121 122 123 |
# File 'lib/google_maps_platform/models/elevation_response.rb', line 119 def to_s class_name = self.class.name.split('::').last "<#{class_name} error_message: #{@error_message}, status: #{@status}, results: #{@results},"\ " additional_properties: #{@additional_properties}>" end |