/// <summary> /// Updates task link. Updates task link. /// </summary> /// <param name="name"></param> /// <param name="index"></param> /// <param name="storage"></param> /// <param name="folder"></param> /// <param name="fileName"></param> /// <param name="body"></param> /// <returns></returns> public TaskLinkResponse PutTaskLink (string name, int? index, string storage, string folder, string fileName, TaskLink body) { // create path and map variables var ResourcePath = "/tasks/{name}/taskLinks/{index}/?appSid={appSid}&storage={storage}&folder={folder}&fileName={fileName}".Replace("{format}","json"); ResourcePath = Regex.Replace(ResourcePath, "\\*", "").Replace("&", "&").Replace("/?", "?").Replace("toFormat={toFormat}", "format={format}"); // query params var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, object>(); // verify required params are set if (name == null || index == null || body == null ) { throw new ApiException(400, "missing required params"); } if (name == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])name=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "name" + "}", apiInvoker.ToPathValue(name)); } if (index == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])index=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "index" + "}", apiInvoker.ToPathValue(index)); } if (storage == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])storage=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "storage" + "}", apiInvoker.ToPathValue(storage)); } if (folder == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])folder=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "folder" + "}", apiInvoker.ToPathValue(folder)); } if (fileName == null){ ResourcePath = Regex.Replace(ResourcePath, @"([&?])fileName=", ""); }else{ ResourcePath = ResourcePath.Replace("{" + "fileName" + "}", apiInvoker.ToPathValue(fileName)); } try { if (typeof(TaskLinkResponse) == typeof(ResponseMessage)) { var response = apiInvoker.invokeBinaryAPI(basePath, ResourcePath, "PUT", queryParams, null, headerParams, formParams); return (TaskLinkResponse) ApiInvoker.deserialize(response, typeof(TaskLinkResponse)); } else { var response = apiInvoker.invokeAPI(basePath, ResourcePath, "PUT", queryParams, body, headerParams, formParams); if(response != null){ return (TaskLinkResponse) ApiInvoker.deserialize(response, typeof(TaskLinkResponse)); } else { return null; } } } catch (ApiException ex) { if(ex.ErrorCode == 404) { return null; } else { throw ex; } } }
public void TestPostTaskLink() { TasksApi target = new TasksApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); string name = "sample-project-2.mpp"; string storage = null; string folder = null; string fileName = null; TaskLink body = new TaskLink(); body.Index = 2; body.PredecessorUid = 1; body.SuccessorUid = 2; storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\tasks\\resources\\" + name)); SaaSposeResponse actual; actual = target.PostTaskLink(name, storage, folder, fileName, body); Assert.AreEqual("200", actual.Code); Assert.IsInstanceOfType(new SaaSposeResponse(), actual.GetType()); }