First (half of a) draft of AFRestClient documentation

This commit is contained in:
Mattt Thompson 2011-09-18 15:06:29 -05:00
parent 5755666b30
commit 2f7f527d9c

View file

@ -33,27 +33,101 @@
NSOperationQueue *_operationQueue; NSOperationQueue *_operationQueue;
} }
/**
An `NSURL` object that is used as the base for paths specified in methods such as `getPath:parameteres:success:failure`
*/
@property (readonly, nonatomic, retain) NSURL *baseURL;
///--------------------------------
/// @name Initializing REST Clients
///--------------------------------
/**
Initializes an `AFRestClient` object with the specified base URL.
@param url The base URL for the REST client. This argument must not be nil.
@return The newly-initialized REST client
*/
- (id)initWithBaseURL:(NSURL *)url; - (id)initWithBaseURL:(NSURL *)url;
///----------------------------------
/// @name Managing HTTP Header Values
///----------------------------------
/**
Returns the value for the HTTP headers set in request objects created by the REST client
@param header The HTTP header to return the default value for
@return The default value for the HTTP header, or `nil` if unspecified
*/
- (NSString *)defaultValueForHeader:(NSString *)header; - (NSString *)defaultValueForHeader:(NSString *)header;
/**
Sets the value for the HTTP headers set in request objects made by the REST client. If `nil`, removes the existing value for that header.
@param header The HTTP header to set a default value for
@param value The value set as default for the specified header, or `nil
*/
- (void)setDefaultHeader:(NSString *)header value:(NSString *)value; - (void)setDefaultHeader:(NSString *)header value:(NSString *)value;
/**
Sets the "Authorization" HTTP header set in request objects made by the REST client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
@param username The HTTP basic auth username
@param password The HTTP basic auth password
*/
- (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password; - (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password;
/**
Sets the "Authorization" HTTP header set in request objects made by the REST client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
@param token The authentication token
*/
- (void)setAuthorizationHeaderWithToken:(NSString *)token; - (void)setAuthorizationHeaderWithToken:(NSString *)token;
/**
Clears any existing value for the "Authorization" HTTP header.
*/
- (void)clearAuthorizationHeader; - (void)clearAuthorizationHeader;
///-------------------------------
/// @name Creating Request Objects
///-------------------------------
/**
Creates an `NSMutableURLRequest` object with the specified HTTP method, resource path, and parameters, with the default HTTP headers specified for the client.
@param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`
@param path The resource path to be appended to the REST client's base URL and used as the request URL
@param parameters The parameters to be either set as a query string for `GET` requests, or form URL-encoded and set in the request HTTP body
@return An `NSMutableURLRequest` object
*/
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
path:(NSString *)path parameters:(NSDictionary *)parameters; path:(NSString *)path parameters:(NSDictionary *)parameters;
///--------------------------------
/// @name Enqueuing HTTP Operations
///--------------------------------
- (void)enqueueHTTPOperation:(AFHTTPRequestOperation *)operation; - (void)enqueueHTTPOperation:(AFHTTPRequestOperation *)operation;
- (void)enqueueHTTPOperationWithRequest:(NSURLRequest *)request - (void)enqueueHTTPOperationWithRequest:(NSURLRequest *)request
success:(void (^)(id response))success success:(void (^)(id response))success
failure:(void (^)(NSError *error))failure; failure:(void (^)(NSError *error))failure;
///---------------------------------
/// @name Cancelling HTTP Operations
///---------------------------------
- (void)cancelHTTPOperationsWithRequest:(NSURLRequest *)request; - (void)cancelHTTPOperationsWithRequest:(NSURLRequest *)request;
- (void)cancelAllHTTPOperations; - (void)cancelAllHTTPOperations;
///---------------------------
/// @name Making HTTP Requests
///---------------------------
- (void)getPath:(NSString *)path - (void)getPath:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
success:(void (^)(id response))success success:(void (^)(id response))success