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)); }
public static FilterResponse GetFilter(string filterName) { switch (filterName) { case FilterFor_OrderListFilter: { return(OrderListFilter.GetFilter()); } } return(null); }
public void OrderListFilter_DoesNotHaveRequiredFields() { // Arrange _filter = new OrderListFilter(); // Act var keyValuePairs = StripeClient.GetModelKeyValuePairs(_filter).ToList(); // Assert keyValuePairs.Should().HaveCount(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(); }
public GetOrderData(OrderListFilter orderType) : this() { OrderType = orderType; }
/// <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)); }
/// <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())); }
public void Init() { _filter = GenFu.GenFu.New <OrderListFilter>(); }