-(void)getNewSessionWithEmail:(NSString*)email Password:(NSString*)password BaseUrl:(NSString*)baseUrl{
NSString *baseDspUrl=baseUrl;
[self.progressView setHidden:NO];
[self.activityIndicator startAnimating];
NIKApiInvoker *_api = [NIKApiInvoker sharedInstance];
NSString *serviceName = @"user"; // your service name here
NSString *apiName = @"session"; // rest path
NSString *restApiPath = [NSString stringWithFormat:@"%@/%@/%@",[self setBaseUrlPath:baseUrl],serviceName,apiName];
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
[headerParams setObject:kApplicationName forKey:@"X-DreamFactory-Application-Name"];
NSString* contentType = @"application/json";
NSDictionary *requestBody = @{@"email": email, @"password": password};
[_api dictionary:restApiPath method:@"POST" queryParams:queryParams body:requestBody headerParams:headerParams contentType:contentType completionBlock:^(NSDictionary *output, NSError *error) {
NSLog(@"ERROR %@",error);
NSLog(@"OUTPUT %@",[output objectForKey:@"id"]);
dispatch_async(dispatch_get_main_queue(),^ (void){
[self.progressView setHidden:YES];
[self.activityIndicator stopAnimating];
if(output){
NSString *SessionId=[output objectForKey:@"session_id"];
[[NSUserDefaults standardUserDefaults] setValue:baseDspUrl forKey:kBaseDspUrl];
[[NSUserDefaults standardUserDefaults] setValue:SessionId forKey:kSessionIdKey];
[[NSUserDefaults standardUserDefaults] setValue:email forKey:kUserEmail];
[[NSUserDefaults standardUserDefaults] setValue:password forKey:kPassword];
[[NSUserDefaults standardUserDefaults] synchronize];
//[self displayInitialViewController];
}else{
UIAlertView *message=[[UIAlertView alloc]initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"ok" otherButtonTitles: nil];
[message show];
}
});
}];
NSLog(@"%@==%@",@"New SESS:",[[NSUserDefaults standardUserDefaults] valueForKey:kSessionIdKey]);
NSLog(@"%@==%@",@"New REST:",restApiPath);
}
-(void)getTodoListContentFromServer{
NSString *swgSessionId=[[NSUserDefaults standardUserDefaults] valueForKey:kSessionIdKey];
if (swgSessionId.length>0) {
[self showProgressView:YES];
NIKApiInvoker *_api = [NIKApiInvoker sharedInstance];
NSString *serviceName = @"eMomentsServiceAPI"; // your service name here
//NSString *apiName = kTableName; // rest path
NSString *apiName = kTableName;
NSString *restApiPath = [NSString stringWithFormat:@"%@/%@/%@",baseUrl,serviceName,apiName];
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
queryParams[@"include_count"] = [NSNumber numberWithBool:TRUE];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
[headerParams setObject:kApplicationName forKey:@"X-DreamFactory-Application-Name"];
[headerParams setObject:swgSessionId forKey:@"X-DreamFactory-Session-Token"];
NSString* contentType = @"application/json";
id bodyDictionary = nil;
[self.progressView setHidden:NO];
[self.activityIndicator startAnimating];
[_api dictionary:restApiPath method:@"GET" queryParams:queryParams body:bodyDictionary headerParams:headerParams contentType:contentType completionBlock:^(NSDictionary *responseDict, NSError *error) {
NSLog(@"Error %@",error);
dispatch_async(dispatch_get_main_queue(),^ (void){
[self showProgressView:NO];
});
if (error) {
dispatch_async(dispatch_get_main_queue(),^ (void){
[self.navigationController popToRootViewControllerAnimated:YES];
});
}else{
[self.todoListContentArray removeAllObjects];
for (NSDictionary *recordInfo in [responseDict objectForKey:@"record"]) {
TODORecord *newRecord=[[TODORecord alloc]init];
[newRecord setRecord_Id:[recordInfo objectForKey:@"id"]];
[newRecord setRecord_Task:[recordInfo objectForKey:@"name"]];
[newRecord setRecord_Complete:[recordInfo objectForKey:@"complete"]];
[self.todoListContentArray addObject:newRecord];
}
dispatch_async(dispatch_get_main_queue(),^ (void){
[self.todoListTableView reloadData];
[self.todoListTableView setNeedsDisplay];
});
}
}];
}else{
}
}
This code is taken from the IOS SDK app.
Can any kind soul help me figure out what is the rest path for my app? Thanks