6

I am using this code portion to find all items which are in Auction type using ebay FindingAPI . Now I want to filter those items which have been started within a specified day (e.g: 2 days) . How can I add this preference??

Check this link and preference type . Here is the code portion :

IPaginationInput pagination = new PaginationInput();

pagination.entriesPerPageSpecified = true;
pagination.entriesPerPage = 100;
pagination.pageNumberSpecified = true;
pagination.pageNumber = curPage;
request.paginationInput = pagination;

ItemFilter if1 = new ItemFilter();
ItemFilter if2 = new ItemFilter();
if1.name = ItemFilterType.ListingType;
if1.value = new string[] { "Auction" };




ItemFilter[] ifa = new ItemFilter[1];
ifa[0] = if1;
request.itemFilter = ifa;

FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);


foreach (var item in response.searchResult.item)
{

    tw.WriteLine(item.viewItemURL.ToString());
    links.Add(item.viewItemURL.ToString());
}
Machavity
  • 30,841
  • 27
  • 92
  • 100
Quazi Marufur Rahman
  • 2,603
  • 5
  • 33
  • 51
  • 1
    Dont think there is a filter for that. FilterType only has EndTimeFrom EndTimeTo not startTime http://developer.ebay.com/devzone/finding/callref/types/ItemFilterType.html – Sandeep Singh Rawat Jun 01 '12 at 19:03
  • Have you tried to use the `ModTimeFrom`-type? Sure, it takes all auctions that have changed status, but maybe you can filter down the auctions client-side when you have this. – NoLifeKing Jul 03 '12 at 06:27

1 Answers1

1

This should get you roughly what you need. Set the two dates used to compare to whatever you want.

IPaginationInput pagination = new PaginationInput();

                    pagination.entriesPerPageSpecified = true;
                    pagination.entriesPerPage = 100;
                    pagination.pageNumberSpecified = true;
                    pagination.pageNumber = curPage;
                    request.paginationInput = pagination;

                    ItemFilter if1 = new ItemFilter();
                    ItemFilter if2 = new ItemFilter();
                    if1.name = ItemFilterType.ListingType;
                    if1.value = new string[] { "Auction" };




                    ItemFilter[] ifa = new ItemFilter[1];
                    ifa[0] = if1;
                    request.itemFilter = ifa;

                    FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);


                    foreach (var item in response.searchResult.item)
                    {
                         // EDIT
                         if (item.listingInfo.startTime.CompareTo(DateTime.UtcNow) > -1) // -1 is earlyer; 0 is same; +1 is later then
                         {
                           if (item.listingInfo.startTime.CompareTo(DateTime.UtcNow.AddDays(-2)) == -1 )
                           {
                               // You have an Item that was started between now and two days ago.
                               // Do something

                           }
                        }
                        // END EDIT

                        tw.WriteLine(item.viewItemURL.ToString());
                        links.Add(item.viewItemURL.ToString());
                    }
SH-
  • 1,642
  • 10
  • 13