Class: Gurunavi::APIErrorFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/gurunavi/api_error.rb

Constant Summary collapse

ERRORS =

error responces document is bellow: api.gnavi.co.jp/api/manual/restsearch/#errors

{
  "429" => "TooManyAccess",
  "600" => "NoShop",
  "601" => "InvalidAccess",
  "602" => "InvalidShopNumber",
  "603" => "InvalidType",
  "604" => "InternalServerError",
}.freeze

Class Method Summary collapse

Class Method Details

.call_api_errors(code, message) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/gurunavi/api_error.rb', line 16

def call_api_errors(code, message)
  if ERRORS.include?(code.to_s)
    return Gurunavi.const_get(ERRORS[code.to_s]).new(code, message)
  end
  # no definition status in ERRORS, return APIError
  return Gurunavi::APIError.new(code, message)
end