Top Level Namespace

Defined Under Namespace

Modules: FastTrack

Constant Summary collapse

ERRORS_BY_STATUS =
{
  '400' => FastTrack::BadRequestException,
  '401' => FastTrack::UnauthorizedException,
  '404' => FastTrack::NotFoundException,
  '405' => FastTrack::MethodNotAllowedException,
  '406' => FastTrack::NotAcceptableException,
  '429' => FastTrack::TooManyRequestsException
}
ERRORS_BY_ERROR_CODE =
{
  '1' => FastTrack::VersionRequiredException,
  '2' => FastTrack::NoResultException,
  '3' => FastTrack::BadParametersException,
  '4' => FastTrack::InvalidVersionException
}
ACCEPT =
'application/vnd.fasttrack+json'
URL =
'https://api.fasttrack-intl.com'
VERSION =
1
PATHNAME_COMPANY =
'/company'
PATHNAME_CONTACT =
'/contact'
TIMEOUT =
5000

Instance Method Summary collapse

Instance Method Details

#exception_for_response(status, errorCode) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/common.rb', line 19

def exception_for_response(status, errorCode)
  fast_track_error = nil

  if errorCode != nil
    fast_track_error = ERRORS_BY_ERROR_CODE[errorCode]
  end

  if fast_track_error == nil && status != nil
    fast_track_error = ERRORS_BY_STATUS[status.to_s]

    if status >= 500 && status < 600
      fast_track_error = FastTrack::InternalServerException
    end
  end

  if fast_track_error == nil
    fast_track_error = Exception
  end

  return fast_track_error
end