@paid-ai/paid-node 0.2.0 → 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.
Files changed (65) hide show
  1. package/README.md +180 -39
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/errors/ForbiddenError.d.ts +9 -0
  4. package/dist/cjs/api/errors/ForbiddenError.js +52 -0
  5. package/dist/cjs/api/errors/index.d.ts +1 -0
  6. package/dist/cjs/api/errors/index.js +17 -0
  7. package/dist/cjs/api/index.d.ts +1 -0
  8. package/dist/cjs/api/index.js +1 -0
  9. package/dist/cjs/api/resources/agents/client/Client.d.ts +3 -3
  10. package/dist/cjs/api/resources/agents/client/Client.js +6 -2
  11. package/dist/cjs/api/resources/contacts/client/Client.d.ts +3 -3
  12. package/dist/cjs/api/resources/contacts/client/Client.js +6 -2
  13. package/dist/cjs/api/resources/customers/client/Client.d.ts +14 -3
  14. package/dist/cjs/api/resources/customers/client/Client.js +62 -2
  15. package/dist/cjs/api/resources/orders/client/Client.d.ts +13 -3
  16. package/dist/cjs/api/resources/orders/client/Client.js +16 -2
  17. package/dist/cjs/api/resources/orders/client/requests/OrderCreate.d.ts +10 -0
  18. package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +3 -3
  19. package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +6 -2
  20. package/dist/cjs/api/resources/usage/client/Client.d.ts +3 -3
  21. package/dist/cjs/api/resources/usage/client/Client.js +6 -2
  22. package/dist/cjs/api/types/EntitlementUsage.d.ts +23 -0
  23. package/dist/cjs/api/types/EntitlementUsage.js +5 -0
  24. package/dist/cjs/api/types/OrderLineAttributeCreate.d.ts +12 -0
  25. package/dist/cjs/api/types/OrderLineAttributeCreate.js +5 -0
  26. package/dist/cjs/api/types/OrderLineCreate.d.ts +7 -0
  27. package/dist/cjs/api/types/index.d.ts +2 -0
  28. package/dist/cjs/api/types/index.js +2 -0
  29. package/dist/cjs/index.d.ts +1 -1
  30. package/dist/cjs/index.js +3 -3
  31. package/dist/cjs/version.d.ts +1 -1
  32. package/dist/cjs/version.js +1 -1
  33. package/dist/esm/Client.mjs +2 -2
  34. package/dist/esm/api/errors/ForbiddenError.d.mts +9 -0
  35. package/dist/esm/api/errors/ForbiddenError.mjs +15 -0
  36. package/dist/esm/api/errors/index.d.mts +1 -0
  37. package/dist/esm/api/errors/index.mjs +1 -0
  38. package/dist/esm/api/index.d.mts +1 -0
  39. package/dist/esm/api/index.mjs +1 -0
  40. package/dist/esm/api/resources/agents/client/Client.d.mts +3 -3
  41. package/dist/esm/api/resources/agents/client/Client.mjs +6 -2
  42. package/dist/esm/api/resources/contacts/client/Client.d.mts +3 -3
  43. package/dist/esm/api/resources/contacts/client/Client.mjs +6 -2
  44. package/dist/esm/api/resources/customers/client/Client.d.mts +14 -3
  45. package/dist/esm/api/resources/customers/client/Client.mjs +62 -2
  46. package/dist/esm/api/resources/orders/client/Client.d.mts +13 -3
  47. package/dist/esm/api/resources/orders/client/Client.mjs +16 -2
  48. package/dist/esm/api/resources/orders/client/requests/OrderCreate.d.mts +10 -0
  49. package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +3 -3
  50. package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +6 -2
  51. package/dist/esm/api/resources/usage/client/Client.d.mts +3 -3
  52. package/dist/esm/api/resources/usage/client/Client.mjs +6 -2
  53. package/dist/esm/api/types/EntitlementUsage.d.mts +23 -0
  54. package/dist/esm/api/types/EntitlementUsage.mjs +4 -0
  55. package/dist/esm/api/types/OrderLineAttributeCreate.d.mts +12 -0
  56. package/dist/esm/api/types/OrderLineAttributeCreate.mjs +4 -0
  57. package/dist/esm/api/types/OrderLineCreate.d.mts +7 -0
  58. package/dist/esm/api/types/index.d.mts +2 -0
  59. package/dist/esm/api/types/index.mjs +2 -0
  60. package/dist/esm/index.d.mts +1 -1
  61. package/dist/esm/index.mjs +1 -1
  62. package/dist/esm/version.d.mts +1 -1
  63. package/dist/esm/version.mjs +1 -1
  64. package/package.json +1 -1
  65. package/reference.md +48 -0
@@ -12,6 +12,16 @@ import * as Paid from "../../../../index.mjs";
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: core.Supplier<core.BearerToken>;
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: Lines.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
  }
@@ -16,7 +16,7 @@ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/he
16
16
  import urlJoin from "url-join";
17
17
  import * as errors from "../../../../../../errors/index.mjs";
18
18
  export class Lines {
19
- constructor(_options) {
19
+ constructor(_options = {}) {
20
20
  this._options = _options;
21
21
  }
22
22
  /**
@@ -83,7 +83,11 @@ export class Lines {
83
83
  }
84
84
  _getAuthorizationHeader() {
85
85
  return __awaiter(this, void 0, void 0, function* () {
86
- return `Bearer ${yield core.Supplier.get(this._options.token)}`;
86
+ const bearer = yield core.Supplier.get(this._options.token);
87
+ if (bearer != null) {
88
+ return `Bearer ${bearer}`;
89
+ }
90
+ return undefined;
87
91
  });
88
92
  }
89
93
  }
@@ -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: core.Supplier<core.BearerToken>;
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: Usage.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
  }
@@ -16,7 +16,7 @@ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.
16
16
  import urlJoin from "url-join";
17
17
  import * as errors from "../../../../errors/index.mjs";
18
18
  export class Usage {
19
- constructor(_options) {
19
+ constructor(_options = {}) {
20
20
  this._options = _options;
21
21
  }
22
22
  /**
@@ -74,7 +74,11 @@ export class Usage {
74
74
  }
75
75
  _getAuthorizationHeader() {
76
76
  return __awaiter(this, void 0, void 0, function* () {
77
- return `Bearer ${yield core.Supplier.get(this._options.token)}`;
77
+ const bearer = yield core.Supplier.get(this._options.token);
78
+ if (bearer != null) {
79
+ return `Bearer ${bearer}`;
80
+ }
81
+ return undefined;
78
82
  });
79
83
  }
80
84
  }
@@ -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,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Paid from "../index.mjs";
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
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -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.mjs";
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.mjs";
22
22
  export * from "./PricePoint.mjs";
23
23
  export * from "./Tier.mjs";
24
24
  export * from "./OrderLineCreate.mjs";
25
+ export * from "./OrderLineAttributeCreate.mjs";
25
26
  export * from "./Signal.mjs";
26
27
  export * from "./Error_.mjs";
27
28
  export * from "./ApiError.mjs";
29
+ export * from "./EntitlementUsage.mjs";
@@ -22,6 +22,8 @@ export * from "./OrderLineAttributePricing.mjs";
22
22
  export * from "./PricePoint.mjs";
23
23
  export * from "./Tier.mjs";
24
24
  export * from "./OrderLineCreate.mjs";
25
+ export * from "./OrderLineAttributeCreate.mjs";
25
26
  export * from "./Signal.mjs";
26
27
  export * from "./Error_.mjs";
27
28
  export * from "./ApiError.mjs";
29
+ export * from "./EntitlementUsage.mjs";
@@ -1,4 +1,4 @@
1
1
  export * as Paid from "./api/index.mjs";
2
2
  export { PaidClient } from "./Client.mjs";
3
- export { PaidError, PaidTimeoutError } from "./errors/index.mjs";
4
3
  export { PaidEnvironment } from "./environments.mjs";
4
+ export { PaidError, PaidTimeoutError } from "./errors/index.mjs";
@@ -1,4 +1,4 @@
1
1
  export * as Paid from "./api/index.mjs";
2
2
  export { PaidClient } from "./Client.mjs";
3
- export { PaidError, PaidTimeoutError } from "./errors/index.mjs";
4
3
  export { PaidEnvironment } from "./environments.mjs";
4
+ export { PaidError, PaidTimeoutError } from "./errors/index.mjs";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.2.0";
1
+ export declare const SDK_VERSION = "0.3.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.2.0";
1
+ export const SDK_VERSION = "0.3.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paid-ai/paid-node",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "repository": "https://github.com/paid-ai/paid-node",
6
6
  "type": "commonjs",
package/reference.md CHANGED
@@ -250,6 +250,54 @@ await client.customers.delete("customerId");
250
250
  </dl>
251
251
  </details>
252
252
 
253
+ <details><summary><code>client.customers.<a href="/src/api/resources/customers/client/Client.ts">getEntitlements</a>(customerId) -> Paid.EntitlementUsage[]</code></summary>
254
+ <dl>
255
+ <dd>
256
+
257
+ #### 🔌 Usage
258
+
259
+ <dl>
260
+ <dd>
261
+
262
+ <dl>
263
+ <dd>
264
+
265
+ ```typescript
266
+ await client.customers.getEntitlements("customerId");
267
+ ```
268
+
269
+ </dd>
270
+ </dl>
271
+ </dd>
272
+ </dl>
273
+
274
+ #### ⚙️ Parameters
275
+
276
+ <dl>
277
+ <dd>
278
+
279
+ <dl>
280
+ <dd>
281
+
282
+ **customerId:** `string` — The customer ID
283
+
284
+ </dd>
285
+ </dl>
286
+
287
+ <dl>
288
+ <dd>
289
+
290
+ **requestOptions:** `Customers.RequestOptions`
291
+
292
+ </dd>
293
+ </dl>
294
+ </dd>
295
+ </dl>
296
+
297
+ </dd>
298
+ </dl>
299
+ </details>
300
+
253
301
  <details><summary><code>client.customers.<a href="/src/api/resources/customers/client/Client.ts">getByExternalId</a>(externalId) -> Paid.Customer</code></summary>
254
302
  <dl>
255
303
  <dd>