Class: GoogleMapsPlatform::DistanceMatrixStatus

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

Overview

Status codes returned by service. - OK indicates the response contains a valid result. - INVALID_REQUEST indicates that the provided request was invalid. - MAX_ELEMENTS_EXCEEDED indicates that the product of origins and destinations exceeds the per-query limit. - MAX_DIMENSIONS_EXCEEDED indicates that the number of origins or destinations exceeds the per-query limit. - OVER_DAILY_LIMIT indicates 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_LIMIT indicates the service has received too many requests from your application within the allowed time period. - REQUEST_DENIED indicates that the service denied use of the Distance Matrix service by your application. - UNKNOWN_ERROR indicates a Distance Matrix request could not be processed due to a server error. The request may succeed if you try again.

Constant Summary collapse

DISTANCE_MATRIX_STATUS =
[
  # TODO: Write general description for OK
  OK = 'OK'.freeze,

  # TODO: Write general description for INVALID_REQUEST
  INVALID_REQUEST = 'INVALID_REQUEST'.freeze,

  # TODO: Write general description for MAX_ELEMENTS_EXCEEDED
  MAX_ELEMENTS_EXCEEDED = 'MAX_ELEMENTS_EXCEEDED'.freeze,

  # TODO: Write general description for MAX_DIMENSIONS_EXCEEDED
  MAX_DIMENSIONS_EXCEEDED = 'MAX_DIMENSIONS_EXCEEDED'.freeze,

  # TODO: Write general description for OVER_DAILY_LIMIT
  OVER_DAILY_LIMIT = 'OVER_DAILY_LIMIT'.freeze,

  # TODO: Write general description for OVER_QUERY_LIMIT
  OVER_QUERY_LIMIT = 'OVER_QUERY_LIMIT'.freeze,

  # TODO: Write general description for REQUEST_DENIED
  REQUEST_DENIED = 'REQUEST_DENIED'.freeze,

  # TODO: Write general description for UNKNOWN_ERROR
  UNKNOWN_ERROR = 'UNKNOWN_ERROR'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = OK) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/google_maps_platform/models/distance_matrix_status.rb', line 55

def self.from_value(value, default_value = OK)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'ok' then OK
  when 'invalid_request' then INVALID_REQUEST
  when 'max_elements_exceeded' then MAX_ELEMENTS_EXCEEDED
  when 'max_dimensions_exceeded' then MAX_DIMENSIONS_EXCEEDED
  when 'over_daily_limit' then OVER_DAILY_LIMIT
  when 'over_query_limit' then OVER_QUERY_LIMIT
  when 'request_denied' then REQUEST_DENIED
  when 'unknown_error' then UNKNOWN_ERROR
  else
    default_value
  end
end

.validate(value) ⇒ Object



49
50
51
52
53
# File 'lib/google_maps_platform/models/distance_matrix_status.rb', line 49

def self.validate(value)
  return false if value.nil?

  DISTANCE_MATRIX_STATUS.include?(value)
end