public void CreateAccount(Account account, string sessionToken) { var httpRequest = new JSONRestRequest("api/v3/accounts/", Method.POST); httpRequest.AddBody(account); httpRequest.AddHeader("sessiontoken", sessionToken); Execute(httpRequest, HttpStatusCode.Created); }
public void DeleteAccount(Guid accountID, String sessionToken) { try { var httpRequest = new JSONRestRequest(string.Format("api/v3/accounts/{0}", accountID), Method.DELETE); httpRequest.AddHeader("sessiontoken", sessionToken); Execute(httpRequest, HttpStatusCode.OK); } catch (Exception ex) { throw ex; } }
public void RemoveDocumentPermission(Guid documentID, Guid permissionID, string sessionToken) { var url = string.Format("api/v3/documents/{0}/permissions/{1}", documentID, permissionID); var httpRequest = new JSONRestRequest(url, Method.DELETE); httpRequest.AddHeader("token", sessionToken); var createResponse = _client.Execute(httpRequest); if (createResponse.StatusCode != HttpStatusCode.NoContent) { throw new Exception("Server returned:" + createResponse.StatusCode); } }
public DocumentInfo GetDocumentInfo(Guid documentID, string sessionToken) { var url = string.Format("api/v3/documents/{0}/info", documentID); var httpRequest = new JSONRestRequest(url); httpRequest.AddHeader("token", sessionToken); var documentInfoResponse = _client.Execute <DocumentInfo>(httpRequest); if (documentInfoResponse.StatusCode != HttpStatusCode.OK) { throw new Exception("Server returned:" + documentInfoResponse.StatusCode); } return(documentInfoResponse.Data); }
/// <summary> /// Set document permission for tenant or for account. (if account no need to fill tenant id) /// </summary> /// <param name="documentID"></param> /// <param name="permission"></param> /// <param name="sessionToken"></param> public void CreateDocumentPermission(Guid documentID, DocumentPermission permission, string sessionToken) { var url = string.Format("api/v3/documents/{0}/permissions", documentID); var httpRequest = new JSONRestRequest(url, Method.POST); httpRequest.AddHeader("token", sessionToken); httpRequest.AddBody(permission); var createResponse = _client.Execute(httpRequest); if (createResponse.StatusCode != HttpStatusCode.Created) { throw new Exception("Server returned:" + createResponse.StatusCode); } }
public void UpdateAccount(Account account, string sessionToken) { try { String relativePath = String.Format("api/v3/accounts/{0}", account.ID); var httpRequest = new JSONRestRequest(relativePath, Method.PUT); httpRequest.AddBody(account); httpRequest.AddHeader("sessiontoken", sessionToken); Execute(httpRequest, HttpStatusCode.OK); } catch (Exception ex) { throw; } }
public ShareDocumentResponse ShareDocument(Guid documentID, DTO.Request.ShareDocumentRequest request, string sessionToken) { var url = string.Format("api/v3/documents/{0}/share", documentID); var httpRequest = new JSONRestRequest(url, Method.POST); httpRequest.AddHeader("token", sessionToken); httpRequest.AddBody(request); var shareResponse = _client.Execute(httpRequest); if (shareResponse.StatusCode != HttpStatusCode.OK) { throw new Exception("Server returned:" + shareResponse.StatusCode); } var locationObject = shareResponse.Headers.FirstOrDefault(x => x.Name == "Location"); String sharedDocumentLocation = (locationObject != null) ? (string)locationObject.Value : null; return(new ShareDocumentResponse { sharedDocumentURL = sharedDocumentLocation }); }