Tuesday, April 7, 2015

Objective-C REST API Network Status Codes

Objective-C REST API Network Status Codes 

/*!
@typedef NS_ENUM (NSUInteger, kStatusInformation)
@abstract Informational responses.
@discussion
These are valid only in the scope of <Project Name>.
*/
typedef NS_ENUM(NSInteger, kStatusInformation) {
/*!
This interim response indicates that everything so far is OK
and that the client should continue with the request or ignore
it if it is already finished.
*/
kStatusInformation_Continue = 100,
/*!
This code is sent in response to an Upgrade: request header by
the client, and indicates that the protocol the server is switching too.
It was introduced to allow migration to an incompatible protocol version,
and is not in common use.
*/
kStatusInformation_SwitchingProtocol = 101,
};
 
 
/*!
@typedef NS_ENUM (NSUInteger, kStatusSuccess)
@abstract Successful responses.
@discussion
These are valid only in the scope of Momentage.
*/
typedef NS_ENUM(NSInteger, kStatusSuccess) {
/*! The request has succeeded. */
kStatusSuccess_OK = 200,
/*!
The request has succeeded and a new resource has been
created as a result of it.
This is typically the response sent after a PUT request.
*/
kStatusSuccess_Created = 201,
/*!
The request has been received but not yet acted upon.
It is non-committal, meaning that there is no way in HTTP to later send
an asynchronous response indicating the outcome of processing the request.
It is intended for cases where another process or server handles the request,
or for batch processing.
*/
kStatusSuccess_Accepted = 202,
/*!
This response code means returned meta-information set is not exact
set as available from the origin server, but collected from a local
or a third party copy. Except this condition, 200 OK response should
be preferred instead of this response.
*/
kStatusSuccess_PartialInfo = 203,
/*!
There is no content to send for this request, but the headers may be
useful. The user-agent may update its cached headers for this
resource with the new ones.
*/
kStatusSuccess_NoResponse = 204,
/*!
This response code is sent after accomplishing request to tell user
agent reset document view which sent this request.
*/
kStatusSuccess_RestContent = 205,
/*!
This response code is used because of range header sent by the client
to separate download into multiple streams.
*/
kStatusSuccess_PartialContent = 206,
/*! */
kStatusSuccess_251 = 251,
};
/*! */
 
/*!
@typedef NS_ENUM (NSUInteger, FBErrorCode)
@abstract Error codes returned by the Facebook SDK in NSError.
@discussion
These are valid only in the scope of FacebookSDKDomain.
*/
typedef NS_ENUM(NSInteger, APIErrorCode) {
APIErrorCodeMultipleChoice = 300
};
 
 
// 4xx Client error
/*!
@typedef NS_ENUM (NSUInteger, kStatusClientError)
@abstract Client error responses
@discussion
These are valid only in the scope of Momentage.
*/
typedef NS_ENUM(NSInteger, kStatusClientError) {
/*! */
kStatusClientError_BadRequest = 400,
/*! */
kStatusClientError_Unauthorized = 401,
/*! */
kStatusClientError_PaymentRequest = 402,
/*! */
kStatusClientError_Forbidden = 403,
/*! */
kStatusClientError_NotFound = 404,
/*! */
kStatusClientError_MethodNotAllowed = 405,
kStatusClientError_ExpectationFailed = 417,
};
 
// 5xx Server error responses
/*!
@typedef NS_ENUM (NSUInteger, kStatusServerError)
@abstract Client error responses
@discussion
These are valid only in the scope of Momentage.
*/
typedef NS_ENUM(NSInteger, kStatusServerError) {
/*! The server has encountered a situation it doesn't know how to handle. */
kStatusServerError_InternalError = 500,
/*!
The request method is not supported by the server and cannot be handled. The only
methods that servers are required to support (and therefore that must not return
this code) are GET and HEAD.
*/
kStatusServerError_NotImplemented = 501,
/*!
This error response means that the server, while working as a gateway to get a
response needed to handle the request, got an invalid response.
*/
kStatusServerError_BadGateway = 502,
/*!
The server is not ready to handle the request. Common causes are a server that is
down for maintenance or that is overloaded. Note that together with this response,
a user-friendly page explaining the problem should be sent. This responses should
be used for temporary conditions and the Retry-After: HTTP header should, if
possible, contain the estimated time before the recovery of the service. The
webmaster must also take care about the caching-related headers that are sent
along with this response, as these temporary condition responses should usually
not be cached.
*/
kStatusServerError_ServiceUnavailable = 503,
/*!
This error response is given when the server is acting as a gateway and cannot get
a response in time.
*/
kStatusServerError_GatewayTimeout = 504,
/*! The HTTP version used in the request is not supported by the server. */
kStatusServerError_HTTPVersionNotSupported = 505,
};

via - 
Github Gist

Other Links -