public static RestRequest BuildUserBinaryPostRequest(this ServiceClientBase target, string action, object data, byte[] binary, string tokenId, string encryptionToken) { var request = new RestRequest(target.CalculateUrlForMethod(action), Method.POST, DataFormat.Json); target.ApplyHeaders(request); request.AddJsonBody(target.CreateUserBinaryRequest(data, binary, tokenId, encryptionToken)); return(request); }
public static RestRequest BuildEmptyUserPostRequest(this ServiceClientBase target, string action, string tokenId, string encryptionToken) { var request = new RestRequest(target.CalculateUrlForMethod(action), Method.POST, DataFormat.Json); target.ApplyHeaders(request); request.AddJsonBody(target.CreateEmptyUserRequest(tokenId, encryptionToken)); return(request); }
public static async Task ExecuteSecureBinaryCallAsync(this ServiceClientBase target, string methodName, object data, byte[] binary, string tokenId, string encryptionToken) { var request = target.BuildUserBinaryPostRequest(methodName, data, binary, tokenId, encryptionToken); target.ApplyHeaders(request); var result = await target.ExecuteRequestAsync <SecureResponse>(request); if (result.Success == false) { throw new Exception(result.Message); } }
public static async Task <(string FileName, string MimeType, byte[] Binary)> ExecuteSecureDownloadServiceCallAsync(this ServiceClientBase target, string methodName, object data, string tokenId, string encryptionToken) { var request = target.BuildUserPostRequest(methodName, data, tokenId, encryptionToken); target.ApplyHeaders(request); var result = await target.ExecuteRequestAsync <SecureBinaryResponse>(request); if (result.Success == false) { throw new Exception(result.Message); } return(result.FileName, result.MimeType, result.Data); }
public static RestRequest BuildSecurePostRequest(this ServiceClientBase target, string action, object data, string tokenId, string encryptionToken) { var request = new RestRequest(target.CalculateUrlForMethod(action), Method.POST, DataFormat.Json); target.ApplyHeaders(request); var fReq = new SecureRequest() { ClientVersionNo = target.WebClient.ClientVersionNo, Id = tokenId, Payload = new SecurePayload(data, encryptionToken), }; request.AddJsonBody(fReq); return(request); }
public static async Task <T> ExecuteSecureCallAsync <T>(this ServiceClientBase target, string methodName, object data, string tokenId, string encryptionToken) { var request = target.BuildUserPostRequest(methodName, data, tokenId, encryptionToken); target.ApplyHeaders(request); var result = await target.ExecuteRequestAsync <SecureResponse>(request); if (result.Success == false) { throw new Exception(result.Message); } var payload = result.Payload.Extract <T>(encryptionToken); return(payload); }