Exemplo n.º 1
0
        public virtual async Task <ApiResult> PostSendEmailLoginAsync(TwoFactorEmailRequest requestObj)
        {
            if (!Connectivity.IsConnected)
            {
                return(HandledNotConnected());
            }

            using (var client = HttpService.ApiClient)
            {
                var requestMessage = new TokenHttpRequestMessage(requestObj)
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/send-email-login")),
                };

                try
                {
                    var response = await client.SendAsync(requestMessage).ConfigureAwait(false);

                    if (!response.IsSuccessStatusCode)
                    {
                        return(await HandleErrorAsync(response).ConfigureAwait(false));
                    }

                    return(ApiResult.Success(response.StatusCode));
                }
                catch
                {
                    return(HandledWebException());
                }
            }
        }
Exemplo n.º 2
0
        public virtual async Task <ApiResult> PostTwoFactorSendEmailLoginAsync(TwoFactorEmailRequest requestObj)
        {
            var stringContent = JsonConvert.SerializeObject(requestObj);

            var requestMessage = new HttpRequestMessage()
            {
                Method     = HttpMethod.Post,
                RequestUri = new Uri(string.Concat(SettingsService.Instance.ApiBaseUrl, "/two-factor/send-email-login")),
                Content    = new StringContent(stringContent, Encoding.UTF8, "application/json")
            };

            try
            {
                var response = await Client.SendAsync(requestMessage).ConfigureAwait(false);

                if (!response.IsSuccessStatusCode)
                {
                    return(await HandleErrorAsync(response).ConfigureAwait(false));
                }

                return(ApiResult.Success(response.StatusCode));
            }
            catch
            {
                return(HandledWebException());
            }
        }
Exemplo n.º 3
0
 public Task PostTwoFactorEmailAsync(TwoFactorEmailRequest request)
 {
     return(SendAsync <TwoFactorEmailRequest, object>(
                HttpMethod.Post, "/two-factor/send-email-login", request, false, false));
 }