public ShareLinkItem createBookmark(Uri link, String title, String description, List <String> spaceKeys, Bitmap icon) { try { LinkApi linkApi = new LinkApi(session.GetApiClient()); LinkV2Record linkRecord = new LinkV2Record(); linkRecord.Link = link.ToString(); linkRecord.Title = title; linkRecord.Text = description; linkRecord.Type = "document"; linkRecord.Subtype = "link"; CreateLinkInput createLinkInput = new CreateLinkInput(linkRecord); CreateLinkResult createLinkResult = linkApi.CreateLink(createLinkInput); if (createLinkResult.Hdr.Rc == 0) { LinkV2Record createdLink = createLinkResult.Link; if (spaceKeys != null) { SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); ShareObjectInput shareInput = new ShareObjectInput(null, spaceKeys, null); ShareObjectResult shareResult = spaceApi.ShareObject(createdLink.Key, shareInput); if (shareResult.Hdr.Rc == 0) { GetLinkResult getLinkResult = linkApi.GetLink(createdLink.Key); if (getLinkResult.Hdr.Rc == 0) { createdLink = getLinkResult.Link; } else { throw new Exception("Vmoso error getting created link. Rc=" + getLinkResult.Hdr.Rc); } } else { throw new Exception("Vmoso error sharing link. Rc=" + shareResult.Hdr.Rc); } } ShareLinkItem item = new ShareLinkItem(createdLink.Title, createdLink.Text); item.Key = createdLink.Key; item.Link = new Uri(createdLink.Link); item.Record = createdLink; item.SetIcon(icon); List <ShareSpace> itemSpaces = new List <ShareSpace>(); foreach (DisplayRecord spaceDisplayRecord in createdLink.Destinations) { ShareSpace space = new ShareSpace(spaceDisplayRecord.Key, spaceDisplayRecord.DisplayName, null); itemSpaces.Add(space); } item.Spaces = itemSpaces; return(item); } else { throw new Exception("Vmoso error creating link. Rc=" + createLinkResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Vmoso error creating link", ex); } }
/// <summary> /// Create a link object. /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="input">CreateLink Input</param> /// <returns>Task of CreateLinkResult</returns> public async System.Threading.Tasks.Task <CreateLinkResult> CreateLinkAsync(CreateLinkInput input) { ApiResponse <CreateLinkResult> localVarResponse = await CreateLinkAsyncWithHttpInfo(input); return(localVarResponse.Data); }
/// <summary> /// Create a link object. /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="input">CreateLink Input</param> /// <returns>Task of ApiResponse (CreateLinkResult)</returns> public async System.Threading.Tasks.Task <ApiResponse <CreateLinkResult> > CreateLinkAsyncWithHttpInfo(CreateLinkInput input) { // verify the required parameter 'input' is set if (input == null) { throw new ApiException(400, "Missing required parameter 'input' when calling LinkApi->CreateLink"); } var localVarPath = "/links"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (input != null && input.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(input); // http body (model) parameter } else { localVarPostBody = input; // byte array } // authentication (vmoso_auth) required if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("X-CV-Authorization"))) { localVarHeaderParams["X-CV-Authorization"] = Configuration.GetApiKeyWithPrefix("X-CV-Authorization"); } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateLink", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <CreateLinkResult>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (CreateLinkResult)Configuration.ApiClient.Deserialize(localVarResponse, typeof(CreateLinkResult)))); }
/// <summary> /// Create a link object. /// </summary> /// <exception cref="VmosoApiClient.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="input">CreateLink Input</param> /// <returns>CreateLinkResult</returns> public CreateLinkResult CreateLink(CreateLinkInput input) { ApiResponse <CreateLinkResult> localVarResponse = CreateLinkWithHttpInfo(input); return(localVarResponse.Data); }