public void RegisterListener(MessageListener listener) { var request = new JSONRestRequest("listeners", Method.POST); request.AddBody(listener); var response = Execute(request, HttpStatusCode.Created); }
public void SendMessage(Message message) { var request = new JSONRestRequest("receiver", Method.POST); request.AddBody(message); var response = Execute(request, HttpStatusCode.OK); }
public void CreateTenantAndAccount(RegistrationRequest request) { //Verify request data! var httpRequest = new JSONRestRequest("api/v3/tenants/registration", Method.POST); httpRequest.AddBody(request); Execute(httpRequest, HttpStatusCode.Created); }
public void CreateDeviceAccount(Account account) { account.AccountType = EAccountType.Device; var httpRequest = new JSONRestRequest("api/v3/device-accounts/", Method.POST); httpRequest.AddBody(account); Execute(httpRequest, HttpStatusCode.Created); }
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 SaveTrustRelationRequestInvitation(TrustRelationRequestInvitation trustRelationInvitation, Guid tenantID) { var url = string.Format("trust-relation-request-invitations/{0}", tenantID); var httpRequest = new JSONRestRequest(url, Method.POST); httpRequest.AddBody(trustRelationInvitation); Execute(httpRequest, HttpStatusCode.Created); }
public void SaveTrustRelationTypeGroup(TrustRelationTypeGroup trustRelationTypeGroup) { var url = string.Format("trust-relation-groups/"); var httpRequest = new JSONRestRequest(url, Method.POST); httpRequest.AddBody(trustRelationTypeGroup as TrustRelationTypeGroup); Execute(httpRequest, HttpStatusCode.Created); }
public void SaveTrustRelationType(TrustRelationType trustRelationType) { var url = string.Format("trust-relation-types/{0}", trustRelationType.ID); var httpRequst = new JSONRestRequest(url, Method.PUT); httpRequst.AddBody(trustRelationType); Execute(httpRequst, HttpStatusCode.NoContent); }
public List <TenantBasicInfo> GetTenantsForUsernamePassword(SignInRequest request) { var httpRequest = new JSONRestRequest("api/v3/tenants/search-username", Method.POST); httpRequest.AddBody(request); var response = Execute <List <TenantBasicInfo> >(httpRequest, HttpStatusCode.OK); return(response.Data); }
public List <TenantBasicInfo> GetMultipleTenantsForCredentials(SignInRequest request) { var httpRequest = new JSONRestRequest("api/v3/tenants/search/", Method.POST); httpRequest.AddBody(request); var response = Execute <List <TenantBasicInfo> >(httpRequest, HttpStatusCode.OK); return(response.Data); }
public void RejectIncomingTrustRelationRequest(Guid tenantID, Guid incomingTrustRelationRequestID, string rejectionReason) { var url = string.Format("{0}/trust-relations/incoming-requests/{1}", tenantID, incomingTrustRelationRequestID); var httpRequest = new JSONRestRequest(url, Method.DELETE); Dictionary <string, string> message = new Dictionary <string, string> { { "message", rejectionReason } }; httpRequest.AddBody(message); var response = Execute(httpRequest, HttpStatusCode.NoContent); }
public string GenerateTemporarySession(TemporaryTokenRequest request) { var httpRequest = new JSONRestRequest("/api/v3/sessions/create-temporary-token", Method.POST); httpRequest.AddBody(request); var response = Execute(httpRequest, HttpStatusCode.Created); var location = response.Headers.FirstOrDefault(x => x.Name == "Location").Value as string; var sessionToken = location.Split('/').Last(); return(sessionToken); }
public void TerminateTrustRelation(Guid tenantID, Guid trustRelationID, string terminationReason = null) { var url = string.Format("{0}/trust-relations/{1}", tenantID, trustRelationID); var httpRequest = new JSONRestRequest(url, Method.DELETE); Dictionary <string, string> message = new Dictionary <string, string> { { "terminationReason", terminationReason } }; httpRequest.AddBody(message); Execute(httpRequest, HttpStatusCode.NoContent); }
public byte[] GeneratePrintJobPreview(PrintPreviewRequest job, string sessionToken) { var request = new JSONRestRequest("api/v3/printjobs/preview", Method.POST); job.SessionToken = sessionToken; request.AddBody(job); var response = this.Download(request); return(response); }
public ChangePasswordResponse ChangePassword(ChangePasswordRequest request) { request.NewPassword = HashingUtil.CalculateMD5Hash(request.NewPassword); request.OldPassword = HashingUtil.CalculateMD5Hash(request.OldPassword); var httpRequest = new JSONRestRequest("api/v3/accounts/change-password", Method.POST); httpRequest.AddBody(request); var response = Execute <ChangePasswordResponse>(httpRequest, HttpStatusCode.OK); return(response.Data); }
public void BanAccount(Guid accountID, string banReason) { var url = string.Format("api/v3/accounts/{0}/ban", accountID.ToString()); var reason = new ReasonWrapper() { Reason = banReason }; var httpRequest = new JSONRestRequest(url, Method.POST); httpRequest.AddBody(reason); Execute(httpRequest, HttpStatusCode.OK); }
public Session SwitchTenant(SwitchTenantRequest request, string token) { var httpRequest = new JSONRestRequest("/api/v3/sessions/{token}/switch", Method.POST); httpRequest.AddUrlSegment("token", token); httpRequest.AddBody(request); var response = Execute(httpRequest, HttpStatusCode.NoContent); var location = response.Headers.FirstOrDefault(x => x.Name == "Location").Value as string; var sessionToken = location.Split('/').Last(); return(GetSessionInformation(sessionToken)); }
public Session SignIn(SignInRequest request) { var httpRequest = new JSONRestRequest("api/v3/sessions/", Method.POST); httpRequest.AddBody(request); var signInResponse = Execute(httpRequest, HttpStatusCode.Created); var location = (string)signInResponse.Headers.FirstOrDefault(x => x.Name == "Location").Value; var sessionToken = location.Split('/').Last(); return(GetSessionInformation(sessionToken)); }
public ResponseMessage SubmitPrintJob(PrintJobRequest job, string sessionToken) { job.SessionToken = sessionToken; job.Template = HttpUtility.HtmlEncode(job.Template); job.Data = HttpUtility.HtmlEncode(job.Data); var url = "api/v3/printjobs/"; var request = new JSONRestRequest(url, Method.POST); request.AddBody(job); var response = Execute <ResponseMessage>(request, System.Net.HttpStatusCode.Created); return(response.Data); }
public void SetDefaultAccount(DefaultTenantRequest request) { try { var httpRequest = new JSONRestRequest("api/v3/accounts/set-default-tenant", Method.POST); httpRequest.AddBody(request); Execute(httpRequest, HttpStatusCode.OK); } catch (Exception ex) { throw ex; } }
/// <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 ResetPassword(ResetPasswordRequest request) { if (request.NewPassword.Length >= 4) { request.NewPassword = HashingUtil.CalculateMD5Hash(request.NewPassword); var httpRequest = new JSONRestRequest("api/v3/accounts/reset-password", Method.POST); httpRequest.AddBody(request); Execute(httpRequest, HttpStatusCode.OK); } else { throw new SDKServiceException("Password must be at least 4 characters long!", new ServiceErrror()); } }
public void AcceptIncomingTrustRelationRequest(Guid tenantID, Guid incomingTrustRelationRequestID, string responseMessage) { var url = string.Format("{0}/trust-relations/incoming-requests", tenantID); var httpRequest = new JSONRestRequest(url, Method.POST); Dictionary <string, object> responseObject = new Dictionary <string, object>() { { "accepted", true }, { "externalId", incomingTrustRelationRequestID }, { "responseMessage", responseMessage } }; httpRequest.AddBody(responseObject); Execute(httpRequest, HttpStatusCode.NoContent); }
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 bool CheckIfCredentialsAreValid(SignInRequest request) { var httpRequest = new JSONRestRequest("/api/v3/sessions/sing-in-check", Method.POST); httpRequest.AddBody(request); try { var response = Execute(httpRequest, HttpStatusCode.OK); return(response.Content == "true"); } catch { return(false); } }
public TrustRelationRequest SendTrustRelationRequest(TrustRelationRequest trustRelationRequest, bool autoApprove = false) { trustRelationRequest.IsAutoApproved = autoApprove; if (trustRelationRequest.InitiatedFromTenant == null) { trustRelationRequest.InitiatedFromTenant = trustRelationRequest.FromTenant; } var url = string.Format("{0}/trust-relations/outgoing-requests/", trustRelationRequest.InitiatedFromTenant); var httpRequest = new JSONRestRequest(url, Method.POST); httpRequest.AddBody(trustRelationRequest); var creationResponse = Execute <Dictionary <String, String> >(httpRequest, HttpStatusCode.Created); Guid requestCode = Guid.Parse(creationResponse.Data["code"]); var createdRequest = GetInitiatedTrustRelationRequest(trustRelationRequest.InitiatedFromTenant.GetValueOrDefault(), requestCode); return(createdRequest); }
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 }); }