Exemple #1
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));
        }
Exemple #2
0
        public HttpResponse <CustomerList> GetCustomerList(CustomerGetList request)
        {
            var getCustomerListUri = 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(new ApiHttpClient().GetRequest <CustomerList>(getCustomerListUri, AppSettings.SecretKey));
        }
        public void GetCustomerList()
        {
            var startTime = DateTime.UtcNow.AddHours(-1); // records for the past hour

            var customer1 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer2 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer3 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer4 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());

            var custGetListRequest = new CustomerGetList
            {
                FromDate = startTime,
                ToDate   = DateTime.UtcNow
            };

            //Get all customers created
            var response = CheckoutClient.CustomerService.GetCustomerList(custGetListRequest);

            response.Should().NotBeNull();
            response.HttpStatusCode.Should().Be(HttpStatusCode.OK);
            response.Model.Count.Should().BeGreaterOrEqualTo(4);

            response.Model.Data[0].Id.Should().Be(customer4.Model.Id);
            response.Model.Data[1].Id.Should().Be(customer3.Model.Id);
            response.Model.Data[2].Id.Should().Be(customer2.Model.Id);
            response.Model.Data[3].Id.Should().Be(customer1.Model.Id);
        }
        public void GetCustomerList()
        {
            var startTime = DateTime.UtcNow.AddHours(-1);// records for the past hour

            var customer1 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer2 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer3 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer4 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());

            var custGetListRequest = new CustomerGetList()
            {
                FromDate = startTime,
                ToDate = DateTime.UtcNow
            };

            //Get all customers created
            var response = CheckoutClient.CustomerService.GetCustomerList(custGetListRequest);

            Assert.NotNull(response);
            Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK);
            Assert.IsTrue(response.Model.Count >= 4);

            Assert.IsTrue(response.Model.Data[0].Id == customer4.Model.Id);
            Assert.IsTrue(response.Model.Data[1].Id == customer3.Model.Id);
            Assert.IsTrue(response.Model.Data[2].Id == customer2.Model.Id);
            Assert.IsTrue(response.Model.Data[3].Id == customer1.Model.Id);
        }
    public HttpResponse<CustomerList> GetCustomerList(CustomerGetList request)
    {
        var getCustomerListUri = 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 new ApiHttpClient().GetRequest<CustomerList>(getCustomerListUri, AppSettings.SecretKey);
    }
        public void GetCustomerList()
        {
            var startTime = DateTime.UtcNow.AddHours(-1);// records for the past hour

            var customer1 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer2 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer3 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer4 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());

            var custGetListRequest = new CustomerGetList()
            {
                FromDate = startTime,
                ToDate   = DateTime.UtcNow
            };

            //Get all customers created
            var response = CheckoutClient.CustomerService.GetCustomerList(custGetListRequest);

            Assert.NotNull(response);
            Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK);
            Assert.IsTrue(response.Model.Count >= 4);

            Assert.IsTrue(response.Model.Data[0].Id == customer4.Model.Id);
            Assert.IsTrue(response.Model.Data[1].Id == customer3.Model.Id);
            Assert.IsTrue(response.Model.Data[2].Id == customer2.Model.Id);
            Assert.IsTrue(response.Model.Data[3].Id == customer1.Model.Id);
        }
Exemple #7
0
        public void GetCustomerList()
        {
            var startTime = DateTime.UtcNow.AddMinutes(-5); // records for the past 5 minutes

            var customer1 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer2 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer3 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());
            var customer4 = CheckoutClient.CustomerService.CreateCustomer(TestHelper.GetCustomerCreateModelWithCard());

            var custGetListRequest = new CustomerGetList
            {
                FromDate = startTime,
                ToDate   = DateTime.UtcNow
            };

            // Get all customers created
            var response = CheckoutClient.CustomerService.GetCustomerList(custGetListRequest);

            response.Should().NotBeNull();
            response.HttpStatusCode.Should().Be(HttpStatusCode.OK);
            response.Model.Count.Should().BeGreaterOrEqualTo(4);

            // Verify if customers are contained in the customer list regardless of parallel customer creation and sorting
            response.Model.Data.ToString().Should().Contain(customer1.Model.ToString());
            response.Model.Data.ToString().Should().Contain(customer2.Model.ToString());
            response.Model.Data.ToString().Should().Contain(customer3.Model.ToString());
            response.Model.Data.ToString().Should().Contain(customer4.Model.ToString());
        }
Exemple #8
0
 public HttpResponse <CustomerList> GetCustomerList(CustomerGetList request)
 {
     return(_customerServiceAsync.GetCustomerListAsync(request).Result);
 }