Class: GoogleMapsPlatform::DistanceMatrixResponse
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::DistanceMatrixResponse
- Defined in:
- lib/google_maps_platform/models/distance_matrix_response.rb
Overview
DistanceMatrixResponse Model.
Instance Attribute Summary collapse
-
#destination_addresses ⇒ Array[String]
An array of addresses as returned by the API from your original request.
-
#error_message ⇒ String
A string containing the human-readable text of any errors encountered while the request was being processed.
-
#origin_addresses ⇒ Array[String]
An array of addresses as returned by the API from your original request.
-
#rows ⇒ Array[DistanceMatrixRow]
An array of elements, which in turn each contain a
status,duration, anddistanceelement. -
#status ⇒ DistanceMatrixStatus
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(origin_addresses:, destination_addresses:, rows:, status:, error_message: SKIP, additional_properties: nil) ⇒ DistanceMatrixResponse
constructor
A new instance of DistanceMatrixResponse.
-
#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(origin_addresses:, destination_addresses:, rows:, status:, error_message: SKIP, additional_properties: nil) ⇒ DistanceMatrixResponse
Returns a new instance of DistanceMatrixResponse.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 81 def initialize(origin_addresses:, destination_addresses:, rows:, status:, error_message: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @origin_addresses = origin_addresses @destination_addresses = destination_addresses @rows = rows @status = status @error_message = unless == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#destination_addresses ⇒ Array[String]
An array of addresses as returned by the API from your original request. As with origin_addresses, these are localized if appropriate. This content is meant to be read as-is. Do not programatically parse the formatted addresses.
24 25 26 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 24 def destination_addresses @destination_addresses end |
#error_message ⇒ String
A string containing the human-readable text of any errors encountered while the request was being processed.
56 57 58 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 56 def @error_message end |
#origin_addresses ⇒ Array[String]
An array of addresses as returned by the API from your original request. These are formatted by the geocoder and localized according to the language parameter passed with the request. This content is meant to be read as-is. Do not programatically parse the formatted addresses.
17 18 19 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 17 def origin_addresses @origin_addresses end |
#rows ⇒ Array[DistanceMatrixRow]
An array of elements, which in turn each contain a status, duration, and distance element.
29 30 31 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 29 def rows @rows end |
#status ⇒ DistanceMatrixStatus
Status codes returned by service.
-
OKindicates the response contains a valid result. -
INVALID_REQUESTindicates that the provided request was invalid. -
MAX_ELEMENTS_EXCEEDEDindicates that the product of origins and
destinations exceeds the per-query limit.
-
MAX_DIMENSIONS_EXCEEDEDindicates that the number of origins or
destinations exceeds the per-query limit.
-
OVER_DAILY_LIMITindicates 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_LIMITindicates the service has received too many requests
from your application within the allowed time period.
-
REQUEST_DENIEDindicates that the service denied use of the Distance
Matrix service by your application.
-
UNKNOWN_ERRORindicates a Distance Matrix request could not be
processed due to a server error. The request may succeed if you try again.
51 52 53 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 51 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 95 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. origin_addresses = hash.key?('origin_addresses') ? hash['origin_addresses'] : nil destination_addresses = hash.key?('destination_addresses') ? hash['destination_addresses'] : nil # Parameter is an array, so we need to iterate through it rows = nil unless hash['rows'].nil? rows = [] hash['rows'].each do |structure| rows << (DistanceMatrixRow.from_hash(structure) if structure) end end rows = nil unless hash.key?('rows') status = hash.key?('status') ? hash['status'] : nil = 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. DistanceMatrixResponse.new(origin_addresses: origin_addresses, destination_addresses: destination_addresses, rows: rows, status: status, error_message: , additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
59 60 61 62 63 64 65 66 67 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 59 def self.names @_hash = {} if @_hash.nil? @_hash['origin_addresses'] = 'origin_addresses' @_hash['destination_addresses'] = 'destination_addresses' @_hash['rows'] = 'rows' @_hash['status'] = 'status' @_hash['error_message'] = 'error_message' @_hash end |
.nullables ⇒ Object
An array for nullable fields
77 78 79 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 77 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
70 71 72 73 74 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 70 def self.optionals %w[ error_message ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
141 142 143 144 145 146 147 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 141 def inspect class_name = self.class.name.split('::').last "<#{class_name} origin_addresses: #{@origin_addresses.inspect}, destination_addresses:"\ " #{@destination_addresses.inspect}, rows: #{@rows.inspect}, status: #{@status.inspect},"\ " error_message: #{@error_message.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
133 134 135 136 137 138 |
# File 'lib/google_maps_platform/models/distance_matrix_response.rb', line 133 def to_s class_name = self.class.name.split('::').last "<#{class_name} origin_addresses: #{@origin_addresses}, destination_addresses:"\ " #{@destination_addresses}, rows: #{@rows}, status: #{@status}, error_message:"\ " #{@error_message}, additional_properties: #{@additional_properties}>" end |