I suggest we need some more enhanced filter/read function:
(E.g. with a resource
argument to receive the nested resource...)
NSURL* serverURL = [NSURL URLWithString:@"http://todo-aerogear.rhcloud.com/"];
AGPipeline* pipeline = [AGPipeline pipelineWithBaseURL:serverURL];
// Add a REST pipe for the 'posts' endpoint
id<AGPipe> postsPipe = [pipeline pipe:^(id<AGPipeConfig> config) {
[config setName:@"posts"];
}];
// READ comments for ID:1
[postsPipe read:1 resource:@"comments" success:^(id responseObject) {
// LOG the JSON response, returned from the server:
NSLog(@"READ RESPONSE\n%@", [responseObject description]);
} failure:^(NSError *error) {
// when an error occurs... at least log it to the console..
NSLog(@"Read: An error occured! \n%@", error);
}];
// READ comments for ID:2
[postsPipe read:2 resource:@"comments" success:^(id responseObject) {
// LOG the JSON response, returned from the server:
NSLog(@"READ RESPONSE\n%@", [responseObject description]);
} failure:^(NSError *error) {
// when an error occurs... at least log it to the console..
NSLog(@"Read: An error occured! \n%@", error);
}];
Here... we can REUSE the pipe, to receive different comments, from different posts