예제 #1
0
        public async Task <StripeResponse <Pagination <Order> > > GetOrders(OrderListFilter filter,
                                                                            CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new StripeRequest <OrderListFilter, Pagination <Order> >
            {
                UrlPath = Paths.Orders,
                Model   = filter
            };

            return(await _client.Get(request, cancellationToken));
        }
예제 #2
0
 public static FilterResponse GetFilter(string filterName)
 {
     switch (filterName)
     {
     case FilterFor_OrderListFilter:
     {
         return(OrderListFilter.GetFilter());
     }
     }
     return(null);
 }
예제 #3
0
        public void OrderListFilter_DoesNotHaveRequiredFields()
        {
            // Arrange
            _filter = new OrderListFilter();

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_filter).ToList();

            // Assert
            keyValuePairs.Should().HaveCount(0);
        }
예제 #4
0
        public async Task Allows_Setting_Global_HttpClientFactory()
        {
            var factory = new FakeHttpClientFactory();

            ShopifyService.SetGlobalHttpClientFactory(factory);

            var shopService  = new ShopService(Utils.MyShopifyUrl, Utils.AccessToken);
            var orderService = new OrderService(Utils.MyShopifyUrl, Utils.AccessToken);
            var policy       = new LeakyBucketExecutionPolicy();
            var orderFilter  = new OrderListFilter
            {
                Limit = 1
            };

            shopService.SetExecutionPolicy(policy);
            orderService.SetExecutionPolicy(policy);

            var ex1 = await Assert.ThrowsAsync <Exception>(() => shopService.GetAsync());

            var ex2 = await Assert.ThrowsAsync <Exception>(() => orderService.ListAsync(orderFilter));

            Assert.Equal("This is an exception thrown by the FakeHttpClient", ex1.Message);
            Assert.Equal("This is an exception thrown by the FakeHttpClient", ex2.Message);

            // Removing the factory should only remove it for future instances
            ShopifyService.SetGlobalHttpClientFactory(null);

            ex1 = await Assert.ThrowsAsync <Exception>(() => shopService.GetAsync());

            ex2 = await Assert.ThrowsAsync <Exception>(() => orderService.ListAsync(orderFilter));

            Assert.Equal("This is an exception thrown by the FakeHttpClient", ex1.Message);
            Assert.Equal("This is an exception thrown by the FakeHttpClient", ex2.Message);

            // Instantiating the services again should now use the default HttpClientFactory
            shopService  = new ShopService(Utils.MyShopifyUrl, Utils.AccessToken);
            orderService = new OrderService(Utils.MyShopifyUrl, Utils.AccessToken);

            shopService.SetExecutionPolicy(policy);
            orderService.SetExecutionPolicy(policy);

            var shop = await shopService.GetAsync();

            var orders = await orderService.ListAsync(orderFilter);

            Assert.NotNull(shop);
            Assert.NotNull(orders);
        }
        public async Task GetOrdersTest()
        {
            // Arrange
            var filter = new OrderListFilter();

            _stripe.Get(
                Arg.Is <StripeRequest <OrderListFilter, Pagination <Order> > >(
                    a => a.UrlPath == "orders" && a.Model == filter), _cancellationToken)
            .Returns(Task.FromResult(new StripeResponse <Pagination <Order> >()));

            // Act
            var response = await _client.GetOrders(filter, _cancellationToken);

            // Assert
            response.Should().NotBeNull();
        }
예제 #6
0
 public GetOrderData(OrderListFilter orderType) : this()
 {
     OrderType = orderType;
 }
예제 #7
0
 /// <summary>
 /// Gets a list of up to 250 of the shop's orders.
 /// </summary>
 /// <param name="filter">Options for filtering the list.</param>
 /// <param name="cancellationToken">Cancellation Token</param>
 /// <returns>The list of orders matching the filter.</returns>
 public virtual async Task <ListResult <Order> > ListAsync(OrderListFilter filter = null, CancellationToken cancellationToken = default)
 {
     return(await ListAsync(filter?.AsListFilter(), cancellationToken));
 }
예제 #8
0
 /// <summary>
 /// Gets a list of up to 250 of the shop's orders.
 /// </summary>
 /// <param name="filter">Options for filtering the list.</param>
 /// <returns>The list of orders matching the filter.</returns>
 public virtual async Task <ListResult <Order> > ListAsync(OrderListFilter filter = null)
 {
     return(await ListAsync(filter?.AsListFilter()));
 }
예제 #9
0
 public void Init()
 {
     _filter = GenFu.GenFu.New <OrderListFilter>();
 }