Ejemplo n.º 1
0
        public async Task <ApiResponse <User> > GetAsync(string email)
        {
            var uri      = new Uri($"{_userApiSettings.ApiBaseAddress}/GetUserDetails?code={_userApiSettings.ApiKey}&email={email}").ToString();
            var response = await _baseHttpClient.GetAsync <User>(uri);

            return(response);
        }
        public async Task <IEnumerable <WeatherForecast> > GetWeatherForecasts()
        {
            string uri = new Uri($"https://localhost:44391/WeatherForecast").ToString();

            ApiResponse <IEnumerable <WeatherForecast> > response = await _baseHttpClient.GetAsync <IEnumerable <WeatherForecast> >(uri, null);

            return(response.Data);
        }
Ejemplo n.º 3
0
        public async Task <bool> AuthenticateAsync(string email, string userId)
        {
            var uri      = new Uri($"{_apiSettings.ApiBaseAddress}/GetUserDetails?code={_apiSettings.ApiKey}&email={email}").ToString();
            var response = await _baseHttpClient.GetAsync <User>(uri);

            if (response.WasSuccessful && response.Data.CustomerId == userId && response.Data.Email == email)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public async Task <HttpResponseMessage> RetrieveUserAccountsAsync(int accountNumber)
        {
            var response = await _baseHttpClient.GetAsync("http://fairwaybank-bizfitech.azurewebsites.net/api/v1/accounts/" + accountNumber);

            string json = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                var userAccounts = JsonConvert.DeserializeObject <AccountViewModel>(json);
                return(Request.CreateResponse(HttpStatusCode.OK, userAccounts));
            }
            else
            {
                var errorMessage = JsonConvert.DeserializeObject <ErrorViewModel>(json);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errorMessage));
            }
        }
Ejemplo n.º 5
0
        public async Task <ServiceResponseModel <DiscoResponse> > GetDiscos()
        {
            try
            {
                var response = await _http.GetAsync <DiscoResponse>(baseUrl : StaticAppSettings.MeterNgBaseUrl, url : "/Sales/get-disco");

                if (!response.status)
                {
                    return(_responseService.ErroResponse <DiscoResponse>("Hello Merchant, get this issue sorted out by calling 07067508940"));
                }
                else
                {
                    return(_responseService.SuccessResponse <DiscoResponse>("Discos retrived sucessfully", response));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        public async Task <HttpResponseMessage> RetrieveUserTransactionsAsync(int accountNumber, string type = "all")
        {
            var response = await _baseHttpClient.GetAsync("http://fairwaybank-bizfitech.azurewebsites.net/api/v1/accounts/" + accountNumber + "/transactions");

            var userTransactions = await response.Content.ReadAsStringAsync();

            if (userTransactions != null)
            {
                if (response.IsSuccessStatusCode)
                {
                    var transactions = JsonConvert.DeserializeObject <List <TransactionViewModel> >(userTransactions);

                    if (type == "all")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, transactions));
                    }
                    else if (string.Equals(type, "credit", StringComparison.OrdinalIgnoreCase))
                    {
                        var creditTransactions = transactions.Where(x => x.Type == "Credit").ToList();
                        return(Request.CreateResponse(HttpStatusCode.OK, creditTransactions));
                    }
                    else if (string.Equals(type, "debit", StringComparison.OrdinalIgnoreCase))
                    {
                        var debitTransactions = transactions.Where(x => x.Type == "Debit").ToList();
                        return(Request.CreateResponse(HttpStatusCode.OK, debitTransactions));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotFound));
                    }
                }
                else
                {
                    var errorMessage = JsonConvert.DeserializeObject <ErrorViewModel>(userTransactions);
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, errorMessage));
                }
            }

            return(Request.CreateResponse(HttpStatusCode.BadRequest));
        }