Esempio n. 1
0
        public HttpResponse <DrinkList> GetDrinkList(DrinkGetList request)
        {
            var getDrinkListUri = ApiUrls.Drinks;

            if (request.Count.HasValue)
            {
                getDrinkListUri = UrlHelper.AddParameterToUrl(getDrinkListUri, "count", request.Count.ToString());
            }

            if (request.Offset.HasValue)
            {
                getDrinkListUri = UrlHelper.AddParameterToUrl(getDrinkListUri, "offset", request.Offset.ToString());
            }

            if (request.FromDate.HasValue)
            {
                getDrinkListUri = UrlHelper.AddParameterToUrl(getDrinkListUri, "fromDate", DateTimeHelper.FormatAsUtc(request.FromDate.Value));
            }

            if (request.ToDate.HasValue)
            {
                getDrinkListUri = UrlHelper.AddParameterToUrl(getDrinkListUri, "toDate", DateTimeHelper.FormatAsUtc(request.ToDate.Value));
            }

            return(new ApiHttpClient().GetRequest <DrinkList>(getDrinkListUri, AppSettings.SecretKey));
        }
Esempio n. 2
0
        public Task <HttpResponse <CustomerList> > GetCustomerListAsync(CustomerGetList request)
        {
            var getCustomerListUri = _configuration.ApiUrls.Customers;

            if (request.Count.HasValue)
            {
                getCustomerListUri = UrlHelper.AddParameterToUrl(getCustomerListUri, "count", request.Count.ToString());
            }

            if (request.Offset.HasValue)
            {
                getCustomerListUri = UrlHelper.AddParameterToUrl(getCustomerListUri, "offset", request.Offset.ToString());
            }

            if (request.FromDate.HasValue)
            {
                getCustomerListUri = UrlHelper.AddParameterToUrl(getCustomerListUri, "fromDate", DateTimeHelper.FormatAsUtc(request.FromDate.Value));
            }

            if (request.ToDate.HasValue)
            {
                getCustomerListUri = UrlHelper.AddParameterToUrl(getCustomerListUri, "toDate", DateTimeHelper.FormatAsUtc(request.ToDate.Value));
            }

            return(_apiHttpClient.GetRequest <CustomerList>(getCustomerListUri, _configuration.SecretKey));
        }
Esempio n. 3
0
        /// <summary>
        /// Get all drinks from the shopping list
        /// </summary>
        public HttpResponse <ShoppingListDrinks> GetDrinks(GetDrinks requestModel)
        {
            var getDrinksUri = ApiUrls.GetDrinks;

            if (requestModel.PageSize.HasValue)
            {
                getDrinksUri = UrlHelper.AddParameterToUrl(getDrinksUri, "pageSize", requestModel.PageSize);
            }

            if (requestModel.Page.HasValue)
            {
                getDrinksUri = UrlHelper.AddParameterToUrl(getDrinksUri, "page", requestModel.Page);
            }

            return(new ApiHttpClient().GetRequest <ShoppingListDrinks>(getDrinksUri, AppSettings.SecretKey));
        }
Esempio n. 4
0
        public HttpResponse <ShoppingList> GetShoppingList(ShoppingList request)
        {
            var getShoppingListUri = string.Format(ApiUrls.ShoppingList, "all");

            if (request.Limit.HasValue)
            {
                getShoppingListUri = UrlHelper.AddParameterToUrl(getShoppingListUri, "limit", request.Limit.ToString());
            }

            if (request.Offset.HasValue)
            {
                getShoppingListUri = UrlHelper.AddParameterToUrl(getShoppingListUri, "offset", request.Offset.ToString());
            }

            return(new ApiHttpClient().GetRequest <ShoppingList>(getShoppingListUri, "Bearer " + shoppingToken.Token));
        }
Esempio n. 5
0
        public HttpResponse <Checkout.ApiServices.ShoppingList.ResponseModels.ShoppingList> GetShoppingList(ShoppingItemGetList request)
        {
            var getShoppingListUri = ApiUrls.ShoppingList;

            if (request.PageSize.HasValue)
            {
                getShoppingListUri = UrlHelper.AddParameterToUrl(getShoppingListUri, "pageSize", request.PageSize.ToString());
            }

            if (!string.IsNullOrEmpty(request.PageNumber))
            {
                getShoppingListUri = UrlHelper.AddParameterToUrl(getShoppingListUri, "pageNumber", request.PageNumber);
            }

            return(new ApiHttpClient().GetRequest <Checkout.ApiServices.ShoppingList.ResponseModels.ShoppingList>(getShoppingListUri, AppSettings.SecretKey));
        }
Esempio n. 6
0
        /// <summary>
        /// Get items paginated
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public HttpResponse <List <Item> > GetItems(GetItemListRequest requestModel)
        {
            var getItemsListUri = ApiUrls.Item;

            if (requestModel.Count.HasValue)
            {
                getItemsListUri = UrlHelper.AddParameterToUrl(getItemsListUri, "count", requestModel.Count.ToString());
            }
            int pageNumber;

            if (int.TryParse(requestModel.PageNumber, out pageNumber))
            {
                int x = 0;
                getItemsListUri = UrlHelper.AddParameterToUrl(getItemsListUri, "pageNumber", requestModel.PageNumber);
            }
            return(new ApiHttpClient().GetRequest <List <Item> >(getItemsListUri, AppSettings.SecretKey));
        }