@paritydeals/node-sdk
Version:
Node.js SDK for interacting with the ParityDeals API.
81 lines (77 loc) • 3.19 kB
JavaScript
;
// src/index.ts
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParityDeals = void 0;
// --- Client ---
// Export the main client class and its options interface.
// Users will typically instantiate the client using `new ParityDeals(...)`.
var client_1 = require("./client");
Object.defineProperty(exports, "ParityDeals", { enumerable: true, get: function () { return client_1.ParityDeals; } });
// --- Constants ---
// Export all constants and their associated literal types.
// This allows users to import them for type safety and convenience.
__exportStar(require("./constants"), exports);
// --- Exceptions ---
// Export all custom exception classes.
// Users can catch these specific errors when interacting with the SDK.
__exportStar(require("./exceptions"), exports);
// --- Models (Payloads and Responses) ---
// Export all model interfaces from the models/index.ts barrel file.
// This makes interfaces like ReportUsagePayload, CreateCheckoutSessionResponse, etc.,
// available directly from the SDK root import.
__exportStar(require("./models"), exports);
// --- Example of how a user might import and use various components ---
/*
import {
ParityDeals,
ParityDealsClientOptions,
ReportUsagePayload,
ReportUsageResponse,
ApiError,
InvalidRequestError,
BEHAVIOUR_CHOICES,
Behaviour, // Literal type for BEHAVIOUR_CHOICES
// ... other models and types ...
} from '@paritydeals/node-sdk'; // Assuming '@paritydeals/node-sdk' is the package name
const options: ParityDealsClientOptions = {
accessToken: "YOUR_ACCESS_TOKEN",
// logger: console, // Example of passing a logger
};
const client = new ParityDeals(options);
async function exampleUsage() {
try {
const usagePayload: ReportUsagePayload = {
customerId: "cust123",
featureId: "featABC",
value: 10,
behaviour: BEHAVIOUR_CHOICES.SET, // Using the exported constant
};
const usageResponse: ReportUsageResponse = await client.reporting.reportUsage(usagePayload);
console.log("Usage reported:", usageResponse.idempotencyKey);
} catch (error) {
if (error instanceof InvalidRequestError) {
console.error("Invalid request to ParityDeals:", error.message, error.details);
} else if (error instanceof ApiError) {
console.error(`ParityDeals API Error (${error.statusCode}): ${error.message}`);
} else {
console.error("An unexpected error occurred:", error);
}
}
}
exampleUsage();
*/
//# sourceMappingURL=index.js.map