简体   繁体   English

eBay Trading API 需要 GetOrders 方法所需的参数,但要进行处理,有些需要是无价值的。 空,不接受

[英]eBay Trading API requires parameters for GetOrders method required, but to process, some need to be valueless. Null, not accepted

I'm using the eBay Trading API, Visual Studio, C#, with the eBay NuGet Package installed, which creates eBay objects and methods for me.我正在使用 eBay Trading API、Visual Studio、C#,并安装了 eBay NuGet 包,它为我创建了 eBay 对象和方法。 The definition of the GetOrders(...) method is:~ GetOrders(...) 方法的定义是:~

public OrderTypeCollection GetOrders(StringCollection OrderIDList, DateTime CreateTimeFrom, DateTime CreateTimeTo, TradingRoleCodeType OrderRole, OrderStatusCodeType OrderStatus, ListingTypeCodeType ListingType, PaginationType Pagination, DateTime ModTimeFrom, DateTime ModTimeTo, int NumberOfDays, bool IncludeFinalValueFee, SortOrderCodeType SortingOrder);

Almost all of these parameters are required, null is not accepted.几乎所有这些参数都是必需的,不接受 null。 Some will accept blank variables.有些将接受空白变量。 So I have this code to call the method:所以我有这个代码来调用该方法:

var roletype = TradingRoleCodeType.Seller;
var orderstatuscode = OrderStatusCodeType.All;
var pagination = new PaginationType();
pagination.EntriesPerPage = itemsPerPage;
pagination.PageNumber = pageNumber;
int noOfDays = new int();
DateTime blankDate = new DateTime();  // Not blank, but 01/01/0001 12:00:00 AM
orders = apicall.GetOrders(null, fromDate, toDate, roletype, orderstatuscode, new ListingTypeCodeType(), pagination, blankDate, blankDate, noOfDays, false, SortOrderCodeType.Ascending);

This code will run, but returns the error "Do not provide CreateTimeFrom/To as well as ModTimeFrom/To, only provide one or the other" If I write my own calls to the API, I can just leave out the unrequired parameters, but by using the methods built by the eBay Nuget package, I'm forced to submit parameters.此代码将运行,但返回错误“不提供 CreateTimeFrom/To 和 ModTimeFrom/To,只提供一个或另一个”如果我编写自己对 API 的调用,我可以省略不需要的参数,但是通过使用 eBay Nuget 包构建的方法,我被迫提交参数。 To me, it appears impossible to use this method, because it requires two sets of dates to submit, but if submitted with two sets of dates, it is rejected by the server.对我来说,这种方法似乎是不可能使用的,因为它需要提交两组日期,但是如果提交两组日期,就会被服务器拒绝。

I'm fairly new to C#, so there's possibly something simple I'm missing.我对 C# 相当陌生,所以我可能遗漏了一些简单的东西。 There are 3 overloads for the method, but none of the accept the required set of parameters.该方法有 3 个重载,但没有一个接受所需的参数集。

I needed to pick one of the simpler GetOrders overflows, with less parameters.我需要选择参数较少的更简单的 GetOrders 溢出之一。 Then feed in optional parameters into the parent object.然后将可选参数输入到父对象中。 For example:例如:

                var orderstatuscode = OrderStatusCodeType.All;
                var pagination = new PaginationType();
                pagination.EntriesPerPage = itemsPerPage;
                pagination.PageNumber = pageNumber;
                apicall.Pagination = pagination;
                orders.AddRange(apicall.GetOrders(fromDate, toDate, roletype , orderstatuscode));

-- Edit -- After doing more work with the code, I've found an even more flexible way of getting this to support a custom selection of parameters. -- 编辑 -- 在对代码做了更多工作后,我发现了一种更灵活的方法来支持自定义参数选择。

                while (hasOrders)
                {
                    Console.WriteLine("Getting page {0}.... ", pagination.PageNumber);

                    apicall.Pagination = pagination;
                    apicall.ModTimeFrom = fromDate;
                    apicall.ModTimeTo = toDate;
                    apicall.OrderRole = TradingRoleCodeType.Seller;
                    apicall.OrderStatus = OrderStatusCodeType.All; ;
                    apicall.Execute();
                    orders.AddRange(apicall.ApiResponse.OrderArray);
                   //orders.AddRange(apicall.GetOrders(fromDate,toDate, roletype, orderstatuscode));   // No overflow will support modified date.
                    hasOrders = apicall.HasMoreOrders;
                    pagination.PageNumber++;
                }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM