UNPKG

shipstation-node

Version:
56 lines (55 loc) 2.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.V1API = void 0; const BaseAPI_1 = __importDefault(require("../BaseAPI")); const Accounts_1 = require("./resources/Accounts"); const Carriers_1 = require("./resources/Carriers"); const Fulfillments_1 = require("./resources/Fulfillments"); const Orders_1 = require("./resources/Orders"); const Products_1 = require("./resources/Products"); const Shipments_1 = require("./resources/Shipments"); const Stores_1 = require("./resources/Stores"); const Users_1 = require("./resources/Users"); const Warehouses_1 = require("./resources/Warehouses"); const Webhooks_1 = require("./resources/Webhooks"); // 40 requests per minute - https://www.shipstation.com/docs/api/requirements/#api-rate-limits const RATE_LIMIT_OPTS = { tokensPerInterval: 40, interval: 'minute' }; class V1API extends BaseAPI_1.default { accounts; carriers; fulfillments; orders; products; shipments; stores; warehouses; webhooks; users; constructor(options) { super('v1', 'https://ssapi.shipstation.com/', RATE_LIMIT_OPTS, options); const credentials = options.credentials.v1; if (credentials?.apiKey && credentials.apiSecret) { this.authHeaders = { Authorization: `Basic ${Buffer.from(`${credentials.apiKey}:${credentials.apiSecret}`).toString('base64')}`, ...(credentials.partnerKey ? { 'x-partner': credentials.partnerKey } : {}) }; } this.accounts = new Accounts_1.Accounts(this); this.carriers = new Carriers_1.Carriers(this); this.fulfillments = new Fulfillments_1.Fulfillments(this); this.orders = new Orders_1.Orders(this); this.products = new Products_1.Products(this); this.shipments = new Shipments_1.Shipments(this); this.stores = new Stores_1.Stores(this); this.warehouses = new Warehouses_1.Warehouses(this); this.webhooks = new Webhooks_1.Webhooks(this); this.users = new Users_1.Users(this); } } exports.V1API = V1API;