Exemplo n.º 1
0
        public async Task <AmlResult> PerformCheck(IHttpRequester httpRequester, IAmlProfile amlProfile, Dictionary <string, string> headers, string apiUrl, string endpoint, byte[] httpContent)
        {
            if (amlProfile == null)
            {
                throw new ArgumentNullException("amlProfile");
            }

            try
            {
                HttpMethod httpMethod = HttpMethod.Post;

                Response response = await httpRequester.DoRequest(
                    new HttpClient(),
                    httpMethod,
                    new Uri(apiUrl + endpoint),
                    headers,
                    httpContent);

                if (!response.Success)
                {
                    CreateExceptionFromStatusCode(response);
                }

                var amlResult = Newtonsoft.Json.JsonConvert.DeserializeObject <AmlResult>(response.Content);

                return(amlResult);
            }
            catch (Exception ex)
            {
                if (ex is AmlException)
                {
                    throw;
                }

                throw new AmlException(
                          string.Format(
                              "Inner exception:{0}{1}",
                              Environment.NewLine,
                              ex.Message),
                          ex);
            }
        }
        /// <summary>
        /// Request a <see cref="ActivityDetails"/>  using the encrypted token provided by yoti during the login process.
        /// </summary>
        /// <param name="encryptedToken">The encrypted returned by Yoti after successfully authenticating.</param>
        /// <returns>The account details of the logged in user as a <see cref="ActivityDetails"/>. </returns>
        public AmlResult PerformAmlCheck(string appId, AsymmetricCipherKeyPair keyPair, string apiUrl, IAmlProfile amlProfile)
        {
            Task <AmlResult> task = Task.Run(async() => await PerformAmlCheckAsync(appId, keyPair, apiUrl, amlProfile));

            return(task.Result);
        }
        /// <summary>
        /// Asynchronously request a <see cref="ActivityDetails"/>  using the encrypted token provided by yoti during the login process.
        /// </summary>
        /// <param name="encryptedToken">The encrypted returned by Yoti after successfully authenticating.</param>
        /// <returns>The account details of the logged in user as a <see cref="ActivityDetails"/>. </returns>
        public async Task <AmlResult> PerformAmlCheckAsync(string appId, AsymmetricCipherKeyPair keyPair, string apiUrl, IAmlProfile amlProfile)
        {
            if (apiUrl == null)
            {
                throw new ArgumentNullException(nameof(apiUrl));
            }

            if (amlProfile == null)
            {
                throw new ArgumentNullException(nameof(amlProfile));
            }

            string serializedProfile = Newtonsoft.Json.JsonConvert.SerializeObject(amlProfile);

            byte[] httpContent = System.Text.Encoding.UTF8.GetBytes(serializedProfile);

            HttpMethod httpMethod = HttpMethod.Post;

            string endpoint = EndpointFactory.CreateAmlEndpoint(httpMethod, appId);

            Dictionary <string, string> headers = CreateHeaders(keyPair, httpMethod, endpoint, httpContent, contentType: YotiConstants.ContentTypeJson);

            AmlResult result = await Task.Run(async() => await new RemoteAmlService()
                                              .PerformCheck(_httpRequester, amlProfile, headers, apiUrl, endpoint, httpContent));

            return(result);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Asynchronously request a <see cref="AmlResult"/>  using an individual's name and address.
 /// </summary>
 /// <param name="amlProfile">An individual's name and address.</param>
 /// <returns>The result of the AML check in the form of a <see cref="AmlResult"/>. </returns>
 public async Task <AmlResult> PerformAmlCheckAsync(IAmlProfile amlProfile)
 {
     return(await _yotiClientEngine.PerformAmlCheckAsync(_sdkId, _keyPair, _defaultApiUrl, amlProfile));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Request an <see cref="AmlResult"/>  using an individual's name and address.
 /// </summary>
 /// <param name="amlProfile">An individual's name and address.</param>
 /// <returns>The result of the AML check in the form of a <see cref="AmlResult"/>. </returns>
 public AmlResult PerformAmlCheck(IAmlProfile amlProfile)
 {
     return(_yotiClientEngine.PerformAmlCheck(_sdkId, _keyPair, _defaultApiUrl, amlProfile));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Request an <see cref="AmlResult"/> using an individual's name and address.
        /// </summary>
        /// <param name="amlProfile">An individual's name and address.</param>
        /// <returns>The result of the AML check in the form of a <see cref="AmlResult"/>.</returns>
        public AmlResult PerformAmlCheck(IAmlProfile amlProfile)
        {
            Task <AmlResult> task = Task.Run(async() => await PerformAmlCheckAsync(amlProfile).ConfigureAwait(false));

            return(task.Result);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Asynchronously request a <see cref="AmlResult"/> using an individual's name and address.
 /// </summary>
 /// <param name="amlProfile">An individual's name and address.</param>
 /// <returns>The result of the AML check in the form of a <see cref="AmlResult"/>.</returns>
 public async Task <AmlResult> PerformAmlCheckAsync(IAmlProfile amlProfile)
 {
     return(await _yotiClientEngine.PerformAmlCheckAsync(_sdkId, _keyPair, ApiUri, amlProfile).ConfigureAwait(false));
 }
Exemplo n.º 8
0
        private async Task <AmlResult> PerformAmlCheckInternalAsync(string sdkId, AsymmetricCipherKeyPair keyPair, Uri apiUrl, IAmlProfile amlProfile)
        {
            string serializedProfile = Newtonsoft.Json.JsonConvert.SerializeObject(amlProfile);

            byte[] httpContent = System.Text.Encoding.UTF8.GetBytes(serializedProfile);

            AmlResult result = await Task.Run(async() => await new RemoteAmlService()
                                              .PerformCheck(
                                                  _httpClient, keyPair, apiUrl, sdkId, httpContent).ConfigureAwait(false))
                               .ConfigureAwait(false);

            return(result);
        }
Exemplo n.º 9
0
        public Task <AmlResult> PerformAmlCheckAsync(string sdkId, AsymmetricCipherKeyPair keyPair, Uri apiUrl, IAmlProfile amlProfile)
        {
            if (apiUrl == null)
            {
                throw new ArgumentNullException(nameof(apiUrl));
            }

            if (amlProfile == null)
            {
                throw new ArgumentNullException(nameof(amlProfile));
            }

            return(PerformAmlCheckInternalAsync(sdkId, keyPair, apiUrl, amlProfile));
        }