public override Task <GetEventResultResponse> GetEventResult(GetResultRequest request, ServerCallContext context) { var random = new Random(); var response = new GetEventResultResponse { AnalysisSid = request.AnalysisSid, }; for (int i = 0; i < request.AnalysisSid; i++) { response.Result.Add(new EventResult { PerilSetCode = 4, YearId = random.Next(request.AnalysisSid), ModelCode = random.Next(255), EventId = random.Next(), Gross = random.NextDouble(), GroundUp = random.NextDouble(), Retained = random.NextDouble(), PreCatNet = random.NextDouble() }); } return(Task.FromResult(response)); }
public static void Main(string[] args) { var apiKey = "Pj+GIg2/l7ZKmicZi37+1giqKJ1WH3Vt8vSSxCuvPkKD"; var email = "*****@*****.**"; AsyncAuthInterceptor authInterceptor = new AsyncAuthInterceptor((context, metadata) => { metadata.Add("Authorization", "Bearer " + apiKey); return(Task.FromResult(0)); }); var channelCredentials = ChannelCredentials.Create(new SslCredentials(), CallCredentials.FromInterceptor(authInterceptor)); Channel channel = new Channel("api.staging.autheid.com", channelCredentials); var client = new Requests.RequestsClient(channel); var request = new CreateRequest(); request.Email = email; request.Title = "test"; request.Type = RequestType.Kyc; request.Kyc = new CreateRequest.Types.KYC(); request.Kyc.FilesFormat = FileFormat.Embedded; var reply = client.Create(request); Console.WriteLine("Request ID: " + reply.RequestId); var resultRequest = new GetResultRequest(); resultRequest.RequestId = reply.RequestId; var resultReply = client.GetResult(resultRequest); Console.WriteLine("Status: " + resultReply.Status); if (resultReply.Status == RequestStatus.Success) { Console.WriteLine("Fist Name: " + resultReply.Kyc.Identification.FirstName); Console.WriteLine("Last Name: " + resultReply.Kyc.Identification.LastName); Console.WriteLine("File size: " + resultReply.Kyc.KycPdf.Embedded.Length); // Create a new file using (FileStream fs = System.IO.File.Create("kyc.pdf")) { fs.Write(resultReply.Kyc.KycPdf.Embedded.ToByteArray(), 0, resultReply.Kyc.KycPdf.Embedded.Length); } } channel.ShutdownAsync().Wait(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public void SerializeGetResultRequest_ValidRequestGiven_ShouldPass() { const string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <wps:GetResult xmlns:ows=""http://www.opengis.net/ows/2.0"" xmlns:xli=""http://www.w3.org/1999/xlink"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" service=""WPS"" version=""2.0.0"" xmlns:wps=""http://www.opengis.net/wps/2.0""> <wps:JobID>testJobId</wps:JobID> </wps:GetResult>"; // Remove white spaces and new line characters for XML comparison. var trimmedExpectedXml = Regex.Replace(expectedXml, @"\s+", string.Empty); var request = new GetResultRequest() { JobId = "testJobId" }; var resultXml = _serializer.Serialize(request); var trimmedResult = Regex.Replace(resultXml, @"\s+", string.Empty); trimmedResult.Should().Be(trimmedExpectedXml); }
public async Task <Result <TData> > GetResult <TData>(string wpsUri, string jobId) { if (wpsUri == null) { throw new ArgumentNullException(nameof(wpsUri)); } if (jobId == null) { throw new ArgumentNullException(nameof(jobId)); } var request = new GetResultRequest { JobId = jobId }; var content = await GetRequestResult(wpsUri, request); var result = _serializationService.Deserialize <Result <TData> >(content); return(result); }