src/Buy/MarketplaceInsightsBeta/V1/Api/ItemSalesApi.php
<?php
/**
* This file is part of the trollandtoad/ebay-sdk-php package.
*
* MIT License
*
* Copyright (c) 2022 Brandon Clothier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
declare(strict_types=1);
/**
* ItemSalesApi.
*
* PHP version ^7.2 || ^8.0
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
/**
* Marketplace Insights API.
*
* <a href=\"https://developer.ebay.com/api-docs/static/versioning.html#limited\" target=\"_blank\"> <img src=\"/cms/img/docs/partners-api.svg\" class=\"legend-icon partners-icon\" title=\"Limited Release\" alt=\"Limited Release\" />(Limited Release)</a> The Marketplace Insights API provides the ability to search for sold items on eBay by keyword, GTIN, category, and product and returns the of sales history of those items.
*
* The version of the OpenAPI document: v1_beta.2.2
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 5.4.0
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Api;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\ApiException;
use TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Configuration;
use TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\HeaderSelector;
use TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\ObjectSerializer;
/**
* ItemSalesApi Class Doc Comment.
*
* @category Class
*
* @author OpenAPI Generator team
*
* @see https://openapi-generator.tech
*/
class ItemSalesApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null,
$hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $hostIndex;
}
/**
* Set the host index.
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index.
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfiguration()
{
return $this->config;
}
/**
* Operation search.
*
* @param string $aspect_filter This field lets you filter by item aspects. The aspect name/value pairs and category, which is required, is used to limit the results to specific aspects of the item. For example, in a clothing category one aspect pair would be Color/Red. The results are returned in the <b>refinement</b> container. <br /><br />For example, the method below uses the category ID for Women's Clothing. This will return only sold items for a woman's red or blue shirt. <br /><br /><code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&aspect_filter=categoryId:15724,Color:{Red|Blue}</code> <br /><br />To get a list of the aspects pairs and the category, which is returned in the <b> dominantCategoryId</b> field, set <b> fieldgroups</b> to <code>ASPECT_REFINEMENTS</code>. <br /><br /> <code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&fieldgroups=ASPECT_REFINEMENTS</code> <br /><br /><b>Format: </b> <code><i>aspectName</i>:{<i>value1</i>|<i>value2</i>}</code> <br /><br /><b>Required: </b> The category ID is required <i>twice</i>; once as a URI parameter and as part of the <b> aspect_filter</b> parameter. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/gct:AspectFilter (optional)
* @param string $category_ids The category ID is required and is used to limit the results. For example, if you search for 'shirt' the result set will be very large. But if you also include the category ID <code>137084</code>, the results will be limited to 'Men's Athletic Apparel'. For example: <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=shirt&category_ids=137084</code> <p>The list of eBay category IDs is not published and category IDs are not the same across all the eBay marketplaces. You can use the following techniques to find a category by site: </p> <ul> <li>For the US marketplace, use the <a href=\"https://pages.ebay.com/sellerinformation/news/categorychanges.html\" target=\"_blank\">Category Changes page</a>.</li> <li>Use the Taxonomy API. For details see <a href=\"/api-docs/buy/buy-categories.html\">Get Categories for Buy APIs</a>. </li> </ul> <b> Usage:</b> <ul><li>This field can have one category ID or a comma separated list of IDs.</li> <li>You can use <b>category_ids</b> by itself or use it with any combination of the <b> gtin</b>, <b> epid</b>, and <b> q</b> fields, which gives you additional control over the result set.</li> </ul> <b>Restrictions: </b> <ul> <li>Partners will be given a list of categories they can use. </li> <li>To use a top-level (L1) category, you <b> must</b> also include the <b> q</b>, or <b> gtin</b>, or <b> epid</b> query parameter. </li> </ul> <b>Maximum number of categories:</b> 4 (optional)
* @param string $epid The ePID is the eBay product identifier of a product from the eBay product catalog. This field limits the results to only items in the specified ePID. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?epid=241986085&category_ids=168058</code> <br /><br />You can use the <a href=\"/api-docs/commerce/catalog/resources/product_summary/methods/search\">product_summary/search</a> method in the <b>Catalog</b> API to search for the ePID of the product. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>epid</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $fieldgroups This field lets you control what is to be returned in the response and accepts a comma separated list of values. <br /><br />The default is <b> MATCHING_ITEMS</b>, which returns the items that match the keyword or category specified. The other values return data that can be used to create histograms. For code examples see, <a href=\"#request.aspect_filter\">aspect_filter</a>. <br /><br /><b> Valid Values: </b> <ul> <li><b> ASPECT_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.aspectDistributions\">aspectDistributions</a> container, which has the <b> dominantCategoryId</b>, <b> matchCount</b>, and <b> refinementHref</b> for the various aspects of the items found. For example, if you searched for 'Mustang', some of the aspect would be <b> Model Year</b>, <b> Exterior Color</b>, <b> Vehicle Mileage</b>, etc. <br /> <br /><span class=\"tablenote\"> <b>Note: </b> ASPECT_REFINEMENTS are category specific.</span> <br /><br /></li> <li><b> BUYING_OPTION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.buyingOptionDistributions\">buyingOptionDistributions</a> container, which has the <b> matchCount</b> and <b> refinementHref</b> for <b> AUCTION</b> and <b> FIXED_PRICE</b> (Buy It Now) items. <br /><br /><span class=\"tablenote\"> <b>Note: </b>Classified items are not supported. </span> <br /><br /> </li> <li><b> CATEGORY_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.categoryDistributions\">categoryDistributions</a> container, which has the categories that the item is in. </li> <li><b> CONDITION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.conditionDistributions\">conditionDistributions</a> container, such as <b> NEW</b>, <b> USED</b>, etc. Within these groups are multiple states of the condition. For example, <b> New </b> can be New without tag, New in box, New without box, etc. </li> <li><b> MATCHING_ITEMS</b> - This is meant to be used with one or more of the refinement values above. You use this to return the specified refinements and all the matching items. </li> <li><b> FULL </b> - This returns all the refinement containers and all the matching items.</li> </ul> Code so that your app gracefully handles any future changes to this list. <br /><br /><b>Default: </b> MATCHING_ITEMS (optional)
* @param string $filter This field supports multiple field filters that can be used to limit/customize the result set. <br /><br />The following lists the supported filters. For details and examples for all the filters, see <a href=\"/api-docs/buy/static/ref-buy-browse-filters.html\">Buy API Field Filters</a>. <table> <tr> <td><ul> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#buyingOptions\">buyingOptions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditionIds\">conditionIds</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditions\">conditions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#itemLocationCountry\">itemLocationCountry</a> </li> </ul> </td> <td> <ul><li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#lastSoldDate\">lastSoldDate</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#price\">price</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#priceCurrency\">priceCurrency</a> </li> </ul></td> </tr> </table> <br />The following example filters the result set by price. <b>Note: </b>To filter by price, <b>price</b> and <b>priceCurrency</b> must always be used together. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&filter=price:[50..500],priceCurrency:USD</code> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:FilterField (optional)
* @param string $gtin This field lets you search by the Global Trade Item Number of the item as defined by <a href=\"https://www.gtin.info\" target=\"_blank\">https://www.gtin.info</a>. This can be a UPC (Universal Product Code), EAN (European Article Number), or an ISBN (International Standard Book Number) value. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?gtin=241986085&category_ids=9355</code> <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>gtin</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $limit The number of items, from the result set, returned in a single page. <br /><br /><b> Default:</b> 50<br /><b> Maximum number of items per page (limit): </b>200 <br /> <b> Maximum number of items in a result set: </b> 10,000 (optional)
* @param string $offset Specifies the number of items to skip in the result set. This is used with the <b> limit</b> field to control the pagination of the output. <br /><br />If <b> offset</b> is 0 and <b> limit</b> is 10, the method will retrieve items 1-10 from the list of items returned, if <b> offset</b> is 10 and <b> limit</b> is 10, the method will retrieve items 11 thru 20 from the list of items returned. <br /><br /><b> Valid Values</b>: 0-10,000 (inclusive) <br /> <b> Default:</b> 0 <br /> <b> Maximum number of items returned: </b> 10,000 (optional)
* @param string $q A string consisting of one or more keywords that are used to search for items on eBay. The keywords are handled as follows: <ul><li>If the keywords are separated by a comma, it is treated as an AND. In the following example, the query returns items that have iphone <b> AND</b> ipad.<br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,ipad&category_ids=15724</code> <br/> </li> <li> If the keywords are separated by a space, it is treated as an OR. In the following examples, the query returns items that have iphone <b> OR</b> ipad. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&nbsp;ipad</code> <br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,&nbsp;ipad&category_ids=15724</code> <br /> </li></ul> <b> Restriction: </b>The <code>*</code> wildcard character is <b> not</b> allowed in this field. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $sort This field specifies the order and the field name to use to sort the items. To sort in descending order use <code>-</code> before the field name. Currently, you can only sort by price (in ascending or descending order). <br /><br />If no sort parameter is submitted, the result set is sorted by &quot;<a href=\"https://pages.ebay.com/help/sell/searchstanding.html\" target=\"_blank\">Best Match</a>&quot;. <br /><br />The following are examples of using the <b> sort</b> query parameter. <br /><br /><table><tr><th>Sort</th><th>Result</th></tr><tr><td><code>&sort=price</code></td><td> Sorts by <b> price</b> in ascending order (lowest price first)</td></tr><tr><td><code>&sort=-price</code></td><td> Sorts by <b> price</b> in descending order (highest price first)</td></tr></table><br /><b> Default: </b> ascending For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:SortField (optional)
*
* @throws \TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Model\SalesHistoryPagedCollection
*/
public function search($aspect_filter = null, $category_ids = null, $epid = null, $fieldgroups = null, $filter = null, $gtin = null, $limit = null, $offset = null, $q = null, $sort = null)
{
[$response] = $this->searchWithHttpInfo($aspect_filter, $category_ids, $epid, $fieldgroups, $filter, $gtin, $limit, $offset, $q, $sort);
return $response;
}
/**
* Operation searchWithHttpInfo.
*
* @param string $aspect_filter This field lets you filter by item aspects. The aspect name/value pairs and category, which is required, is used to limit the results to specific aspects of the item. For example, in a clothing category one aspect pair would be Color/Red. The results are returned in the <b>refinement</b> container. <br /><br />For example, the method below uses the category ID for Women's Clothing. This will return only sold items for a woman's red or blue shirt. <br /><br /><code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&aspect_filter=categoryId:15724,Color:{Red|Blue}</code> <br /><br />To get a list of the aspects pairs and the category, which is returned in the <b> dominantCategoryId</b> field, set <b> fieldgroups</b> to <code>ASPECT_REFINEMENTS</code>. <br /><br /> <code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&fieldgroups=ASPECT_REFINEMENTS</code> <br /><br /><b>Format: </b> <code><i>aspectName</i>:{<i>value1</i>|<i>value2</i>}</code> <br /><br /><b>Required: </b> The category ID is required <i>twice</i>; once as a URI parameter and as part of the <b> aspect_filter</b> parameter. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/gct:AspectFilter (optional)
* @param string $category_ids The category ID is required and is used to limit the results. For example, if you search for 'shirt' the result set will be very large. But if you also include the category ID <code>137084</code>, the results will be limited to 'Men's Athletic Apparel'. For example: <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=shirt&category_ids=137084</code> <p>The list of eBay category IDs is not published and category IDs are not the same across all the eBay marketplaces. You can use the following techniques to find a category by site: </p> <ul> <li>For the US marketplace, use the <a href=\"https://pages.ebay.com/sellerinformation/news/categorychanges.html\" target=\"_blank\">Category Changes page</a>.</li> <li>Use the Taxonomy API. For details see <a href=\"/api-docs/buy/buy-categories.html\">Get Categories for Buy APIs</a>. </li> </ul> <b> Usage:</b> <ul><li>This field can have one category ID or a comma separated list of IDs.</li> <li>You can use <b>category_ids</b> by itself or use it with any combination of the <b> gtin</b>, <b> epid</b>, and <b> q</b> fields, which gives you additional control over the result set.</li> </ul> <b>Restrictions: </b> <ul> <li>Partners will be given a list of categories they can use. </li> <li>To use a top-level (L1) category, you <b> must</b> also include the <b> q</b>, or <b> gtin</b>, or <b> epid</b> query parameter. </li> </ul> <b>Maximum number of categories:</b> 4 (optional)
* @param string $epid The ePID is the eBay product identifier of a product from the eBay product catalog. This field limits the results to only items in the specified ePID. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?epid=241986085&category_ids=168058</code> <br /><br />You can use the <a href=\"/api-docs/commerce/catalog/resources/product_summary/methods/search\">product_summary/search</a> method in the <b>Catalog</b> API to search for the ePID of the product. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>epid</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $fieldgroups This field lets you control what is to be returned in the response and accepts a comma separated list of values. <br /><br />The default is <b> MATCHING_ITEMS</b>, which returns the items that match the keyword or category specified. The other values return data that can be used to create histograms. For code examples see, <a href=\"#request.aspect_filter\">aspect_filter</a>. <br /><br /><b> Valid Values: </b> <ul> <li><b> ASPECT_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.aspectDistributions\">aspectDistributions</a> container, which has the <b> dominantCategoryId</b>, <b> matchCount</b>, and <b> refinementHref</b> for the various aspects of the items found. For example, if you searched for 'Mustang', some of the aspect would be <b> Model Year</b>, <b> Exterior Color</b>, <b> Vehicle Mileage</b>, etc. <br /> <br /><span class=\"tablenote\"> <b>Note: </b> ASPECT_REFINEMENTS are category specific.</span> <br /><br /></li> <li><b> BUYING_OPTION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.buyingOptionDistributions\">buyingOptionDistributions</a> container, which has the <b> matchCount</b> and <b> refinementHref</b> for <b> AUCTION</b> and <b> FIXED_PRICE</b> (Buy It Now) items. <br /><br /><span class=\"tablenote\"> <b>Note: </b>Classified items are not supported. </span> <br /><br /> </li> <li><b> CATEGORY_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.categoryDistributions\">categoryDistributions</a> container, which has the categories that the item is in. </li> <li><b> CONDITION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.conditionDistributions\">conditionDistributions</a> container, such as <b> NEW</b>, <b> USED</b>, etc. Within these groups are multiple states of the condition. For example, <b> New </b> can be New without tag, New in box, New without box, etc. </li> <li><b> MATCHING_ITEMS</b> - This is meant to be used with one or more of the refinement values above. You use this to return the specified refinements and all the matching items. </li> <li><b> FULL </b> - This returns all the refinement containers and all the matching items.</li> </ul> Code so that your app gracefully handles any future changes to this list. <br /><br /><b>Default: </b> MATCHING_ITEMS (optional)
* @param string $filter This field supports multiple field filters that can be used to limit/customize the result set. <br /><br />The following lists the supported filters. For details and examples for all the filters, see <a href=\"/api-docs/buy/static/ref-buy-browse-filters.html\">Buy API Field Filters</a>. <table> <tr> <td><ul> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#buyingOptions\">buyingOptions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditionIds\">conditionIds</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditions\">conditions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#itemLocationCountry\">itemLocationCountry</a> </li> </ul> </td> <td> <ul><li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#lastSoldDate\">lastSoldDate</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#price\">price</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#priceCurrency\">priceCurrency</a> </li> </ul></td> </tr> </table> <br />The following example filters the result set by price. <b>Note: </b>To filter by price, <b>price</b> and <b>priceCurrency</b> must always be used together. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&filter=price:[50..500],priceCurrency:USD</code> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:FilterField (optional)
* @param string $gtin This field lets you search by the Global Trade Item Number of the item as defined by <a href=\"https://www.gtin.info\" target=\"_blank\">https://www.gtin.info</a>. This can be a UPC (Universal Product Code), EAN (European Article Number), or an ISBN (International Standard Book Number) value. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?gtin=241986085&category_ids=9355</code> <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>gtin</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $limit The number of items, from the result set, returned in a single page. <br /><br /><b> Default:</b> 50<br /><b> Maximum number of items per page (limit): </b>200 <br /> <b> Maximum number of items in a result set: </b> 10,000 (optional)
* @param string $offset Specifies the number of items to skip in the result set. This is used with the <b> limit</b> field to control the pagination of the output. <br /><br />If <b> offset</b> is 0 and <b> limit</b> is 10, the method will retrieve items 1-10 from the list of items returned, if <b> offset</b> is 10 and <b> limit</b> is 10, the method will retrieve items 11 thru 20 from the list of items returned. <br /><br /><b> Valid Values</b>: 0-10,000 (inclusive) <br /> <b> Default:</b> 0 <br /> <b> Maximum number of items returned: </b> 10,000 (optional)
* @param string $q A string consisting of one or more keywords that are used to search for items on eBay. The keywords are handled as follows: <ul><li>If the keywords are separated by a comma, it is treated as an AND. In the following example, the query returns items that have iphone <b> AND</b> ipad.<br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,ipad&category_ids=15724</code> <br/> </li> <li> If the keywords are separated by a space, it is treated as an OR. In the following examples, the query returns items that have iphone <b> OR</b> ipad. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&nbsp;ipad</code> <br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,&nbsp;ipad&category_ids=15724</code> <br /> </li></ul> <b> Restriction: </b>The <code>*</code> wildcard character is <b> not</b> allowed in this field. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $sort This field specifies the order and the field name to use to sort the items. To sort in descending order use <code>-</code> before the field name. Currently, you can only sort by price (in ascending or descending order). <br /><br />If no sort parameter is submitted, the result set is sorted by &quot;<a href=\"https://pages.ebay.com/help/sell/searchstanding.html\" target=\"_blank\">Best Match</a>&quot;. <br /><br />The following are examples of using the <b> sort</b> query parameter. <br /><br /><table><tr><th>Sort</th><th>Result</th></tr><tr><td><code>&sort=price</code></td><td> Sorts by <b> price</b> in ascending order (lowest price first)</td></tr><tr><td><code>&sort=-price</code></td><td> Sorts by <b> price</b> in descending order (highest price first)</td></tr></table><br /><b> Default: </b> ascending For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:SortField (optional)
*
* @throws \TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Model\SalesHistoryPagedCollection, HTTP status code, HTTP response headers (array of strings)
*/
public function searchWithHttpInfo($aspect_filter = null, $category_ids = null, $epid = null, $fieldgroups = null, $filter = null, $gtin = null, $limit = null, $offset = null, $q = null, $sort = null)
{
$request = $this->searchRequest($aspect_filter, $category_ids, $epid, $fieldgroups, $filter, $gtin, $limit, $offset, $q, $sort);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null, $e);
} catch (ConnectException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
} catch (GuzzleException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null, $e);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
switch ($statusCode) {
case 200:
if ('\TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Model\SalesHistoryPagedCollection' === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Model\SalesHistoryPagedCollection', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}
$returnType = '\TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Model\SalesHistoryPagedCollection';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Model\SalesHistoryPagedCollection',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation searchAsync.
*
* @param string $aspect_filter This field lets you filter by item aspects. The aspect name/value pairs and category, which is required, is used to limit the results to specific aspects of the item. For example, in a clothing category one aspect pair would be Color/Red. The results are returned in the <b>refinement</b> container. <br /><br />For example, the method below uses the category ID for Women's Clothing. This will return only sold items for a woman's red or blue shirt. <br /><br /><code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&aspect_filter=categoryId:15724,Color:{Red|Blue}</code> <br /><br />To get a list of the aspects pairs and the category, which is returned in the <b> dominantCategoryId</b> field, set <b> fieldgroups</b> to <code>ASPECT_REFINEMENTS</code>. <br /><br /> <code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&fieldgroups=ASPECT_REFINEMENTS</code> <br /><br /><b>Format: </b> <code><i>aspectName</i>:{<i>value1</i>|<i>value2</i>}</code> <br /><br /><b>Required: </b> The category ID is required <i>twice</i>; once as a URI parameter and as part of the <b> aspect_filter</b> parameter. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/gct:AspectFilter (optional)
* @param string $category_ids The category ID is required and is used to limit the results. For example, if you search for 'shirt' the result set will be very large. But if you also include the category ID <code>137084</code>, the results will be limited to 'Men's Athletic Apparel'. For example: <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=shirt&category_ids=137084</code> <p>The list of eBay category IDs is not published and category IDs are not the same across all the eBay marketplaces. You can use the following techniques to find a category by site: </p> <ul> <li>For the US marketplace, use the <a href=\"https://pages.ebay.com/sellerinformation/news/categorychanges.html\" target=\"_blank\">Category Changes page</a>.</li> <li>Use the Taxonomy API. For details see <a href=\"/api-docs/buy/buy-categories.html\">Get Categories for Buy APIs</a>. </li> </ul> <b> Usage:</b> <ul><li>This field can have one category ID or a comma separated list of IDs.</li> <li>You can use <b>category_ids</b> by itself or use it with any combination of the <b> gtin</b>, <b> epid</b>, and <b> q</b> fields, which gives you additional control over the result set.</li> </ul> <b>Restrictions: </b> <ul> <li>Partners will be given a list of categories they can use. </li> <li>To use a top-level (L1) category, you <b> must</b> also include the <b> q</b>, or <b> gtin</b>, or <b> epid</b> query parameter. </li> </ul> <b>Maximum number of categories:</b> 4 (optional)
* @param string $epid The ePID is the eBay product identifier of a product from the eBay product catalog. This field limits the results to only items in the specified ePID. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?epid=241986085&category_ids=168058</code> <br /><br />You can use the <a href=\"/api-docs/commerce/catalog/resources/product_summary/methods/search\">product_summary/search</a> method in the <b>Catalog</b> API to search for the ePID of the product. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>epid</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $fieldgroups This field lets you control what is to be returned in the response and accepts a comma separated list of values. <br /><br />The default is <b> MATCHING_ITEMS</b>, which returns the items that match the keyword or category specified. The other values return data that can be used to create histograms. For code examples see, <a href=\"#request.aspect_filter\">aspect_filter</a>. <br /><br /><b> Valid Values: </b> <ul> <li><b> ASPECT_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.aspectDistributions\">aspectDistributions</a> container, which has the <b> dominantCategoryId</b>, <b> matchCount</b>, and <b> refinementHref</b> for the various aspects of the items found. For example, if you searched for 'Mustang', some of the aspect would be <b> Model Year</b>, <b> Exterior Color</b>, <b> Vehicle Mileage</b>, etc. <br /> <br /><span class=\"tablenote\"> <b>Note: </b> ASPECT_REFINEMENTS are category specific.</span> <br /><br /></li> <li><b> BUYING_OPTION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.buyingOptionDistributions\">buyingOptionDistributions</a> container, which has the <b> matchCount</b> and <b> refinementHref</b> for <b> AUCTION</b> and <b> FIXED_PRICE</b> (Buy It Now) items. <br /><br /><span class=\"tablenote\"> <b>Note: </b>Classified items are not supported. </span> <br /><br /> </li> <li><b> CATEGORY_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.categoryDistributions\">categoryDistributions</a> container, which has the categories that the item is in. </li> <li><b> CONDITION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.conditionDistributions\">conditionDistributions</a> container, such as <b> NEW</b>, <b> USED</b>, etc. Within these groups are multiple states of the condition. For example, <b> New </b> can be New without tag, New in box, New without box, etc. </li> <li><b> MATCHING_ITEMS</b> - This is meant to be used with one or more of the refinement values above. You use this to return the specified refinements and all the matching items. </li> <li><b> FULL </b> - This returns all the refinement containers and all the matching items.</li> </ul> Code so that your app gracefully handles any future changes to this list. <br /><br /><b>Default: </b> MATCHING_ITEMS (optional)
* @param string $filter This field supports multiple field filters that can be used to limit/customize the result set. <br /><br />The following lists the supported filters. For details and examples for all the filters, see <a href=\"/api-docs/buy/static/ref-buy-browse-filters.html\">Buy API Field Filters</a>. <table> <tr> <td><ul> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#buyingOptions\">buyingOptions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditionIds\">conditionIds</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditions\">conditions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#itemLocationCountry\">itemLocationCountry</a> </li> </ul> </td> <td> <ul><li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#lastSoldDate\">lastSoldDate</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#price\">price</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#priceCurrency\">priceCurrency</a> </li> </ul></td> </tr> </table> <br />The following example filters the result set by price. <b>Note: </b>To filter by price, <b>price</b> and <b>priceCurrency</b> must always be used together. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&filter=price:[50..500],priceCurrency:USD</code> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:FilterField (optional)
* @param string $gtin This field lets you search by the Global Trade Item Number of the item as defined by <a href=\"https://www.gtin.info\" target=\"_blank\">https://www.gtin.info</a>. This can be a UPC (Universal Product Code), EAN (European Article Number), or an ISBN (International Standard Book Number) value. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?gtin=241986085&category_ids=9355</code> <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>gtin</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $limit The number of items, from the result set, returned in a single page. <br /><br /><b> Default:</b> 50<br /><b> Maximum number of items per page (limit): </b>200 <br /> <b> Maximum number of items in a result set: </b> 10,000 (optional)
* @param string $offset Specifies the number of items to skip in the result set. This is used with the <b> limit</b> field to control the pagination of the output. <br /><br />If <b> offset</b> is 0 and <b> limit</b> is 10, the method will retrieve items 1-10 from the list of items returned, if <b> offset</b> is 10 and <b> limit</b> is 10, the method will retrieve items 11 thru 20 from the list of items returned. <br /><br /><b> Valid Values</b>: 0-10,000 (inclusive) <br /> <b> Default:</b> 0 <br /> <b> Maximum number of items returned: </b> 10,000 (optional)
* @param string $q A string consisting of one or more keywords that are used to search for items on eBay. The keywords are handled as follows: <ul><li>If the keywords are separated by a comma, it is treated as an AND. In the following example, the query returns items that have iphone <b> AND</b> ipad.<br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,ipad&category_ids=15724</code> <br/> </li> <li> If the keywords are separated by a space, it is treated as an OR. In the following examples, the query returns items that have iphone <b> OR</b> ipad. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&nbsp;ipad</code> <br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,&nbsp;ipad&category_ids=15724</code> <br /> </li></ul> <b> Restriction: </b>The <code>*</code> wildcard character is <b> not</b> allowed in this field. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $sort This field specifies the order and the field name to use to sort the items. To sort in descending order use <code>-</code> before the field name. Currently, you can only sort by price (in ascending or descending order). <br /><br />If no sort parameter is submitted, the result set is sorted by &quot;<a href=\"https://pages.ebay.com/help/sell/searchstanding.html\" target=\"_blank\">Best Match</a>&quot;. <br /><br />The following are examples of using the <b> sort</b> query parameter. <br /><br /><table><tr><th>Sort</th><th>Result</th></tr><tr><td><code>&sort=price</code></td><td> Sorts by <b> price</b> in ascending order (lowest price first)</td></tr><tr><td><code>&sort=-price</code></td><td> Sorts by <b> price</b> in descending order (highest price first)</td></tr></table><br /><b> Default: </b> ascending For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:SortField (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function searchAsync($aspect_filter = null, $category_ids = null, $epid = null, $fieldgroups = null, $filter = null, $gtin = null, $limit = null, $offset = null, $q = null, $sort = null)
{
return $this->searchAsyncWithHttpInfo($aspect_filter, $category_ids, $epid, $fieldgroups, $filter, $gtin, $limit, $offset, $q, $sort)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation searchAsyncWithHttpInfo.
*
* @param string $aspect_filter This field lets you filter by item aspects. The aspect name/value pairs and category, which is required, is used to limit the results to specific aspects of the item. For example, in a clothing category one aspect pair would be Color/Red. The results are returned in the <b>refinement</b> container. <br /><br />For example, the method below uses the category ID for Women's Clothing. This will return only sold items for a woman's red or blue shirt. <br /><br /><code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&aspect_filter=categoryId:15724,Color:{Red|Blue}</code> <br /><br />To get a list of the aspects pairs and the category, which is returned in the <b> dominantCategoryId</b> field, set <b> fieldgroups</b> to <code>ASPECT_REFINEMENTS</code>. <br /><br /> <code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&fieldgroups=ASPECT_REFINEMENTS</code> <br /><br /><b>Format: </b> <code><i>aspectName</i>:{<i>value1</i>|<i>value2</i>}</code> <br /><br /><b>Required: </b> The category ID is required <i>twice</i>; once as a URI parameter and as part of the <b> aspect_filter</b> parameter. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/gct:AspectFilter (optional)
* @param string $category_ids The category ID is required and is used to limit the results. For example, if you search for 'shirt' the result set will be very large. But if you also include the category ID <code>137084</code>, the results will be limited to 'Men's Athletic Apparel'. For example: <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=shirt&category_ids=137084</code> <p>The list of eBay category IDs is not published and category IDs are not the same across all the eBay marketplaces. You can use the following techniques to find a category by site: </p> <ul> <li>For the US marketplace, use the <a href=\"https://pages.ebay.com/sellerinformation/news/categorychanges.html\" target=\"_blank\">Category Changes page</a>.</li> <li>Use the Taxonomy API. For details see <a href=\"/api-docs/buy/buy-categories.html\">Get Categories for Buy APIs</a>. </li> </ul> <b> Usage:</b> <ul><li>This field can have one category ID or a comma separated list of IDs.</li> <li>You can use <b>category_ids</b> by itself or use it with any combination of the <b> gtin</b>, <b> epid</b>, and <b> q</b> fields, which gives you additional control over the result set.</li> </ul> <b>Restrictions: </b> <ul> <li>Partners will be given a list of categories they can use. </li> <li>To use a top-level (L1) category, you <b> must</b> also include the <b> q</b>, or <b> gtin</b>, or <b> epid</b> query parameter. </li> </ul> <b>Maximum number of categories:</b> 4 (optional)
* @param string $epid The ePID is the eBay product identifier of a product from the eBay product catalog. This field limits the results to only items in the specified ePID. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?epid=241986085&category_ids=168058</code> <br /><br />You can use the <a href=\"/api-docs/commerce/catalog/resources/product_summary/methods/search\">product_summary/search</a> method in the <b>Catalog</b> API to search for the ePID of the product. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>epid</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $fieldgroups This field lets you control what is to be returned in the response and accepts a comma separated list of values. <br /><br />The default is <b> MATCHING_ITEMS</b>, which returns the items that match the keyword or category specified. The other values return data that can be used to create histograms. For code examples see, <a href=\"#request.aspect_filter\">aspect_filter</a>. <br /><br /><b> Valid Values: </b> <ul> <li><b> ASPECT_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.aspectDistributions\">aspectDistributions</a> container, which has the <b> dominantCategoryId</b>, <b> matchCount</b>, and <b> refinementHref</b> for the various aspects of the items found. For example, if you searched for 'Mustang', some of the aspect would be <b> Model Year</b>, <b> Exterior Color</b>, <b> Vehicle Mileage</b>, etc. <br /> <br /><span class=\"tablenote\"> <b>Note: </b> ASPECT_REFINEMENTS are category specific.</span> <br /><br /></li> <li><b> BUYING_OPTION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.buyingOptionDistributions\">buyingOptionDistributions</a> container, which has the <b> matchCount</b> and <b> refinementHref</b> for <b> AUCTION</b> and <b> FIXED_PRICE</b> (Buy It Now) items. <br /><br /><span class=\"tablenote\"> <b>Note: </b>Classified items are not supported. </span> <br /><br /> </li> <li><b> CATEGORY_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.categoryDistributions\">categoryDistributions</a> container, which has the categories that the item is in. </li> <li><b> CONDITION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.conditionDistributions\">conditionDistributions</a> container, such as <b> NEW</b>, <b> USED</b>, etc. Within these groups are multiple states of the condition. For example, <b> New </b> can be New without tag, New in box, New without box, etc. </li> <li><b> MATCHING_ITEMS</b> - This is meant to be used with one or more of the refinement values above. You use this to return the specified refinements and all the matching items. </li> <li><b> FULL </b> - This returns all the refinement containers and all the matching items.</li> </ul> Code so that your app gracefully handles any future changes to this list. <br /><br /><b>Default: </b> MATCHING_ITEMS (optional)
* @param string $filter This field supports multiple field filters that can be used to limit/customize the result set. <br /><br />The following lists the supported filters. For details and examples for all the filters, see <a href=\"/api-docs/buy/static/ref-buy-browse-filters.html\">Buy API Field Filters</a>. <table> <tr> <td><ul> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#buyingOptions\">buyingOptions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditionIds\">conditionIds</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditions\">conditions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#itemLocationCountry\">itemLocationCountry</a> </li> </ul> </td> <td> <ul><li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#lastSoldDate\">lastSoldDate</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#price\">price</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#priceCurrency\">priceCurrency</a> </li> </ul></td> </tr> </table> <br />The following example filters the result set by price. <b>Note: </b>To filter by price, <b>price</b> and <b>priceCurrency</b> must always be used together. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&filter=price:[50..500],priceCurrency:USD</code> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:FilterField (optional)
* @param string $gtin This field lets you search by the Global Trade Item Number of the item as defined by <a href=\"https://www.gtin.info\" target=\"_blank\">https://www.gtin.info</a>. This can be a UPC (Universal Product Code), EAN (European Article Number), or an ISBN (International Standard Book Number) value. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?gtin=241986085&category_ids=9355</code> <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>gtin</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $limit The number of items, from the result set, returned in a single page. <br /><br /><b> Default:</b> 50<br /><b> Maximum number of items per page (limit): </b>200 <br /> <b> Maximum number of items in a result set: </b> 10,000 (optional)
* @param string $offset Specifies the number of items to skip in the result set. This is used with the <b> limit</b> field to control the pagination of the output. <br /><br />If <b> offset</b> is 0 and <b> limit</b> is 10, the method will retrieve items 1-10 from the list of items returned, if <b> offset</b> is 10 and <b> limit</b> is 10, the method will retrieve items 11 thru 20 from the list of items returned. <br /><br /><b> Valid Values</b>: 0-10,000 (inclusive) <br /> <b> Default:</b> 0 <br /> <b> Maximum number of items returned: </b> 10,000 (optional)
* @param string $q A string consisting of one or more keywords that are used to search for items on eBay. The keywords are handled as follows: <ul><li>If the keywords are separated by a comma, it is treated as an AND. In the following example, the query returns items that have iphone <b> AND</b> ipad.<br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,ipad&category_ids=15724</code> <br/> </li> <li> If the keywords are separated by a space, it is treated as an OR. In the following examples, the query returns items that have iphone <b> OR</b> ipad. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&nbsp;ipad</code> <br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,&nbsp;ipad&category_ids=15724</code> <br /> </li></ul> <b> Restriction: </b>The <code>*</code> wildcard character is <b> not</b> allowed in this field. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $sort This field specifies the order and the field name to use to sort the items. To sort in descending order use <code>-</code> before the field name. Currently, you can only sort by price (in ascending or descending order). <br /><br />If no sort parameter is submitted, the result set is sorted by &quot;<a href=\"https://pages.ebay.com/help/sell/searchstanding.html\" target=\"_blank\">Best Match</a>&quot;. <br /><br />The following are examples of using the <b> sort</b> query parameter. <br /><br /><table><tr><th>Sort</th><th>Result</th></tr><tr><td><code>&sort=price</code></td><td> Sorts by <b> price</b> in ascending order (lowest price first)</td></tr><tr><td><code>&sort=-price</code></td><td> Sorts by <b> price</b> in descending order (highest price first)</td></tr></table><br /><b> Default: </b> ascending For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:SortField (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function searchAsyncWithHttpInfo($aspect_filter = null, $category_ids = null, $epid = null, $fieldgroups = null, $filter = null, $gtin = null, $limit = null, $offset = null, $q = null, $sort = null)
{
$returnType = '\TNT\Ebay\Buy\MarketplaceInsightsBeta\V1\Model\SalesHistoryPagedCollection';
$request = $this->searchRequest($aspect_filter, $category_ids, $epid, $fieldgroups, $filter, $gtin, $limit, $offset, $q, $sort);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); // Stream goes to serializer.
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody(), $exception instanceof \Throwable ? $exception : null);
}
);
}
/**
* Create request for operation 'search'.
*
* @param string $aspect_filter This field lets you filter by item aspects. The aspect name/value pairs and category, which is required, is used to limit the results to specific aspects of the item. For example, in a clothing category one aspect pair would be Color/Red. The results are returned in the <b>refinement</b> container. <br /><br />For example, the method below uses the category ID for Women's Clothing. This will return only sold items for a woman's red or blue shirt. <br /><br /><code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&aspect_filter=categoryId:15724,Color:{Red|Blue}</code> <br /><br />To get a list of the aspects pairs and the category, which is returned in the <b> dominantCategoryId</b> field, set <b> fieldgroups</b> to <code>ASPECT_REFINEMENTS</code>. <br /><br /> <code>/buy/marketplace_insights/v1_beta/item_sales/search?q=shirt&category_ids=15724&fieldgroups=ASPECT_REFINEMENTS</code> <br /><br /><b>Format: </b> <code><i>aspectName</i>:{<i>value1</i>|<i>value2</i>}</code> <br /><br /><b>Required: </b> The category ID is required <i>twice</i>; once as a URI parameter and as part of the <b> aspect_filter</b> parameter. For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/gct:AspectFilter (optional)
* @param string $category_ids The category ID is required and is used to limit the results. For example, if you search for 'shirt' the result set will be very large. But if you also include the category ID <code>137084</code>, the results will be limited to 'Men's Athletic Apparel'. For example: <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=shirt&category_ids=137084</code> <p>The list of eBay category IDs is not published and category IDs are not the same across all the eBay marketplaces. You can use the following techniques to find a category by site: </p> <ul> <li>For the US marketplace, use the <a href=\"https://pages.ebay.com/sellerinformation/news/categorychanges.html\" target=\"_blank\">Category Changes page</a>.</li> <li>Use the Taxonomy API. For details see <a href=\"/api-docs/buy/buy-categories.html\">Get Categories for Buy APIs</a>. </li> </ul> <b> Usage:</b> <ul><li>This field can have one category ID or a comma separated list of IDs.</li> <li>You can use <b>category_ids</b> by itself or use it with any combination of the <b> gtin</b>, <b> epid</b>, and <b> q</b> fields, which gives you additional control over the result set.</li> </ul> <b>Restrictions: </b> <ul> <li>Partners will be given a list of categories they can use. </li> <li>To use a top-level (L1) category, you <b> must</b> also include the <b> q</b>, or <b> gtin</b>, or <b> epid</b> query parameter. </li> </ul> <b>Maximum number of categories:</b> 4 (optional)
* @param string $epid The ePID is the eBay product identifier of a product from the eBay product catalog. This field limits the results to only items in the specified ePID. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?epid=241986085&category_ids=168058</code> <br /><br />You can use the <a href=\"/api-docs/commerce/catalog/resources/product_summary/methods/search\">product_summary/search</a> method in the <b>Catalog</b> API to search for the ePID of the product. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>epid</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $fieldgroups This field lets you control what is to be returned in the response and accepts a comma separated list of values. <br /><br />The default is <b> MATCHING_ITEMS</b>, which returns the items that match the keyword or category specified. The other values return data that can be used to create histograms. For code examples see, <a href=\"#request.aspect_filter\">aspect_filter</a>. <br /><br /><b> Valid Values: </b> <ul> <li><b> ASPECT_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.aspectDistributions\">aspectDistributions</a> container, which has the <b> dominantCategoryId</b>, <b> matchCount</b>, and <b> refinementHref</b> for the various aspects of the items found. For example, if you searched for 'Mustang', some of the aspect would be <b> Model Year</b>, <b> Exterior Color</b>, <b> Vehicle Mileage</b>, etc. <br /> <br /><span class=\"tablenote\"> <b>Note: </b> ASPECT_REFINEMENTS are category specific.</span> <br /><br /></li> <li><b> BUYING_OPTION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.buyingOptionDistributions\">buyingOptionDistributions</a> container, which has the <b> matchCount</b> and <b> refinementHref</b> for <b> AUCTION</b> and <b> FIXED_PRICE</b> (Buy It Now) items. <br /><br /><span class=\"tablenote\"> <b>Note: </b>Classified items are not supported. </span> <br /><br /> </li> <li><b> CATEGORY_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.categoryDistributions\">categoryDistributions</a> container, which has the categories that the item is in. </li> <li><b> CONDITION_REFINEMENTS</b> - This returns the <a href=\"#response.refinement.conditionDistributions\">conditionDistributions</a> container, such as <b> NEW</b>, <b> USED</b>, etc. Within these groups are multiple states of the condition. For example, <b> New </b> can be New without tag, New in box, New without box, etc. </li> <li><b> MATCHING_ITEMS</b> - This is meant to be used with one or more of the refinement values above. You use this to return the specified refinements and all the matching items. </li> <li><b> FULL </b> - This returns all the refinement containers and all the matching items.</li> </ul> Code so that your app gracefully handles any future changes to this list. <br /><br /><b>Default: </b> MATCHING_ITEMS (optional)
* @param string $filter This field supports multiple field filters that can be used to limit/customize the result set. <br /><br />The following lists the supported filters. For details and examples for all the filters, see <a href=\"/api-docs/buy/static/ref-buy-browse-filters.html\">Buy API Field Filters</a>. <table> <tr> <td><ul> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#buyingOptions\">buyingOptions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditionIds\">conditionIds</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#conditions\">conditions</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#itemLocationCountry\">itemLocationCountry</a> </li> </ul> </td> <td> <ul><li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#lastSoldDate\">lastSoldDate</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#price\">price</a> </li> <li><a href=\"/api-docs/buy/static/ref-buy-browse-filters.html#priceCurrency\">priceCurrency</a> </li> </ul></td> </tr> </table> <br />The following example filters the result set by price. <b>Note: </b>To filter by price, <b>price</b> and <b>priceCurrency</b> must always be used together. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&filter=price:[50..500],priceCurrency:USD</code> For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:FilterField (optional)
* @param string $gtin This field lets you search by the Global Trade Item Number of the item as defined by <a href=\"https://www.gtin.info\" target=\"_blank\">https://www.gtin.info</a>. This can be a UPC (Universal Product Code), EAN (European Article Number), or an ISBN (International Standard Book Number) value. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?gtin=241986085&category_ids=9355</code> <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b> Maximum: </b> 1 <b>gtin</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $limit The number of items, from the result set, returned in a single page. <br /><br /><b> Default:</b> 50<br /><b> Maximum number of items per page (limit): </b>200 <br /> <b> Maximum number of items in a result set: </b> 10,000 (optional)
* @param string $offset Specifies the number of items to skip in the result set. This is used with the <b> limit</b> field to control the pagination of the output. <br /><br />If <b> offset</b> is 0 and <b> limit</b> is 10, the method will retrieve items 1-10 from the list of items returned, if <b> offset</b> is 10 and <b> limit</b> is 10, the method will retrieve items 11 thru 20 from the list of items returned. <br /><br /><b> Valid Values</b>: 0-10,000 (inclusive) <br /> <b> Default:</b> 0 <br /> <b> Maximum number of items returned: </b> 10,000 (optional)
* @param string $q A string consisting of one or more keywords that are used to search for items on eBay. The keywords are handled as follows: <ul><li>If the keywords are separated by a comma, it is treated as an AND. In the following example, the query returns items that have iphone <b> AND</b> ipad.<br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,ipad&category_ids=15724</code> <br/> </li> <li> If the keywords are separated by a space, it is treated as an OR. In the following examples, the query returns items that have iphone <b> OR</b> ipad. <br /><br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone&category_ids=15724&nbsp;ipad</code> <br /><code>/buy/marketplace-insights/v1_beta/item_sales/search?q=iphone,&nbsp;ipad&category_ids=15724</code> <br /> </li></ul> <b> Restriction: </b>The <code>*</code> wildcard character is <b> not</b> allowed in this field. <br /><br /><b> Required: </b> At least 1 <b> category_ids</b> <br /><b>Optional: </b>Any combination of <b> epid</b>, <b> gtin</b>, or <b> q</b> (optional)
* @param string $sort This field specifies the order and the field name to use to sort the items. To sort in descending order use <code>-</code> before the field name. Currently, you can only sort by price (in ascending or descending order). <br /><br />If no sort parameter is submitted, the result set is sorted by &quot;<a href=\"https://pages.ebay.com/help/sell/searchstanding.html\" target=\"_blank\">Best Match</a>&quot;. <br /><br />The following are examples of using the <b> sort</b> query parameter. <br /><br /><table><tr><th>Sort</th><th>Result</th></tr><tr><td><code>&sort=price</code></td><td> Sorts by <b> price</b> in ascending order (lowest price first)</td></tr><tr><td><code>&sort=-price</code></td><td> Sorts by <b> price</b> in descending order (highest price first)</td></tr></table><br /><b> Default: </b> ascending For implementation help, refer to eBay API documentation at https://developer.ebay.com/api-docs/buy/marketplace_insights/types/cos:SortField (optional)
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function searchRequest($aspect_filter = null, $category_ids = null, $epid = null, $fieldgroups = null, $filter = null, $gtin = null, $limit = null, $offset = null, $q = null, $sort = null)
{
$resourcePath = '/item_sales/search';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$aspect_filter,
'aspect_filter', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$category_ids,
'category_ids', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$epid,
'epid', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$fieldgroups,
'fieldgroups', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$filter,
'filter', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$gtin,
'gtin', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$limit,
'limit', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$offset,
'offset', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$q,
'q', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$sort,
'sort', // param base name
'string', // openApiType
'form', // style
true // explode
) ?? []);
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// For model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// For HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// For HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($queryParams);
}
}
// this endpoint requires OAuth (access token)
if (! empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Create http client option.
*
* @throws \RuntimeException on file opening failure
*
* @return array of http client options
*/
protected function createHttpClientOption()
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'ab');
if (! $options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: '.$this->config->getDebugFile());
}
}
return $options;
}
}