shipstation-node
Version:
Unofficial Node.js wrapper for the ShipStation API
76 lines (75 loc) • 3.11 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.V2API = void 0;
const BaseAPI_1 = __importDefault(require("../BaseAPI"));
const Batches_1 = require("./resources/Batches");
const Carriers_1 = require("./resources/Carriers");
const Downloads_1 = require("./resources/Downloads");
const Inventory_1 = require("./resources/Inventory");
const InventoryLocations_1 = require("./resources/InventoryLocations");
const InventoryWarehouses_1 = require("./resources/InventoryWarehouses");
const Labels_1 = require("./resources/Labels");
const Manifests_1 = require("./resources/Manifests");
const PackagePickups_1 = require("./resources/PackagePickups");
const PackageTypes_1 = require("./resources/PackageTypes");
const Rates_1 = require("./resources/Rates");
const Shipments_1 = require("./resources/Shipments");
const Tags_1 = require("./resources/Tags");
const Tracking_1 = require("./resources/Tracking");
const Warehouses_1 = require("./resources/Warehouses");
const Webhooks_1 = require("./resources/Webhooks");
// 200 requests per minute - https://docs.shipstation.com/rate-limits
const RATE_LIMIT_OPTS = {
tokensPerInterval: 200,
interval: 'minute'
};
class V2API extends BaseAPI_1.default {
isMock;
batches;
carriers;
downloads;
inventory;
inventoryLocations;
inventoryWarehouses;
labels;
manifests;
packagePickups;
packageTypes;
rates;
shipments;
tags;
tracking;
warehouses;
webhooks;
constructor(options) {
const credentials = options.credentials.v2;
const isMock = credentials?.mock ?? false;
const baseUrl = isMock ? 'https://docs.shipstation.com/_mock/openapi/v2' : 'https://api.shipstation.com/v2';
super('v2', baseUrl, RATE_LIMIT_OPTS, options);
const apiKey = isMock ? 'mock' : credentials?.apiKey;
if (apiKey) {
this.authHeaders = { 'API-Key': apiKey };
}
this.isMock = isMock;
this.batches = new Batches_1.Batches(this);
this.carriers = new Carriers_1.Carriers(this);
this.downloads = new Downloads_1.Downloads(this);
this.inventory = new Inventory_1.Inventory(this);
this.inventoryLocations = new InventoryLocations_1.InventoryLocations(this);
this.inventoryWarehouses = new InventoryWarehouses_1.InventoryWarehouses(this);
this.labels = new Labels_1.Labels(this);
this.manifests = new Manifests_1.Manifests(this);
this.packagePickups = new PackagePickups_1.PackagePickups(this);
this.packageTypes = new PackageTypes_1.PackageTypes(this);
this.rates = new Rates_1.Rates(this);
this.shipments = new Shipments_1.Shipments(this);
this.tags = new Tags_1.Tags(this);
this.tracking = new Tracking_1.Tracking(this);
this.warehouses = new Warehouses_1.Warehouses(this);
this.webhooks = new Webhooks_1.Webhooks(this);
}
}
exports.V2API = V2API;