public void Parse_GetOrdersResponseWithItemVariationSku_HookupVariationSku()
 {
     using (var fs = new FileStream(@".\FIles\GetOrdersResponse\EbayServiceGetOrdersResponseWithItemVariationSku.xml", FileMode.Open, FileAccess.Read))
     {
         var parser = new EbayGetOrdersResponseParser();
         var orders = parser.Parse(fs);
         orders.Orders.First().TransactionArray.First().Variation.Sku.Should().NotBeNullOrWhiteSpace("because in source file there is item with variation sku");
     }
 }
 public void Parse_OrdersResponseWithoutItems_ThereisNoErrorsAndExceptions()
 {
     using (var fs = new FileStream(@".\FIles\GetOrdersResponse\EbayServiceGetOrdersResponseWithOutItems.xml", FileMode.Open, FileAccess.Read))
     {
         var parser = new EbayGetOrdersResponseParser();
         var orders = parser.Parse(fs);
         orders.Orders.Should().HaveCount(0, "because in source file there is {0} orders", 0);
     }
 }
 public void FileStreamWithCorrectXml_ParseOrdersResponse_HookupCorrectDeserializedObject()
 {
     using (var fs = new FileStream(@".\FIles\GetOrdersResponse\EbayServiceGetOrdersResponseWithItemsSku.xml", FileMode.Open, FileAccess.Read))
     {
         var parser = new EbayGetOrdersResponseParser();
         var orders = parser.Parse(fs);
         orders.Orders.Should().HaveCount(1, "because in source file there is {0} order", 1);
         orders.Orders[0].Status.ShouldBeEquivalentTo(EbayOrderStatusEnum.Active);
     }
 }
Пример #4
0
        public async Task <GetOrdersResponse> GetOrdersAsync(string mark = "", params string[] ordersIds)
        {
            var orders = new GetOrdersResponse();

            var totalRecords   = 0;
            var recordsPerPage = this._itemsPerPage;
            var pageNumber     = 1;
            var hasMoreOrders  = false;

            do
            {
                var headers = CreateEbayGetOrdersRequestHeadersWithApiCallName();

                var body = this.CreateGetOrdersRequestBody(recordsPerPage, pageNumber, ordersIds);

                await ActionPolicies.GetAsync.Do(async() =>
                {
                    var webRequest = await this.CreateEbayStandartPostRequestWithCertAsync(this._endPoint, headers, body, mark, CancellationToken.None).ConfigureAwait(false);

                    using (var memStream = await this._webRequestServices.GetResponseStreamAsync(webRequest, mark, CancellationToken.None).ConfigureAwait(false))
                    {
                        var pagination = new EbayPaginationResultResponseParser().Parse(memStream);
                        if (pagination != null)
                        {
                            totalRecords = pagination.TotalNumberOfEntries;
                        }

                        var getOrdersResponseParsed = new EbayGetOrdersResponseParser().Parse(memStream);
                        if (getOrdersResponseParsed != null)
                        {
                            if (getOrdersResponseParsed.Errors != null)
                            {
                                orders.Errors = getOrdersResponseParsed.Errors;
                                return;
                            }
                            hasMoreOrders = getOrdersResponseParsed.HasMoreOrders;
                            if (getOrdersResponseParsed.Orders != null)
                            {
                                orders.Orders.AddRange(getOrdersResponseParsed.Orders);
                            }
                        }
                    }
                }).ConfigureAwait(false);

                pageNumber++;
            } while(hasMoreOrders);

            return(orders);
        }
        public void Parse_GetOrdersResponse_HookupOrdewrDetails()
        {
            using (var fs = new FileStream(@".\Files\GetOrdersResponse\EbayServiceGetOrdersResponseWithItemsSku.xml", FileMode.Open, FileAccess.Read))
            {
                //A
                var parser = new EbayGetOrdersResponseParser();
                //A
                var orders = parser.Parse(fs);
                //A
                orders.Orders.First().TransactionArray.First().Item.Sku.Should().NotBeNullOrWhiteSpace("because in source file there is order with SKU");
                orders.Orders.First().ShippingAddress.Name.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingAddress.Country.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingAddress.CountryName.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingAddress.Phone.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingAddress.City.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingAddress.PostalCode.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingAddress.State.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingAddress.Street1.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingAddress.Street2.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");

                orders.Orders.First().ShippingDetails.ShippingServiceOptions.ShippingService.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.ShippingServiceOptions.ShippingServiceCost.Should().HaveValue("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.ShippingServiceOptions.ShippingServicePriority.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.ShippingServiceOptions.ExpeditedService.Should().HaveValue("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.ShippingServiceOptions.ShippingTimeMin.Should().HaveValue("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.ShippingServiceOptions.ShippingTimeMax.Should().HaveValue("because in source file there is shipping info");

                orders.Orders.First().ShippingDetails.SalesTax.SalesTaxPercent.Should().HaveValue("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.SalesTax.SalesTaxState.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.SalesTax.ShippingIncludedInTax.Should().HaveValue("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.SalesTax.SalesTaxAmount.Should().HaveValue("because in source file there is shipping info");
                orders.Orders.First().ShippingDetails.SalesTax.SalesTaxAmountCurrencyId.Should().NotBeNullOrWhiteSpace("because in source file there is shipping info");

                orders.Orders.First().ShippingDetails.GetItFast.Should().HaveValue("because in source file there is shipping info");
            }
        }