Exemple #1
0
        /// <summary>
        /// Resolve verification to create an account on the backend
        /// and authenticate via tokens.
        /// </summary>
        /// <param name="verificationCode">Verification code from the server send via SMS.</param>
        /// <param name="phoneNumber">Country code and phonenumber concatenated</param>
        /// <param name="password">Password which should be a GIUD uppercase</param>
        /// <returns></returns>
        public async Task <bool> ResolveVerificationCodeAsync(string verificationCode, string phoneNumber, string password)
        {
            if (string.IsNullOrWhiteSpace(verificationCode) ||
                string.IsNullOrWhiteSpace(phoneNumber) ||
                string.IsNullOrWhiteSpace(password))
            {
                throw new ArgumentNullException("You must provide all parameters");
            }

            using (var client = new HttpClient(new NativeMessageHandler()))
            {
                client.Timeout = _timeOut;

                var dto = new VerificationResolveDto
                {
                    VerificationCode = verificationCode,
                    PhoneNumber      = phoneNumber,
                    Password         = password
                };

                var encodedContent = new FormUrlEncodedContent(dto.ToDictionary());

                try
                {
                    var response = await client.PostAsync(_resolveAddress, encodedContent);

                    return(response.IsSuccessStatusCode);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }