コード例 #1
0
 /// <summary>
 /// Creates a Doc Scan session using the supplied session specification
 /// </summary>
 /// <param name="sessionSpec">the Doc Scan session specification</param>
 /// <returns>the session creation result</returns>
 public CreateSessionResult CreateSession(SessionSpecification sessionSpec)
 {
     return(CreateSessionAsync(sessionSpec).Result);
 }
コード例 #2
0
        public async Task <CreateSessionResult> CreateSession(string sdkId, AsymmetricCipherKeyPair keyPair, SessionSpecification sessionSpec)
        {
            Validation.NotNullOrEmpty(sdkId, nameof(sdkId));
            Validation.NotNull(keyPair, nameof(keyPair));
            Validation.NotNull(sessionSpec, nameof(sessionSpec));

            string serializedSessionSpec = JsonConvert.SerializeObject(sessionSpec, YotiDefaultJsonSettings);

            byte[] body = Encoding.UTF8.GetBytes(serializedSessionSpec);

            Request createSessionRequest = GetSignedRequestBuilder()
                                           .WithKeyPair(keyPair)
                                           .WithHttpMethod(HttpMethod.Post)
                                           .WithBaseUri(ApiUri)
                                           .WithEndpoint("/sessions")
                                           .WithQueryParam("sdkId", sdkId)
                                           .WithContent(body)
                                           .WithContentHeader(Api.ContentTypeHeader, Api.ContentTypeJson)
                                           .Build();

            using (HttpResponseMessage response = await createSessionRequest.Execute(_httpClient).ConfigureAwait(false))
            {
                if (!response.IsSuccessStatusCode)
                {
                    Response.CreateYotiExceptionFromStatusCode <DocScanException>(response);
                }

                return(JsonConvert.DeserializeObject <CreateSessionResult>(
                           response.Content.ReadAsStringAsync().Result));
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates a Doc Scan session using the supplied session specification
        /// </summary>
        /// <param name="sessionSpec">the Doc Scan session specification</param>
        /// <returns>the session creation result</returns>
        public async Task <CreateSessionResult> CreateSessionAsync(SessionSpecification sessionSpec)
        {
            _logger.Debug("Creating a Yoti Doc Scan session...");

            return(await _docScanService.CreateSession(_sdkId, _keyPair, sessionSpec).ConfigureAwait(false));
        }