This may seem obvious, but this framework is completely and totally abandoned. Look but don't touch.
RESTMan lets you easily interact with RESTful (GET, POST, PUT, DELETE) web APIs by allowing you to reference object type enums instead of URLs within your code. No messy in-line URLs to maintain.
// GET {YOUR_BASE_URL}/book/1234
[RESTMan getObjectOfType:BOOK withID:@"1234" parameters:nil success:^(id responseData) {
NSDictionary *book = responseData[@"book"];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// handle error just as you would when using AFNetworking
}];
Define all of your endpoints in a single plist file and let RESTMan do the rest. RESTman uses ARC and is built on top of AFNetworking
, but adds a layer of simplicity that lets you write more maintainable code.
Copy the RESTMan folder into your Xcode project (make sure the "Copy items..." box is selected).
Go to the Build Phases
tab for your target and add a New Run Script Build Phase
Add the following text to the the script area...
cd "${SRCROOT}/${PROJECT_NAME}/RESTMan/RESTMan"
/bin/sh "restman-generator.sh"
It should now look like this:
Open RESTMan.plist within your project. This file will be used to generate all of the endpoints used in your API.
For Base URL
, set the value as the base url of your applications web service.
Define all of your endpoints via Resources
. Add a new row for each resource in your web API that you want to use. Here is an example:
user#users
The first part before the #
defines the way you want to reference the object throughout your project. The second part after the #
should be the corresponding path name used by your API. In the example above, this will allow to refer refer to USER when using RESTMan, meanwhile under-the-hood RESTMan will generate URLs that use the /users
path.
In addition, RESTMan can support different kinds of nested paths. For example, if your APIs path for login is something like POST /auth/users/login
, where it is just a series of nested resources without IDs, you could do something like this.
session#auth/users/login
This would allow to make the following call using RESTMan...
[RESTMan createObjectOfType:SESSION parameters:loginCredentials success:^(id responseData) {
// get token from response data, etc...
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// handle invalid credentials, etc...
}];
For nested paths that combine 2 resources, use the RESTMan class methods that accept nested and root object types. See the documentation in RESTMan.h for the details, or just jump right in and start using it bc it's awesome.
You're done!
This script will automatically pull in your settings from RESTMan.plist
and generate your endpoints each time your project builds. Hit CMD-B
and then checkout RESTManConfig.h
to see your generated config file.
RESTMan lets you add your applications custom authentication logic via the RESTManAuthentication.h file. To do this you will need to modify the implementation of the authenticatedPath method.
Import RESTMan wherever you need to make API calls.
#import "RESTMan.h"
Use the public methods in RESTMan.h to easily get what you need from your web service.
+ (void)getObjectsOfType:(RESOURCE_TYPE)type
withParameters:(NSDictionary *)params
success:(void(^)(id responseData))successBlock
failure:(void(^)(AFHTTPRequestOperation *operation, NSError *error))failureBlock;
Check out RESTMan.h too see all of the methods available to you and to see more documentation.
- Cocoapods support
- Handling different types of authentication