PWAPIManager Class Reference
Inherits from | NSObject |
---|---|
Declared in | PWAPIManager.h |
Overview
A generic class for making HTTP/HTTPS calls, and the authentication header will be automatically added.
– get:withParameters:withCompletion:
Send a GET
request for specific endpoint and parameters.
- (void)get:(NSString *)endpoint withParameters:(NSDictionary *)parameters withCompletion:(void ( ^ ) ( id response , NSError *error ))completion
Parameters
endpoint |
The endpoint for the request. |
---|---|
parameters |
The parameters for the request. |
completion |
A block that returns the HTTP response or error. |
Declared In
PWAPIManager.h
– getCached:withParameters:withCompletion:
Send a GET
request for specific endpoint and parameters, and the response may be fetched from the cache.
- (void)getCached:(NSString *)endpoint withParameters:(NSDictionary *)parameters withCompletion:(void ( ^ ) ( id response , NSError *error ))completion
Parameters
endpoint |
The endpoint for the request. |
---|---|
parameters |
The parameters for the request. |
completion |
A block that returns the HTTP response or error. |
Discussion
The HTTP response is cached for 24 hours, so it will return you the cached data if you request again in 24 hours. You can use get:...
if you want to get the real-time response.
Declared In
PWAPIManager.h
– post:withParameters:withCompletion:
Send a POST
request for specific endpoint and parameters.
- (void)post:(NSString *)endpoint withParameters:(NSDictionary *)parameters withCompletion:(void ( ^ ) ( id response , NSError *error ))completion
Parameters
endpoint |
The endpoint for the request. |
---|---|
parameters |
The parameters for the request. |
completion |
A block that returns the HTTP response or error. |
Declared In
PWAPIManager.h
– request:withHTTPMethod:withParameters:withCompletion:
Send a request for specific endpoint, parameters and HTTP method.
- (void)request:(NSString *)endpoint withHTTPMethod:(NSString *)httpMethod withParameters:(NSDictionary *)parameters withCompletion:(void ( ^ ) ( id response , NSError *error ))completion
Parameters
endpoint |
The endpoint for the request. |
---|---|
httpMethod |
The http request for the request. |
parameters |
The parameters for the request. |
completion |
A block that returns the HTTP response or error. |
Declared In
PWAPIManager.h