This web page is under construction. |
Authentication
Find out how many teams I am part of
Get team project list
Get project details
Get project topology
Get project disciplines
Upload project thumbnail
Create an issue in the project
Get the issue list from the project
Delete all the issues from the project
Create a new pin for the issue
Get all the pins of the issue
Create/Upload a new attachment for the issue
Get the attachment list from the issue
|
|
|
|
|
|
|
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton]; //get its dictionary: NSMutableDictionary *currentIssueData = [self getIssueInformationForIssueId:ISSUE_ID]; //create nsdata for uploading: NSError *error; NSData *dataForCurrentIssue = [NSJSONSerialization dataWithJSONObject:currentIssueData options:NSJSONWritingPrettyPrinted error:&error]; //create issue request: NSMutableURLRequest *uploadRequestForCurrentIssue; uploadRequestForCurrentIssue = [[NSMutableURLRequest alloc] init]; NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/projects/%@/issues", [CSS getDefaultAPIURL], [CSS getSlug], self.mID]; [uploadRequestForCurrentIssue setURL:[NSURL URLWithString:urlStringForIssue]]; [uploadRequestForCurrentIssue setHTTPMethod:@"POST"]; [uploadRequestForCurrentIssue setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [uploadRequestForCurrentIssue setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"]; [uploadRequestForCurrentIssue setHTTPBody:dataForCurrentIssue]; NSHTTPURLResponse *responseHTTPForCurrentIssue; NSData *responseForCurrentIssue = [NSURLConnection sendSynchronousRequest:uploadRequestForCurrentIssue returningResponse:&responseHTTPForCurrentIssue error:&error]; [uploadRequestForCurrentIssue release]; if ([responseHTTPForCurrentIssue statusCode] == 201) { // Success, issue uploaded }else{ // Error, upload failed } |
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton]; //create issue request: NSMutableURLRequest *issueListRequest; issueListRequest = [[NSMutableURLRequest alloc] init]; NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/projects/%@/issues", [CSS getDefaultAPIURL], [CSS getSlug], self.mID]; DLog(@"%@",urlStringForIssue); [issueListRequest setURL:[NSURL URLWithString:urlStringForIssue]]; [issueListRequest setHTTPMethod:@"GET"]; [issueListRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [issueListRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"]; NSHTTPURLResponse *responseHTTPForIssueList; NSError *error; NSData *rawIssueList = [NSURLConnection sendSynchronousRequest:issueListRequest returningResponse:&responseHTTPForIssueList error:&error]; [issueListRequest release]; if ([responseHTTPForIssueList statusCode] == 200) { NSMutableArray *issueList = [NSJSONSerialization JSONObjectWithData:rawIssueList options:NSJSONReadingMutableContainers error:&error]; return issueList; }else{ return NULL; } |
//delete it form the server CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton]; //create issue request: NSMutableURLRequest *deleteRequest = [[NSMutableURLRequest alloc] init]; NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/issues/%@", [CSS getDefaultAPIURL], [CSS getSlug], issueid]; [deleteRequest setURL:[NSURL URLWithString:urlStringForIssue]]; [deleteRequest setHTTPMethod:@"DELETE"]; [deleteRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [deleteRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"]; NSHTTPURLResponse *responseHTTPForDeletion; [NSURLConnection sendSynchronousRequest:deleteRequest returningResponse:&responseHTTPForDeletion error:&error]; [deleteRequest release]; if ([responseHTTPForDeletion statusCode] == 200) { //successful deletion return 0; } else { //add it to a deletion list [self addIssueToUnDeletedIssueList:issueid]; return 1; } |
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton]; NSMutableDictionary *pinData = [self getPinDataForPinId:PIN_ID inIssue:ISSUE_ID]; //remove the id and the objectsparent id since they are unrequired data for the server: NSString *oldObjectsParentID = [pinData objectForKey:@"objectsParentId"]; [pinData removeObjectForKey:@"objectsParentId"]; NSString *oldPinId = [pinData objectForKey:@"id"]; [pinData removeObjectForKey:@"id"]; //set the new issue id: [pinData setObject:newCurrentIssueId forKey:@"issueId"]; //create nsdata for uploading: NSData *dataForCurrentPin = [NSJSONSerialization dataWithJSONObject:pinData options:NSJSONWritingPrettyPrinted error:&error]; //create pin request: NSMutableURLRequest *uploadRequestForCurrentPin; uploadRequestForCurrentPin = [[NSMutableURLRequest alloc] init]; NSString *urlStringForPin = [NSString stringWithFormat:@"%@%@/issues/%@/pins", [CSS getDefaultAPIURL], [CSS getSlug], self.newCurrentIssueID]; [uploadRequestForCurrentPin setURL:[NSURL URLWithString:urlStringForPin]]; [uploadRequestForCurrentPin setHTTPMethod:@"POST"]; [uploadRequestForCurrentPin setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [uploadRequestForCurrentPin setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"]; [uploadRequestForCurrentPin setHTTPBody:dataForCurrentPin]; NSHTTPURLResponse *responseHTTPForCurrentPin; NSData *responseForCurrentPin = [NSURLConnection sendSynchronousRequest:uploadRequestForCurrentPin returningResponse:&responseHTTPForCurrentPin error:&error]; [uploadRequestForCurrentPin release]; if ([responseHTTPForCurrentPin statusCode] == 201) { // success } else { // Upload Failed } |
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton]; //create issue request: NSMutableURLRequest *pinListRequest; pinListRequest = [[NSMutableURLRequest alloc] init]; NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/issues/%@/pins", [CSS getDefaultAPIURL], [CSS getSlug], issueid]; DLog(@"%@",urlStringForIssue); [pinListRequest setURL:[NSURL URLWithString:urlStringForIssue]]; [pinListRequest setHTTPMethod:@"GET"]; [pinListRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [pinListRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"]; NSHTTPURLResponse *responseHTTPForPinList; NSError *error; NSData *rawPinList = [NSURLConnection sendSynchronousRequest:pinListRequest returningResponse:&responseHTTPForPinList error:&error]; [pinListRequest release]; if ([responseHTTPForPinList statusCode] == 200) { NSMutableArray *pinList = [NSJSONSerialization JSONObjectWithData:rawPinList options:NSJSONReadingMutableContainers error:&error]; return pinList; }else{ return NULL; } |
NSString *attachmentURL = [[CSS getDefaultAPIURL] stringByAppendingFormat:@"%@/issues/%@/attachments", [CSS getSlug],currentIssueId]; MultIPartFormCommunication *MPC = [MultIPartFormCommunication sharedSingleton]; NSString *imageName = [NSString stringWithFormat:@"issueImage%f",[[NSDate date] timeIntervalSince1970]]; if ([MPC uploadImage:issueImage withExtension:@"jpeg" withFileName:imageName ToURLString:attachmentURL]){ //succesful uploading }else{ //unsuccesful uploading store the issue image in a list: } |
See the bottom of the page to see the uploadImage method
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton]; NSMutableURLRequest *attachmentsRequest; attachmentsRequest = [[NSMutableURLRequest alloc] init]; NSString *urlStringForIssue = [NSString stringWithFormat:@"%@%@/issues/%@/attachments", [CSS getDefaultAPIURL], [CSS getSlug], issueid]; DLog(@"%@",urlStringForIssue); [attachmentsRequest setURL:[NSURL URLWithString:urlStringForIssue]]; [attachmentsRequest setHTTPMethod:@"GET"]; [attachmentsRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [attachmentsRequest setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"]; NSHTTPURLResponse *responseHTTPForAttachments; NSError *error; NSData *rawAttachmentsList = [NSURLConnection sendSynchronousRequest:attachmentsRequest returningResponse:&responseHTTPForAttachments error:&error]; [attachmentsRequest release]; if ([responseHTTPForAttachments statusCode] == 200) { NSMutableArray *attachmentsList = [NSJSONSerialization JSONObjectWithData:rawAttachmentsList options:NSJSONReadingMutableContainers error:&error]; if ([attachmentsList count] > 0) { return attachmentsList; }else{ return NULL; } }else{ return NULL; } |
- (BOOL)uploadImage:(UIImage*)image withExtension:(NSString*)ext withFileName:(NSString*)fileName ToURLString:(NSString*)urlString{ CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton]; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; // Method [request setHTTPMethod:@"POST"]; // Set headers NSString *boundary = @"AaB03x"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; [request setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"]; [request addValue:contentType forHTTPHeaderField:@"Content-Type"]; // FORM NSData *dataForTestImage = UIImageJPEGRepresentation(image, 1.0); NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"file\"; filename=\"%@.%@\"\r\n", fileName,ext] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:dataForTestImage]; // fileName [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"fileName\"\r\n\r\n%@.%@", fileName,ext] dataUsingEncoding:NSUTF8StringEncoding]]; // type [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"type\"\r\n\r\nimage/%@", ext] dataUsingEncoding:NSUTF8StringEncoding]]; // size [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"size\"\r\n\r\n%d", [dataForTestImage length]] dataUsingEncoding:NSUTF8StringEncoding]]; // objectIds [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"objectIds\"\r\n\r\n%@", @""] dataUsingEncoding:NSUTF8StringEncoding]]; // End [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:body]; NSHTTPURLResponse* response; NSError* err; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err]; if ([response statusCode] == 201) { return true; }else{ return false; } } |