Skip to content

Commit

Permalink
feat: add marketplace insights API
Browse files Browse the repository at this point in the history
  • Loading branch information
dantio committed Apr 7, 2021
1 parent b7d1f3b commit 3788ade
Show file tree
Hide file tree
Showing 8 changed files with 1,033 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ It supports `client credentials grant` and `authorization code grant` \(Auth'N'A

| API | Implemented |
| :--- | :--- |
| **Buy API** | ✔ Browse API<br>✔ Deal API<br>✔ Feed API<br>✔ Marketing API<br>✔ Offer API<br>✔ Order API<br>✔ Marketplace Insights API |
| **Buy API** | ✔ Browse API<br>✔ Deal API<br>✔ Feed API<br>✔ Marketing API<br>✔ Offer API<br>✔ Order API<br>✔ Marketplace Insights API <small>(Limited Release) available only to select developers approved by business units</small>|
| **Commerce API** | ✔ Catalog API<br>✔ Charity API<br>✔ Identity API<br>✔ Notification API<br>✔ Taxonomy API<br>✔ Translation API |
| **Developer API** ||
| **Post Order API** ||
Expand Down
3 changes: 2 additions & 1 deletion src/api/apiFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {IEBayApiRequest} from '../request';
import {AppConfig, ClientAlerts, Finding, Shopping, Trading} from '../types';
import Api from './';
import RestfulApi from './restful/';
import {Browse, Buy, Deal, Feed, Marketing as BuyMarketing, Offer, Order} from './restful/buy';
import {Browse, Buy, Deal, Feed, Marketing as BuyMarketing, MarketplaceInsights, Offer, Order} from './restful/buy';
import {Catalog, Charity, Commerce, Identity, Notification, Taxonomy, Translation} from './restful/commerce';
import {Analytics as DeveloperAnalytics, Developer,} from './restful/developer';
import {Cancellation, Case, Inquiry, PostOrder, Return,} from './restful/postOrder';
Expand Down Expand Up @@ -40,6 +40,7 @@ export default class ApiFactory extends Api {
offer: this.createRestfulApi(Offer),
order: this.createRestfulApi(Order),
deal: this.createRestfulApi(Deal),
marketplaceInsights: this.createRestfulApi(MarketplaceInsights),
};
}

Expand Down
9 changes: 6 additions & 3 deletions src/api/restful/buy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ import Marketing from './marketing';
import Offer from './offer';
import Order from './order';
import Deal from './deal';
import MarketplaceInsights from './marketplaceInsights'

export type Buy = {
browse: Browse,
deal: Deal
feed: Feed,
marketing: Marketing,
marketplaceInsights: MarketplaceInsights
offer: Offer,
order: Order
deal: Deal
};

export {
Browse,
Deal,
Feed,
Marketing,
MarketplaceInsights,
Offer,
Order,
Deal
Order
};
58 changes: 58 additions & 0 deletions src/api/restful/buy/marketplaceInsights/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import Restful from '../../';
import {MarketingInsightsSearchParams} from '../../../../types';

/**
* (Limited Release) 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.
*/
export default class MarketplaceInsights extends Restful {

get basePath(): string {
return '/buy/marketplace_insights/v1_beta';
}

/**
* (Limited Release) This method searches for sold eBay items by various URI query parameters and retrieves the sales
* history of the items for the last 90 days. You can search by keyword, category, eBay product ID (ePID), or GTIN,
* or a combination of these.
*
* @param itemId
* @param aspectFilter This field lets you filter by item aspects.
* @param categoryIds The category ID is required and is used to limit the results.
* @param epid The ePID is the eBay product identifier of a product from the eBay product catalog.
* @param fieldgroups This field lets you control what is to be returned in the response and accepts a comma separated list of values.
* @param filter This field supports multiple field filters that can be used to limit/customize the result set.
* @param gtin This field lets you search by the Global Trade Item Number of the item as defined by https://www.gtin.info.
* @param limit The number of items, from the result set, returned in a single page.
* @param offset Specifies the number of items to skip in the result set.
* @param q A string consisting of one or more keywords that are used to search for items on eBay.
* @param sort This field specifies the order and the field name to use to sort the items.
*/
public search({
aspectFilter,
categoryIds,
epid,
fieldgroups,
filter,
gtin,
limit,
offset,
q,
sort,
}: MarketingInsightsSearchParams) {
return this.get(`/item_sales/search`, {
params: {
aspect_filter: aspectFilter,
category_ids: categoryIds,
epid,
fieldgroups,
filter,
gtin,
limit,
offset,
q,
sort,
}
});
}
}
13 changes: 13 additions & 0 deletions src/types/restfulTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1163,4 +1163,17 @@ export type SellFeedParams = {
lookBackDays?: string
offset?: string
scheduleId?: string
}

export type MarketingInsightsSearchParams = {
aspectFilter?: string
categoryIds?: string
epid?: string
fieldgroups?: string
filter?: string
gtin?: string
limit?: string
offset?: string
q?: string
sort?: string
}
4 changes: 3 additions & 1 deletion test/api/restful/buy/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {Browse, Feed, Marketing, Offer, Order, Deal} from '../../../../src/api/restful/buy';
import {Browse, Feed, Marketing, Offer, Order, Deal, MarketplaceInsights} from '../../../../src/api/restful/buy';
import BrowseOas from './browse/buy_browse_v1_beta_oas3.json';
import FeedOas from './feed/buy_feed_v1_beta_oas3.json';
import MarketingOas from './marketing/buy_marketing_v1_beta_oas3.json';
import OfferOas from './offer/buy_offer_v1_beta_oas3.json';
import OrderOas from './order/buy_order_v1_beta_oas3.json';
import DealOas from './deal/buy_deal_v1_oas3.json';
import MarketplaceInsightsOas from './marketplaceInsights/buy_marketplace_insights_v1_beta_oas3.json';

const tests = new Map<any, any>();
tests.set(Browse, BrowseOas);
Expand All @@ -13,5 +14,6 @@ tests.set(Marketing, MarketingOas);
tests.set(Offer, OfferOas);
tests.set(Order, OrderOas);
tests.set(Deal, DealOas);
tests.set(MarketplaceInsights, MarketplaceInsightsOas);

export default tests;
Loading

0 comments on commit 3788ade

Please sign in to comment.