@paid-ai/paid-node 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/errors/ForbiddenError.d.ts +9 -0
- package/dist/cjs/api/errors/ForbiddenError.js +52 -0
- package/dist/cjs/api/errors/index.d.ts +1 -0
- package/dist/cjs/api/errors/index.js +17 -0
- package/dist/cjs/api/index.d.ts +1 -0
- package/dist/cjs/api/index.js +1 -0
- package/dist/cjs/api/resources/agents/client/Client.d.ts +3 -3
- package/dist/cjs/api/resources/agents/client/Client.js +6 -2
- package/dist/cjs/api/resources/contacts/client/Client.d.ts +3 -3
- package/dist/cjs/api/resources/contacts/client/Client.js +6 -2
- package/dist/cjs/api/resources/customers/client/Client.d.ts +14 -3
- package/dist/cjs/api/resources/customers/client/Client.js +62 -2
- package/dist/cjs/api/resources/orders/client/Client.d.ts +13 -3
- package/dist/cjs/api/resources/orders/client/Client.js +16 -2
- package/dist/cjs/api/resources/orders/client/requests/OrderCreate.d.ts +10 -0
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +3 -3
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +6 -2
- package/dist/cjs/api/resources/usage/client/Client.d.ts +3 -3
- package/dist/cjs/api/resources/usage/client/Client.js +6 -2
- package/dist/cjs/api/types/EntitlementUsage.d.ts +23 -0
- package/dist/cjs/api/types/EntitlementUsage.js +5 -0
- package/dist/cjs/api/types/OrderLineAttributeCreate.d.ts +12 -0
- package/dist/cjs/api/types/OrderLineAttributeCreate.js +5 -0
- package/dist/cjs/api/types/OrderLineCreate.d.ts +7 -0
- package/dist/cjs/api/types/index.d.ts +2 -0
- package/dist/cjs/api/types/index.js +2 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/errors/ForbiddenError.d.mts +9 -0
- package/dist/esm/api/errors/ForbiddenError.mjs +15 -0
- package/dist/esm/api/errors/index.d.mts +1 -0
- package/dist/esm/api/errors/index.mjs +1 -0
- package/dist/esm/api/index.d.mts +1 -0
- package/dist/esm/api/index.mjs +1 -0
- package/dist/esm/api/resources/agents/client/Client.d.mts +3 -3
- package/dist/esm/api/resources/agents/client/Client.mjs +6 -2
- package/dist/esm/api/resources/contacts/client/Client.d.mts +3 -3
- package/dist/esm/api/resources/contacts/client/Client.mjs +6 -2
- package/dist/esm/api/resources/customers/client/Client.d.mts +14 -3
- package/dist/esm/api/resources/customers/client/Client.mjs +62 -2
- package/dist/esm/api/resources/orders/client/Client.d.mts +13 -3
- package/dist/esm/api/resources/orders/client/Client.mjs +16 -2
- package/dist/esm/api/resources/orders/client/requests/OrderCreate.d.mts +10 -0
- package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +3 -3
- package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +6 -2
- package/dist/esm/api/resources/usage/client/Client.d.mts +3 -3
- package/dist/esm/api/resources/usage/client/Client.mjs +6 -2
- package/dist/esm/api/types/EntitlementUsage.d.mts +23 -0
- package/dist/esm/api/types/EntitlementUsage.mjs +4 -0
- package/dist/esm/api/types/OrderLineAttributeCreate.d.mts +12 -0
- package/dist/esm/api/types/OrderLineAttributeCreate.mjs +4 -0
- package/dist/esm/api/types/OrderLineCreate.d.mts +7 -0
- package/dist/esm/api/types/index.d.mts +2 -0
- package/dist/esm/api/types/index.mjs +2 -0
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +48 -0
package/dist/cjs/Client.js
CHANGED
|
@@ -60,8 +60,8 @@ class PaidClient {
|
|
|
60
60
|
this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
|
|
61
61
|
"X-Fern-Language": "JavaScript",
|
|
62
62
|
"X-Fern-SDK-Name": "@paid-ai/paid-node",
|
|
63
|
-
"X-Fern-SDK-Version": "0.
|
|
64
|
-
"User-Agent": "@paid-ai/paid-node/0.
|
|
63
|
+
"X-Fern-SDK-Version": "0.3.0",
|
|
64
|
+
"User-Agent": "@paid-ai/paid-node/0.3.0",
|
|
65
65
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
66
66
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
67
67
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as errors from "../../errors/index.js";
|
|
5
|
+
import * as Paid from "../index.js";
|
|
6
|
+
import * as core from "../../core/index.js";
|
|
7
|
+
export declare class ForbiddenError extends errors.PaidError {
|
|
8
|
+
constructor(body: Paid.Error_, rawResponse?: core.RawResponse);
|
|
9
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ForbiddenError = void 0;
|
|
40
|
+
const errors = __importStar(require("../../errors/index.js"));
|
|
41
|
+
class ForbiddenError extends errors.PaidError {
|
|
42
|
+
constructor(body, rawResponse) {
|
|
43
|
+
super({
|
|
44
|
+
message: "ForbiddenError",
|
|
45
|
+
statusCode: 403,
|
|
46
|
+
body: body,
|
|
47
|
+
rawResponse: rawResponse,
|
|
48
|
+
});
|
|
49
|
+
Object.setPrototypeOf(this, ForbiddenError.prototype);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ForbiddenError = ForbiddenError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ForbiddenError.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ForbiddenError.js"), exports);
|
package/dist/cjs/api/index.d.ts
CHANGED
package/dist/cjs/api/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types/index.js"), exports);
|
|
18
|
+
__exportStar(require("./errors/index.js"), exports);
|
|
18
19
|
__exportStar(require("./resources/index.js"), exports);
|
|
@@ -9,7 +9,7 @@ export declare namespace Agents {
|
|
|
9
9
|
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
10
10
|
/** Specify a custom URL to connect the client to. */
|
|
11
11
|
baseUrl?: core.Supplier<string>;
|
|
12
|
-
token
|
|
12
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
13
13
|
/** Additional headers to include in requests. */
|
|
14
14
|
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
15
15
|
}
|
|
@@ -26,7 +26,7 @@ export declare namespace Agents {
|
|
|
26
26
|
}
|
|
27
27
|
export declare class Agents {
|
|
28
28
|
protected readonly _options: Agents.Options;
|
|
29
|
-
constructor(_options
|
|
29
|
+
constructor(_options?: Agents.Options);
|
|
30
30
|
/**
|
|
31
31
|
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
|
|
32
32
|
*
|
|
@@ -151,5 +151,5 @@ export declare class Agents {
|
|
|
151
151
|
*/
|
|
152
152
|
deleteByExternalId(externalId: string, requestOptions?: Agents.RequestOptions): core.HttpResponsePromise<void>;
|
|
153
153
|
private __deleteByExternalId;
|
|
154
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
154
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
155
155
|
}
|
|
@@ -55,7 +55,7 @@ const headers_js_1 = require("../../../../core/headers.js");
|
|
|
55
55
|
const url_join_1 = __importDefault(require("url-join"));
|
|
56
56
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
57
57
|
class Agents {
|
|
58
|
-
constructor(_options) {
|
|
58
|
+
constructor(_options = {}) {
|
|
59
59
|
this._options = _options;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -505,7 +505,11 @@ class Agents {
|
|
|
505
505
|
}
|
|
506
506
|
_getAuthorizationHeader() {
|
|
507
507
|
return __awaiter(this, void 0, void 0, function* () {
|
|
508
|
-
|
|
508
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
509
|
+
if (bearer != null) {
|
|
510
|
+
return `Bearer ${bearer}`;
|
|
511
|
+
}
|
|
512
|
+
return undefined;
|
|
509
513
|
});
|
|
510
514
|
}
|
|
511
515
|
}
|
|
@@ -9,7 +9,7 @@ export declare namespace Contacts {
|
|
|
9
9
|
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
10
10
|
/** Specify a custom URL to connect the client to. */
|
|
11
11
|
baseUrl?: core.Supplier<string>;
|
|
12
|
-
token
|
|
12
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
13
13
|
/** Additional headers to include in requests. */
|
|
14
14
|
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
15
15
|
}
|
|
@@ -26,7 +26,7 @@ export declare namespace Contacts {
|
|
|
26
26
|
}
|
|
27
27
|
export declare class Contacts {
|
|
28
28
|
protected readonly _options: Contacts.Options;
|
|
29
|
-
constructor(_options
|
|
29
|
+
constructor(_options?: Contacts.Options);
|
|
30
30
|
/**
|
|
31
31
|
* @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
|
|
32
32
|
*
|
|
@@ -86,5 +86,5 @@ export declare class Contacts {
|
|
|
86
86
|
*/
|
|
87
87
|
deleteByExternalId(externalId: string, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<void>;
|
|
88
88
|
private __deleteByExternalId;
|
|
89
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
89
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
90
90
|
}
|
|
@@ -55,7 +55,7 @@ const headers_js_1 = require("../../../../core/headers.js");
|
|
|
55
55
|
const url_join_1 = __importDefault(require("url-join"));
|
|
56
56
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
57
57
|
class Contacts {
|
|
58
|
-
constructor(_options) {
|
|
58
|
+
constructor(_options = {}) {
|
|
59
59
|
this._options = _options;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -356,7 +356,11 @@ class Contacts {
|
|
|
356
356
|
}
|
|
357
357
|
_getAuthorizationHeader() {
|
|
358
358
|
return __awaiter(this, void 0, void 0, function* () {
|
|
359
|
-
|
|
359
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
360
|
+
if (bearer != null) {
|
|
361
|
+
return `Bearer ${bearer}`;
|
|
362
|
+
}
|
|
363
|
+
return undefined;
|
|
360
364
|
});
|
|
361
365
|
}
|
|
362
366
|
}
|
|
@@ -9,7 +9,7 @@ export declare namespace Customers {
|
|
|
9
9
|
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
10
10
|
/** Specify a custom URL to connect the client to. */
|
|
11
11
|
baseUrl?: core.Supplier<string>;
|
|
12
|
-
token
|
|
12
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
13
13
|
/** Additional headers to include in requests. */
|
|
14
14
|
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
15
15
|
}
|
|
@@ -26,7 +26,7 @@ export declare namespace Customers {
|
|
|
26
26
|
}
|
|
27
27
|
export declare class Customers {
|
|
28
28
|
protected readonly _options: Customers.Options;
|
|
29
|
-
constructor(_options
|
|
29
|
+
constructor(_options?: Customers.Options);
|
|
30
30
|
/**
|
|
31
31
|
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
32
32
|
*
|
|
@@ -80,6 +80,17 @@ export declare class Customers {
|
|
|
80
80
|
*/
|
|
81
81
|
delete(customerId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<void>;
|
|
82
82
|
private __delete;
|
|
83
|
+
/**
|
|
84
|
+
* @param {string} customerId - The customer ID
|
|
85
|
+
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
86
|
+
*
|
|
87
|
+
* @throws {@link Paid.ForbiddenError}
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* await client.customers.getEntitlements("customerId")
|
|
91
|
+
*/
|
|
92
|
+
getEntitlements(customerId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.EntitlementUsage[]>;
|
|
93
|
+
private __getEntitlements;
|
|
83
94
|
/**
|
|
84
95
|
* @param {string} externalId
|
|
85
96
|
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -108,5 +119,5 @@ export declare class Customers {
|
|
|
108
119
|
*/
|
|
109
120
|
deleteByExternalId(externalId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<void>;
|
|
110
121
|
private __deleteByExternalId;
|
|
111
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
122
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
112
123
|
}
|
|
@@ -51,11 +51,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
51
51
|
exports.Customers = void 0;
|
|
52
52
|
const environments = __importStar(require("../../../../environments.js"));
|
|
53
53
|
const core = __importStar(require("../../../../core/index.js"));
|
|
54
|
+
const Paid = __importStar(require("../../../index.js"));
|
|
54
55
|
const headers_js_1 = require("../../../../core/headers.js");
|
|
55
56
|
const url_join_1 = __importDefault(require("url-join"));
|
|
56
57
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
57
58
|
class Customers {
|
|
58
|
-
constructor(_options) {
|
|
59
|
+
constructor(_options = {}) {
|
|
59
60
|
this._options = _options;
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
@@ -312,6 +313,61 @@ class Customers {
|
|
|
312
313
|
}
|
|
313
314
|
});
|
|
314
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* @param {string} customerId - The customer ID
|
|
318
|
+
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
319
|
+
*
|
|
320
|
+
* @throws {@link Paid.ForbiddenError}
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* await client.customers.getEntitlements("customerId")
|
|
324
|
+
*/
|
|
325
|
+
getEntitlements(customerId, requestOptions) {
|
|
326
|
+
return core.HttpResponsePromise.fromPromise(this.__getEntitlements(customerId, requestOptions));
|
|
327
|
+
}
|
|
328
|
+
__getEntitlements(customerId, requestOptions) {
|
|
329
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
330
|
+
var _a, _b, _c;
|
|
331
|
+
const _response = yield core.fetcher({
|
|
332
|
+
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, `customers/${encodeURIComponent(customerId)}/credit-bundles`),
|
|
333
|
+
method: "GET",
|
|
334
|
+
headers: (0, headers_js_1.mergeHeaders)((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
335
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
336
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
337
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
338
|
+
});
|
|
339
|
+
if (_response.ok) {
|
|
340
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
341
|
+
}
|
|
342
|
+
if (_response.error.reason === "status-code") {
|
|
343
|
+
switch (_response.error.statusCode) {
|
|
344
|
+
case 403:
|
|
345
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
346
|
+
default:
|
|
347
|
+
throw new errors.PaidError({
|
|
348
|
+
statusCode: _response.error.statusCode,
|
|
349
|
+
body: _response.error.body,
|
|
350
|
+
rawResponse: _response.rawResponse,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
switch (_response.error.reason) {
|
|
355
|
+
case "non-json":
|
|
356
|
+
throw new errors.PaidError({
|
|
357
|
+
statusCode: _response.error.statusCode,
|
|
358
|
+
body: _response.error.rawBody,
|
|
359
|
+
rawResponse: _response.rawResponse,
|
|
360
|
+
});
|
|
361
|
+
case "timeout":
|
|
362
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/{customerId}/credit-bundles.");
|
|
363
|
+
case "unknown":
|
|
364
|
+
throw new errors.PaidError({
|
|
365
|
+
message: _response.error.errorMessage,
|
|
366
|
+
rawResponse: _response.rawResponse,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
315
371
|
/**
|
|
316
372
|
* @param {string} externalId
|
|
317
373
|
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -462,7 +518,11 @@ class Customers {
|
|
|
462
518
|
}
|
|
463
519
|
_getAuthorizationHeader() {
|
|
464
520
|
return __awaiter(this, void 0, void 0, function* () {
|
|
465
|
-
|
|
521
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
522
|
+
if (bearer != null) {
|
|
523
|
+
return `Bearer ${bearer}`;
|
|
524
|
+
}
|
|
525
|
+
return undefined;
|
|
466
526
|
});
|
|
467
527
|
}
|
|
468
528
|
}
|
|
@@ -10,7 +10,7 @@ export declare namespace Orders {
|
|
|
10
10
|
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
11
11
|
/** Specify a custom URL to connect the client to. */
|
|
12
12
|
baseUrl?: core.Supplier<string>;
|
|
13
|
-
token
|
|
13
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
14
14
|
/** Additional headers to include in requests. */
|
|
15
15
|
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
16
16
|
}
|
|
@@ -28,7 +28,7 @@ export declare namespace Orders {
|
|
|
28
28
|
export declare class Orders {
|
|
29
29
|
protected readonly _options: Orders.Options;
|
|
30
30
|
protected _lines: Lines | undefined;
|
|
31
|
-
constructor(_options
|
|
31
|
+
constructor(_options?: Orders.Options);
|
|
32
32
|
get lines(): Lines;
|
|
33
33
|
/**
|
|
34
34
|
* @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -51,6 +51,16 @@ export declare class Orders {
|
|
|
51
51
|
* endDate: "2026-01-01",
|
|
52
52
|
* currency: "USD"
|
|
53
53
|
* })
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* await client.orders.create({
|
|
57
|
+
* customerExternalId: "acme-inc",
|
|
58
|
+
* name: "Acme Order with Custom Pricing",
|
|
59
|
+
* description: "Order with customized attribute pricing",
|
|
60
|
+
* startDate: "2025-01-01",
|
|
61
|
+
* endDate: "2026-01-01",
|
|
62
|
+
* currency: "USD"
|
|
63
|
+
* })
|
|
54
64
|
*/
|
|
55
65
|
create(request: Paid.OrderCreate, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Order>;
|
|
56
66
|
private __create;
|
|
@@ -81,5 +91,5 @@ export declare class Orders {
|
|
|
81
91
|
*/
|
|
82
92
|
activate(orderId: string, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Order>;
|
|
83
93
|
private __activate;
|
|
84
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
94
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
85
95
|
}
|
|
@@ -56,7 +56,7 @@ const url_join_1 = __importDefault(require("url-join"));
|
|
|
56
56
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
57
57
|
const Client_js_1 = require("../resources/lines/client/Client.js");
|
|
58
58
|
class Orders {
|
|
59
|
-
constructor(_options) {
|
|
59
|
+
constructor(_options = {}) {
|
|
60
60
|
this._options = _options;
|
|
61
61
|
}
|
|
62
62
|
get lines() {
|
|
@@ -123,6 +123,16 @@ class Orders {
|
|
|
123
123
|
* endDate: "2026-01-01",
|
|
124
124
|
* currency: "USD"
|
|
125
125
|
* })
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* await client.orders.create({
|
|
129
|
+
* customerExternalId: "acme-inc",
|
|
130
|
+
* name: "Acme Order with Custom Pricing",
|
|
131
|
+
* description: "Order with customized attribute pricing",
|
|
132
|
+
* startDate: "2025-01-01",
|
|
133
|
+
* endDate: "2026-01-01",
|
|
134
|
+
* currency: "USD"
|
|
135
|
+
* })
|
|
126
136
|
*/
|
|
127
137
|
create(request, requestOptions) {
|
|
128
138
|
return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
|
|
@@ -314,7 +324,11 @@ class Orders {
|
|
|
314
324
|
}
|
|
315
325
|
_getAuthorizationHeader() {
|
|
316
326
|
return __awaiter(this, void 0, void 0, function* () {
|
|
317
|
-
|
|
327
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
328
|
+
if (bearer != null) {
|
|
329
|
+
return `Bearer ${bearer}`;
|
|
330
|
+
}
|
|
331
|
+
return undefined;
|
|
318
332
|
});
|
|
319
333
|
}
|
|
320
334
|
}
|
|
@@ -12,6 +12,16 @@ import * as Paid from "../../../../index.js";
|
|
|
12
12
|
* endDate: "2026-01-01",
|
|
13
13
|
* currency: "USD"
|
|
14
14
|
* }
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* {
|
|
18
|
+
* customerExternalId: "acme-inc",
|
|
19
|
+
* name: "Acme Order with Custom Pricing",
|
|
20
|
+
* description: "Order with customized attribute pricing",
|
|
21
|
+
* startDate: "2025-01-01",
|
|
22
|
+
* endDate: "2026-01-01",
|
|
23
|
+
* currency: "USD"
|
|
24
|
+
* }
|
|
15
25
|
*/
|
|
16
26
|
export interface OrderCreate {
|
|
17
27
|
customerId?: string;
|
|
@@ -9,7 +9,7 @@ export declare namespace Lines {
|
|
|
9
9
|
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
10
10
|
/** Specify a custom URL to connect the client to. */
|
|
11
11
|
baseUrl?: core.Supplier<string>;
|
|
12
|
-
token
|
|
12
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
13
13
|
/** Additional headers to include in requests. */
|
|
14
14
|
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
15
15
|
}
|
|
@@ -26,7 +26,7 @@ export declare namespace Lines {
|
|
|
26
26
|
}
|
|
27
27
|
export declare class Lines {
|
|
28
28
|
protected readonly _options: Lines.Options;
|
|
29
|
-
constructor(_options
|
|
29
|
+
constructor(_options?: Lines.Options);
|
|
30
30
|
/**
|
|
31
31
|
* @param {string} orderId
|
|
32
32
|
* @param {Paid.orders.LinesUpdateRequest} request
|
|
@@ -47,5 +47,5 @@ export declare class Lines {
|
|
|
47
47
|
*/
|
|
48
48
|
update(orderId: string, request?: Paid.orders.LinesUpdateRequest, requestOptions?: Lines.RequestOptions): core.HttpResponsePromise<Paid.Order>;
|
|
49
49
|
private __update;
|
|
50
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
50
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
51
51
|
}
|
|
@@ -55,7 +55,7 @@ const headers_js_1 = require("../../../../../../core/headers.js");
|
|
|
55
55
|
const url_join_1 = __importDefault(require("url-join"));
|
|
56
56
|
const errors = __importStar(require("../../../../../../errors/index.js"));
|
|
57
57
|
class Lines {
|
|
58
|
-
constructor(_options) {
|
|
58
|
+
constructor(_options = {}) {
|
|
59
59
|
this._options = _options;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -122,7 +122,11 @@ class Lines {
|
|
|
122
122
|
}
|
|
123
123
|
_getAuthorizationHeader() {
|
|
124
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
|
|
125
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
126
|
+
if (bearer != null) {
|
|
127
|
+
return `Bearer ${bearer}`;
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
132
|
}
|
|
@@ -9,7 +9,7 @@ export declare namespace Usage {
|
|
|
9
9
|
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
10
10
|
/** Specify a custom URL to connect the client to. */
|
|
11
11
|
baseUrl?: core.Supplier<string>;
|
|
12
|
-
token
|
|
12
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
13
13
|
/** Additional headers to include in requests. */
|
|
14
14
|
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
15
15
|
}
|
|
@@ -26,7 +26,7 @@ export declare namespace Usage {
|
|
|
26
26
|
}
|
|
27
27
|
export declare class Usage {
|
|
28
28
|
protected readonly _options: Usage.Options;
|
|
29
|
-
constructor(_options
|
|
29
|
+
constructor(_options?: Usage.Options);
|
|
30
30
|
/**
|
|
31
31
|
* @param {Paid.UsageRecordBulkRequest} request
|
|
32
32
|
* @param {Usage.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -38,5 +38,5 @@ export declare class Usage {
|
|
|
38
38
|
*/
|
|
39
39
|
recordBulk(request?: Paid.UsageRecordBulkRequest, requestOptions?: Usage.RequestOptions): core.HttpResponsePromise<void>;
|
|
40
40
|
private __recordBulk;
|
|
41
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
41
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
42
42
|
}
|
|
@@ -55,7 +55,7 @@ const headers_js_1 = require("../../../../core/headers.js");
|
|
|
55
55
|
const url_join_1 = __importDefault(require("url-join"));
|
|
56
56
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
57
57
|
class Usage {
|
|
58
|
-
constructor(_options) {
|
|
58
|
+
constructor(_options = {}) {
|
|
59
59
|
this._options = _options;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -113,7 +113,11 @@ class Usage {
|
|
|
113
113
|
}
|
|
114
114
|
_getAuthorizationHeader() {
|
|
115
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
|
|
116
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
117
|
+
if (bearer != null) {
|
|
118
|
+
return `Bearer ${bearer}`;
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
117
121
|
});
|
|
118
122
|
}
|
|
119
123
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Tracks the usage of an entitlement for a customer
|
|
6
|
+
*/
|
|
7
|
+
export interface EntitlementUsage {
|
|
8
|
+
id: string;
|
|
9
|
+
createdAt?: string;
|
|
10
|
+
updatedAt?: string;
|
|
11
|
+
organizationId: string;
|
|
12
|
+
productId: string;
|
|
13
|
+
entitlementId: string;
|
|
14
|
+
customerId: string;
|
|
15
|
+
startDate: string;
|
|
16
|
+
endDate?: string;
|
|
17
|
+
/** Total entitlement amount */
|
|
18
|
+
total: number;
|
|
19
|
+
/** Available entitlement amount */
|
|
20
|
+
available: number;
|
|
21
|
+
/** Used entitlement amount */
|
|
22
|
+
used: number;
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as Paid from "../index.js";
|
|
5
|
+
export interface OrderLineAttributeCreate {
|
|
6
|
+
/** The name of the agent attribute to override (e.g., "api_call", "call_placed") */
|
|
7
|
+
agentAttributeName: string;
|
|
8
|
+
/** Quantity for this attribute (defaults to 0) */
|
|
9
|
+
quantity?: number;
|
|
10
|
+
/** Custom pricing configuration for this attribute */
|
|
11
|
+
pricing: Paid.OrderLineAttributePricing;
|
|
12
|
+
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
|
+
import * as Paid from "../index.js";
|
|
4
5
|
export interface OrderLineCreate {
|
|
6
|
+
/** Paid's internal ID for the agent/product */
|
|
5
7
|
agentId?: string;
|
|
8
|
+
/** The external ID of the agent/product i.e. the id within your system */
|
|
6
9
|
agentExternalId?: string;
|
|
10
|
+
/** Name of the order line */
|
|
7
11
|
name?: string;
|
|
12
|
+
/** Description of the order line */
|
|
8
13
|
description?: string;
|
|
14
|
+
/** Optional array of custom agent attributes to override default pricing, allowing per customer pricing. If not provided, attributes will be auto-generated from the product definition. */
|
|
15
|
+
agentAttributes?: Paid.OrderLineAttributeCreate[];
|
|
9
16
|
}
|
|
@@ -22,6 +22,8 @@ export * from "./OrderLineAttributePricing.js";
|
|
|
22
22
|
export * from "./PricePoint.js";
|
|
23
23
|
export * from "./Tier.js";
|
|
24
24
|
export * from "./OrderLineCreate.js";
|
|
25
|
+
export * from "./OrderLineAttributeCreate.js";
|
|
25
26
|
export * from "./Signal.js";
|
|
26
27
|
export * from "./Error_.js";
|
|
27
28
|
export * from "./ApiError.js";
|
|
29
|
+
export * from "./EntitlementUsage.js";
|
|
@@ -38,6 +38,8 @@ __exportStar(require("./OrderLineAttributePricing.js"), exports);
|
|
|
38
38
|
__exportStar(require("./PricePoint.js"), exports);
|
|
39
39
|
__exportStar(require("./Tier.js"), exports);
|
|
40
40
|
__exportStar(require("./OrderLineCreate.js"), exports);
|
|
41
|
+
__exportStar(require("./OrderLineAttributeCreate.js"), exports);
|
|
41
42
|
__exportStar(require("./Signal.js"), exports);
|
|
42
43
|
__exportStar(require("./Error_.js"), exports);
|
|
43
44
|
__exportStar(require("./ApiError.js"), exports);
|
|
45
|
+
__exportStar(require("./EntitlementUsage.js"), exports);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * as Paid from "./api/index.js";
|
|
2
2
|
export { PaidClient } from "./Client.js";
|
|
3
|
-
export { PaidError, PaidTimeoutError } from "./errors/index.js";
|
|
4
3
|
export { PaidEnvironment } from "./environments.js";
|
|
4
|
+
export { PaidError, PaidTimeoutError } from "./errors/index.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -33,12 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.PaidTimeoutError = exports.PaidError = exports.PaidEnvironment = exports.PaidClient = exports.Paid = void 0;
|
|
37
37
|
exports.Paid = __importStar(require("./api/index.js"));
|
|
38
38
|
var Client_js_1 = require("./Client.js");
|
|
39
39
|
Object.defineProperty(exports, "PaidClient", { enumerable: true, get: function () { return Client_js_1.PaidClient; } });
|
|
40
|
+
var environments_js_1 = require("./environments.js");
|
|
41
|
+
Object.defineProperty(exports, "PaidEnvironment", { enumerable: true, get: function () { return environments_js_1.PaidEnvironment; } });
|
|
40
42
|
var index_js_1 = require("./errors/index.js");
|
|
41
43
|
Object.defineProperty(exports, "PaidError", { enumerable: true, get: function () { return index_js_1.PaidError; } });
|
|
42
44
|
Object.defineProperty(exports, "PaidTimeoutError", { enumerable: true, get: function () { return index_js_1.PaidTimeoutError; } });
|
|
43
|
-
var environments_js_1 = require("./environments.js");
|
|
44
|
-
Object.defineProperty(exports, "PaidEnvironment", { enumerable: true, get: function () { return environments_js_1.PaidEnvironment; } });
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.3.0";
|