UNPKG

ebay-api

Version:

eBay API for Node and Browser

95 lines (94 loc) 4.01 kB
import Api from './index.js'; import { Browse, Deal, Feed, Marketing as BuyMarketing, MarketplaceInsights, Offer, Order } from './restful/buy/index.js'; import { Catalog, Charity, Identity, Notification, Taxonomy, Translation } from './restful/commerce/index.js'; import { Analytics as DeveloperAnalytics, KeyManagement } from './restful/developer/index.js'; import { Cancellation, Case, Inquiry, Return, } from './restful/postOrder/index.js'; import { Account, Analytics as SellAnalytics, Compliance, Feed as SellFeed, Finances, Fulfillment, Inventory, Listing, Logistics, Marketing as SellMarketing, Metadata, Negotiation, Recommendation } from './restful/sell/index.js'; import Traditional from './traditional/index.js'; /** * Factory class to create RESTFul API or Traditional API. */ export default class ApiFactory extends Api { constructor() { super(...arguments); this._restful = {}; } createBuyApi() { return { browse: this.createRestfulApi(Browse), feed: this.createRestfulApi(Feed), marketing: this.createRestfulApi(BuyMarketing), offer: this.createRestfulApi(Offer), order: this.createRestfulApi(Order), deal: this.createRestfulApi(Deal), marketplaceInsights: this.createRestfulApi(MarketplaceInsights), }; } createCommerceApi() { return { catalog: this.createRestfulApi(Catalog), identity: this.createRestfulApi(Identity), taxonomy: this.createRestfulApi(Taxonomy), translation: this.createRestfulApi(Translation), charity: this.createRestfulApi(Charity), notification: this.createRestfulApi(Notification), }; } createDeveloperApi() { return { analytics: this.createRestfulApi(DeveloperAnalytics), keyManagement: this.createRestfulApi(KeyManagement), }; } createPostOrderApi() { return { cancellation: this.createRestfulApi(Cancellation), case: this.createRestfulApi(Case), inquiry: this.createRestfulApi(Inquiry), return: this.createRestfulApi(Return), }; } createSellApi() { return { account: this.createRestfulApi(Account), analytics: this.createRestfulApi(SellAnalytics), compliance: this.createRestfulApi(Compliance), fulfillment: this.createRestfulApi(Fulfillment), inventory: this.createRestfulApi(Inventory), marketing: this.createRestfulApi(SellMarketing), metadata: this.createRestfulApi(Metadata), recommendation: this.createRestfulApi(Recommendation), finances: this.createRestfulApi(Finances), feed: this.createRestfulApi(SellFeed), logistics: this.createRestfulApi(Logistics), negotiation: this.createRestfulApi(Negotiation), listing: this.createRestfulApi(Listing), }; } get traditional() { if (this._traditional) { return this._traditional; } return (this._traditional = new Traditional(this.config, this.req, this.auth)); } createTradingApi() { return this.traditional.createTradingApi(); } createShoppingApi() { return this.traditional.createShoppingApi(); } createFindingApi() { return this.traditional.createFindingApi(); } createClientAlertsApi() { return this.traditional.createClientAlertsApi(); } createMerchandisingApi() { return this.traditional.createMerchandisingApi(); } // tslint:disable-next-line:variable-name createRestfulApi(RestfulApiClass) { const id = RestfulApiClass.id; return (this._restful[id] || (this._restful[id] = new RestfulApiClass(this.config, this.req, this.auth))); } }