Class: Urbanairship::Common::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/urbanairship/common.rb

Class Method Summary collapse

Class Method Details

.check_code(response_code, response) ⇒ Object

Parse Response Codes and trigger appropriate actions.



143
144
145
146
147
148
149
150
151
# File 'lib/urbanairship/common.rb', line 143

def self.check_code(response_code, response)
  if response_code == 401
    raise Unauthorized, 'Client is not authorized to make this request. The authorization credentials are incorrect or missing.'
  elsif response_code == 403
    raise Forbidden, 'Client is forbidden from making this request. The application does not have the proper entitlement to access this feature.'
  elsif !((200...300).include?(response_code))
    raise AirshipFailure.new.from_response(response)
  end
end