@paid-ai/paid-node 1.2.1 → 1.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 (152) hide show
  1. package/dist/cjs/Client.d.ts +3 -0
  2. package/dist/cjs/Client.js +7 -2
  3. package/dist/cjs/api/errors/ConflictError.d.ts +6 -0
  4. package/dist/cjs/api/errors/ConflictError.js +50 -0
  5. package/dist/cjs/api/errors/index.d.ts +1 -0
  6. package/dist/cjs/api/errors/index.js +1 -0
  7. package/dist/cjs/api/resources/checkouts/client/Client.d.ts +1 -1
  8. package/dist/cjs/api/resources/customers/client/Client.d.ts +19 -0
  9. package/dist/cjs/api/resources/customers/client/Client.js +86 -0
  10. package/dist/cjs/api/resources/customers/client/requests/UpsertCustomerUserRequest.d.ts +16 -0
  11. package/dist/cjs/api/resources/customers/client/requests/UpsertCustomerUserRequest.js +3 -0
  12. package/dist/cjs/api/resources/customers/client/requests/index.d.ts +1 -0
  13. package/dist/cjs/api/resources/index.d.ts +4 -0
  14. package/dist/cjs/api/resources/index.js +5 -1
  15. package/dist/cjs/api/resources/orders/client/Client.d.ts +60 -0
  16. package/dist/cjs/api/resources/orders/client/Client.js +242 -0
  17. package/dist/cjs/api/resources/orders/client/requests/BatchSeatAssignmentsRequest.d.ts +22 -0
  18. package/dist/cjs/api/resources/orders/client/requests/BatchSeatAssignmentsRequest.js +3 -0
  19. package/dist/cjs/api/resources/orders/client/requests/ListOrderSeatsRequest.d.ts +14 -0
  20. package/dist/cjs/api/resources/orders/client/requests/ListOrderSeatsRequest.js +3 -0
  21. package/dist/cjs/api/resources/orders/client/requests/UpdateSeatAssignmentRequest.d.ts +12 -0
  22. package/dist/cjs/api/resources/orders/client/requests/UpdateSeatAssignmentRequest.js +3 -0
  23. package/dist/cjs/api/resources/orders/client/requests/index.d.ts +3 -0
  24. package/dist/cjs/api/resources/orders/index.d.ts +1 -0
  25. package/dist/cjs/api/resources/orders/index.js +1 -0
  26. package/dist/cjs/api/resources/orders/types/ListOrderSeatsRequestStatus.d.ts +5 -0
  27. package/dist/cjs/api/resources/orders/types/ListOrderSeatsRequestStatus.js +8 -0
  28. package/dist/cjs/api/resources/orders/types/index.d.ts +1 -0
  29. package/dist/cjs/api/resources/orders/types/index.js +17 -0
  30. package/dist/cjs/api/resources/webhooks/client/Client.d.ts +63 -0
  31. package/dist/cjs/api/resources/webhooks/client/Client.js +282 -0
  32. package/dist/cjs/api/resources/webhooks/client/index.d.ts +1 -0
  33. package/dist/cjs/api/resources/webhooks/client/index.js +17 -0
  34. package/dist/cjs/api/resources/webhooks/client/requests/TestWebhookRequest.d.ts +10 -0
  35. package/dist/cjs/api/resources/webhooks/client/requests/TestWebhookRequest.js +3 -0
  36. package/dist/cjs/api/resources/webhooks/client/requests/UpdateWebhookRequest.d.ts +14 -0
  37. package/dist/cjs/api/resources/webhooks/client/requests/UpdateWebhookRequest.js +3 -0
  38. package/dist/cjs/api/resources/webhooks/client/requests/index.d.ts +2 -0
  39. package/dist/cjs/api/resources/webhooks/client/requests/index.js +2 -0
  40. package/dist/cjs/api/resources/webhooks/index.d.ts +2 -0
  41. package/dist/cjs/api/resources/webhooks/index.js +18 -0
  42. package/dist/cjs/api/resources/webhooks/types/TestWebhookRequestWebhookName.d.ts +12 -0
  43. package/dist/cjs/api/resources/webhooks/types/TestWebhookRequestWebhookName.js +15 -0
  44. package/dist/cjs/api/resources/webhooks/types/UpdateWebhookRequestWebhookName.d.ts +12 -0
  45. package/dist/cjs/api/resources/webhooks/types/UpdateWebhookRequestWebhookName.js +15 -0
  46. package/dist/cjs/api/resources/webhooks/types/index.d.ts +2 -0
  47. package/dist/cjs/api/resources/webhooks/types/index.js +18 -0
  48. package/dist/cjs/api/types/BatchSeatAssignmentsResponse.d.ts +4 -0
  49. package/dist/cjs/api/types/BatchSeatAssignmentsResponse.js +3 -0
  50. package/dist/cjs/api/types/CheckoutDetails.d.ts +21 -0
  51. package/dist/cjs/api/types/CheckoutDetails.js +3 -0
  52. package/dist/cjs/api/types/CustomerUser.d.ts +13 -0
  53. package/dist/cjs/api/types/CustomerUser.js +3 -0
  54. package/dist/cjs/api/types/CustomerUserStatus.d.ts +5 -0
  55. package/dist/cjs/api/types/CustomerUserStatus.js +8 -0
  56. package/dist/cjs/api/types/OrderSeat.d.ts +10 -0
  57. package/dist/cjs/api/types/OrderSeat.js +3 -0
  58. package/dist/cjs/api/types/OrderSeatListResponse.d.ts +5 -0
  59. package/dist/cjs/api/types/OrderSeatListResponse.js +3 -0
  60. package/dist/cjs/api/types/SeatAssignee.d.ts +5 -0
  61. package/dist/cjs/api/types/SeatAssignee.js +3 -0
  62. package/dist/cjs/api/types/SeatAssignmentStatus.d.ts +5 -0
  63. package/dist/cjs/api/types/SeatAssignmentStatus.js +8 -0
  64. package/dist/cjs/api/types/Webhook.d.ts +24 -0
  65. package/dist/cjs/api/types/Webhook.js +18 -0
  66. package/dist/cjs/api/types/WebhookDeliveryStatus.d.ts +5 -0
  67. package/dist/cjs/api/types/WebhookDeliveryStatus.js +8 -0
  68. package/dist/cjs/api/types/WebhookListResponse.d.ts +4 -0
  69. package/dist/cjs/api/types/WebhookListResponse.js +3 -0
  70. package/dist/cjs/api/types/WebhookTestResponse.d.ts +3 -0
  71. package/dist/cjs/api/types/WebhookTestResponse.js +3 -0
  72. package/dist/cjs/api/types/index.d.ts +12 -0
  73. package/dist/cjs/api/types/index.js +12 -0
  74. package/dist/cjs/version.d.ts +1 -1
  75. package/dist/cjs/version.js +1 -1
  76. package/dist/esm/Client.d.mts +3 -0
  77. package/dist/esm/Client.mjs +7 -2
  78. package/dist/esm/api/errors/ConflictError.d.mts +6 -0
  79. package/dist/esm/api/errors/ConflictError.mjs +13 -0
  80. package/dist/esm/api/errors/index.d.mts +1 -0
  81. package/dist/esm/api/errors/index.mjs +1 -0
  82. package/dist/esm/api/resources/checkouts/client/Client.d.mts +1 -1
  83. package/dist/esm/api/resources/customers/client/Client.d.mts +19 -0
  84. package/dist/esm/api/resources/customers/client/Client.mjs +86 -0
  85. package/dist/esm/api/resources/customers/client/requests/UpsertCustomerUserRequest.d.mts +16 -0
  86. package/dist/esm/api/resources/customers/client/requests/UpsertCustomerUserRequest.mjs +2 -0
  87. package/dist/esm/api/resources/customers/client/requests/index.d.mts +1 -0
  88. package/dist/esm/api/resources/index.d.mts +4 -0
  89. package/dist/esm/api/resources/index.mjs +4 -0
  90. package/dist/esm/api/resources/orders/client/Client.d.mts +60 -0
  91. package/dist/esm/api/resources/orders/client/Client.mjs +242 -0
  92. package/dist/esm/api/resources/orders/client/requests/BatchSeatAssignmentsRequest.d.mts +22 -0
  93. package/dist/esm/api/resources/orders/client/requests/BatchSeatAssignmentsRequest.mjs +2 -0
  94. package/dist/esm/api/resources/orders/client/requests/ListOrderSeatsRequest.d.mts +14 -0
  95. package/dist/esm/api/resources/orders/client/requests/ListOrderSeatsRequest.mjs +2 -0
  96. package/dist/esm/api/resources/orders/client/requests/UpdateSeatAssignmentRequest.d.mts +12 -0
  97. package/dist/esm/api/resources/orders/client/requests/UpdateSeatAssignmentRequest.mjs +2 -0
  98. package/dist/esm/api/resources/orders/client/requests/index.d.mts +3 -0
  99. package/dist/esm/api/resources/orders/index.d.mts +1 -0
  100. package/dist/esm/api/resources/orders/index.mjs +1 -0
  101. package/dist/esm/api/resources/orders/types/ListOrderSeatsRequestStatus.d.mts +5 -0
  102. package/dist/esm/api/resources/orders/types/ListOrderSeatsRequestStatus.mjs +5 -0
  103. package/dist/esm/api/resources/orders/types/index.d.mts +1 -0
  104. package/dist/esm/api/resources/orders/types/index.mjs +1 -0
  105. package/dist/esm/api/resources/webhooks/client/Client.d.mts +63 -0
  106. package/dist/esm/api/resources/webhooks/client/Client.mjs +245 -0
  107. package/dist/esm/api/resources/webhooks/client/index.d.mts +1 -0
  108. package/dist/esm/api/resources/webhooks/client/index.mjs +1 -0
  109. package/dist/esm/api/resources/webhooks/client/requests/TestWebhookRequest.d.mts +10 -0
  110. package/dist/esm/api/resources/webhooks/client/requests/TestWebhookRequest.mjs +2 -0
  111. package/dist/esm/api/resources/webhooks/client/requests/UpdateWebhookRequest.d.mts +14 -0
  112. package/dist/esm/api/resources/webhooks/client/requests/UpdateWebhookRequest.mjs +2 -0
  113. package/dist/esm/api/resources/webhooks/client/requests/index.d.mts +2 -0
  114. package/dist/esm/api/resources/webhooks/client/requests/index.mjs +1 -0
  115. package/dist/esm/api/resources/webhooks/index.d.mts +2 -0
  116. package/dist/esm/api/resources/webhooks/index.mjs +2 -0
  117. package/dist/esm/api/resources/webhooks/types/TestWebhookRequestWebhookName.d.mts +12 -0
  118. package/dist/esm/api/resources/webhooks/types/TestWebhookRequestWebhookName.mjs +12 -0
  119. package/dist/esm/api/resources/webhooks/types/UpdateWebhookRequestWebhookName.d.mts +12 -0
  120. package/dist/esm/api/resources/webhooks/types/UpdateWebhookRequestWebhookName.mjs +12 -0
  121. package/dist/esm/api/resources/webhooks/types/index.d.mts +2 -0
  122. package/dist/esm/api/resources/webhooks/types/index.mjs +2 -0
  123. package/dist/esm/api/types/BatchSeatAssignmentsResponse.d.mts +4 -0
  124. package/dist/esm/api/types/BatchSeatAssignmentsResponse.mjs +2 -0
  125. package/dist/esm/api/types/CheckoutDetails.d.mts +21 -0
  126. package/dist/esm/api/types/CheckoutDetails.mjs +2 -0
  127. package/dist/esm/api/types/CustomerUser.d.mts +13 -0
  128. package/dist/esm/api/types/CustomerUser.mjs +2 -0
  129. package/dist/esm/api/types/CustomerUserStatus.d.mts +5 -0
  130. package/dist/esm/api/types/CustomerUserStatus.mjs +5 -0
  131. package/dist/esm/api/types/OrderSeat.d.mts +10 -0
  132. package/dist/esm/api/types/OrderSeat.mjs +2 -0
  133. package/dist/esm/api/types/OrderSeatListResponse.d.mts +5 -0
  134. package/dist/esm/api/types/OrderSeatListResponse.mjs +2 -0
  135. package/dist/esm/api/types/SeatAssignee.d.mts +5 -0
  136. package/dist/esm/api/types/SeatAssignee.mjs +2 -0
  137. package/dist/esm/api/types/SeatAssignmentStatus.d.mts +5 -0
  138. package/dist/esm/api/types/SeatAssignmentStatus.mjs +5 -0
  139. package/dist/esm/api/types/Webhook.d.mts +24 -0
  140. package/dist/esm/api/types/Webhook.mjs +15 -0
  141. package/dist/esm/api/types/WebhookDeliveryStatus.d.mts +5 -0
  142. package/dist/esm/api/types/WebhookDeliveryStatus.mjs +5 -0
  143. package/dist/esm/api/types/WebhookListResponse.d.mts +4 -0
  144. package/dist/esm/api/types/WebhookListResponse.mjs +2 -0
  145. package/dist/esm/api/types/WebhookTestResponse.d.mts +3 -0
  146. package/dist/esm/api/types/WebhookTestResponse.mjs +2 -0
  147. package/dist/esm/api/types/index.d.mts +12 -0
  148. package/dist/esm/api/types/index.mjs +12 -0
  149. package/dist/esm/version.d.mts +1 -1
  150. package/dist/esm/version.mjs +1 -1
  151. package/package.json +1 -1
  152. package/reference.md +452 -1
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id",
5
+ * assignments: [{
6
+ * seatId: "seatId"
7
+ * }]
8
+ * }
9
+ */
10
+ export interface BatchSeatAssignmentsRequest {
11
+ id: string;
12
+ assignments: BatchSeatAssignmentsRequest.Assignments.Item[];
13
+ }
14
+ export declare namespace BatchSeatAssignmentsRequest {
15
+ type Assignments = Assignments.Item[];
16
+ namespace Assignments {
17
+ interface Item {
18
+ seatId: string;
19
+ userExternalId: string | null;
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import type * as Paid from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {
5
+ * id: "id"
6
+ * }
7
+ */
8
+ export interface ListOrderSeatsRequest {
9
+ id: string;
10
+ limit?: number;
11
+ offset?: number;
12
+ productExternalId?: string;
13
+ status?: Paid.ListOrderSeatsRequestStatus;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id",
5
+ * seatId: "seatId"
6
+ * }
7
+ */
8
+ export interface UpdateSeatAssignmentRequest {
9
+ id: string;
10
+ seatId: string;
11
+ userExternalId: string | null;
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,9 @@
1
+ export type { BatchSeatAssignmentsRequest } from "./BatchSeatAssignmentsRequest.js";
1
2
  export type { CreateOrderRequest } from "./CreateOrderRequest.js";
2
3
  export type { DeleteOrderByIdRequest } from "./DeleteOrderByIdRequest.js";
3
4
  export type { GetOrderByIdRequest } from "./GetOrderByIdRequest.js";
4
5
  export type { GetOrderLinesRequest } from "./GetOrderLinesRequest.js";
6
+ export type { ListOrderSeatsRequest } from "./ListOrderSeatsRequest.js";
5
7
  export type { ListOrdersRequest } from "./ListOrdersRequest.js";
6
8
  export type { UpdateOrderRequest } from "./UpdateOrderRequest.js";
9
+ export type { UpdateSeatAssignmentRequest } from "./UpdateSeatAssignmentRequest.js";
@@ -1 +1,2 @@
1
1
  export * from "./client/index.js";
2
+ export * from "./types/index.js";
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./client/index.js"), exports);
18
+ __exportStar(require("./types/index.js"), exports);
@@ -0,0 +1,5 @@
1
+ export declare const ListOrderSeatsRequestStatus: {
2
+ readonly Assigned: "assigned";
3
+ readonly Unassigned: "unassigned";
4
+ };
5
+ export type ListOrderSeatsRequestStatus = (typeof ListOrderSeatsRequestStatus)[keyof typeof ListOrderSeatsRequestStatus];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ListOrderSeatsRequestStatus = void 0;
5
+ exports.ListOrderSeatsRequestStatus = {
6
+ Assigned: "assigned",
7
+ Unassigned: "unassigned",
8
+ };
@@ -0,0 +1 @@
1
+ export * from "./ListOrderSeatsRequestStatus.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("./ListOrderSeatsRequestStatus.js"), exports);
@@ -0,0 +1,63 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import * as core from "../../../../core/index.js";
3
+ import * as Paid from "../../../index.js";
4
+ export declare namespace Webhooks {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class Webhooks {
11
+ protected readonly _options: Webhooks.Options;
12
+ constructor(_options: Webhooks.Options);
13
+ /**
14
+ * List customer-facing billing webhooks for the authenticated organization.
15
+ *
16
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
17
+ *
18
+ * @throws {@link Paid.ForbiddenError}
19
+ * @throws {@link Paid.InternalServerError}
20
+ *
21
+ * @example
22
+ * await client.webhooks.listWebhooks()
23
+ */
24
+ listWebhooks(requestOptions?: Webhooks.RequestOptions): core.HttpResponsePromise<Paid.WebhookListResponse>;
25
+ private __listWebhooks;
26
+ /**
27
+ * Enable or disable a webhook and configure the destination URL for the authenticated organization.
28
+ *
29
+ * @param {Paid.UpdateWebhookRequest} request
30
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
31
+ *
32
+ * @throws {@link Paid.BadRequestError}
33
+ * @throws {@link Paid.ForbiddenError}
34
+ * @throws {@link Paid.NotFoundError}
35
+ * @throws {@link Paid.InternalServerError}
36
+ *
37
+ * @example
38
+ * await client.webhooks.updateWebhook({
39
+ * webhookName: "billing-invoice-created"
40
+ * })
41
+ */
42
+ updateWebhook(request: Paid.UpdateWebhookRequest, requestOptions?: Webhooks.RequestOptions): core.HttpResponsePromise<Paid.Webhook>;
43
+ private __updateWebhook;
44
+ /**
45
+ * Send a synthetic webhook delivery to the configured destination for this webhook.
46
+ *
47
+ * @param {Paid.TestWebhookRequest} request
48
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
49
+ *
50
+ * @throws {@link Paid.BadRequestError}
51
+ * @throws {@link Paid.ForbiddenError}
52
+ * @throws {@link Paid.NotFoundError}
53
+ * @throws {@link Paid.InternalServerError}
54
+ *
55
+ * @example
56
+ * await client.webhooks.testWebhook({
57
+ * webhookName: "billing-invoice-created"
58
+ * })
59
+ */
60
+ testWebhook(request: Paid.TestWebhookRequest, requestOptions?: Webhooks.RequestOptions): core.HttpResponsePromise<Paid.WebhookTestResponse>;
61
+ private __testWebhook;
62
+ protected _getAuthorizationHeader(): Promise<string>;
63
+ }
@@ -0,0 +1,282 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __rest = (this && this.__rest) || function (s, e) {
46
+ var t = {};
47
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
48
+ t[p] = s[p];
49
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
50
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
51
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
52
+ t[p[i]] = s[p[i]];
53
+ }
54
+ return t;
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.Webhooks = void 0;
58
+ const headers_js_1 = require("../../../../core/headers.js");
59
+ const core = __importStar(require("../../../../core/index.js"));
60
+ const environments = __importStar(require("../../../../environments.js"));
61
+ const errors = __importStar(require("../../../../errors/index.js"));
62
+ const Paid = __importStar(require("../../../index.js"));
63
+ class Webhooks {
64
+ constructor(_options) {
65
+ this._options = _options;
66
+ }
67
+ /**
68
+ * List customer-facing billing webhooks for the authenticated organization.
69
+ *
70
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
71
+ *
72
+ * @throws {@link Paid.ForbiddenError}
73
+ * @throws {@link Paid.InternalServerError}
74
+ *
75
+ * @example
76
+ * await client.webhooks.listWebhooks()
77
+ */
78
+ listWebhooks(requestOptions) {
79
+ return core.HttpResponsePromise.fromPromise(this.__listWebhooks(requestOptions));
80
+ }
81
+ __listWebhooks(requestOptions) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ var _a, _b, _c, _d, _e, _f, _g, _h;
84
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
85
+ const _response = yield core.fetcher({
86
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Default, "webhooks/"),
87
+ method: "GET",
88
+ headers: _headers,
89
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
90
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
91
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
92
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
93
+ });
94
+ if (_response.ok) {
95
+ return { data: _response.body, rawResponse: _response.rawResponse };
96
+ }
97
+ if (_response.error.reason === "status-code") {
98
+ switch (_response.error.statusCode) {
99
+ case 403:
100
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
101
+ case 500:
102
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
103
+ default:
104
+ throw new errors.PaidError({
105
+ statusCode: _response.error.statusCode,
106
+ body: _response.error.body,
107
+ rawResponse: _response.rawResponse,
108
+ });
109
+ }
110
+ }
111
+ switch (_response.error.reason) {
112
+ case "non-json":
113
+ throw new errors.PaidError({
114
+ statusCode: _response.error.statusCode,
115
+ body: _response.error.rawBody,
116
+ rawResponse: _response.rawResponse,
117
+ });
118
+ case "timeout":
119
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /webhooks/.");
120
+ case "unknown":
121
+ throw new errors.PaidError({
122
+ message: _response.error.errorMessage,
123
+ rawResponse: _response.rawResponse,
124
+ });
125
+ }
126
+ });
127
+ }
128
+ /**
129
+ * Enable or disable a webhook and configure the destination URL for the authenticated organization.
130
+ *
131
+ * @param {Paid.UpdateWebhookRequest} request
132
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
133
+ *
134
+ * @throws {@link Paid.BadRequestError}
135
+ * @throws {@link Paid.ForbiddenError}
136
+ * @throws {@link Paid.NotFoundError}
137
+ * @throws {@link Paid.InternalServerError}
138
+ *
139
+ * @example
140
+ * await client.webhooks.updateWebhook({
141
+ * webhookName: "billing-invoice-created"
142
+ * })
143
+ */
144
+ updateWebhook(request, requestOptions) {
145
+ return core.HttpResponsePromise.fromPromise(this.__updateWebhook(request, requestOptions));
146
+ }
147
+ __updateWebhook(request, requestOptions) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ var _a, _b, _c, _d, _e, _f, _g, _h;
150
+ const { webhookName } = request, _body = __rest(request, ["webhookName"]);
151
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
152
+ const _response = yield core.fetcher({
153
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Default, `webhooks/${core.url.encodePathParam(webhookName)}`),
154
+ method: "PATCH",
155
+ headers: _headers,
156
+ contentType: "application/json",
157
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
158
+ requestType: "json",
159
+ body: _body,
160
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
161
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
162
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
163
+ });
164
+ if (_response.ok) {
165
+ return { data: _response.body, rawResponse: _response.rawResponse };
166
+ }
167
+ if (_response.error.reason === "status-code") {
168
+ switch (_response.error.statusCode) {
169
+ case 400:
170
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
171
+ case 403:
172
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
173
+ case 404:
174
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
175
+ case 500:
176
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
177
+ default:
178
+ throw new errors.PaidError({
179
+ statusCode: _response.error.statusCode,
180
+ body: _response.error.body,
181
+ rawResponse: _response.rawResponse,
182
+ });
183
+ }
184
+ }
185
+ switch (_response.error.reason) {
186
+ case "non-json":
187
+ throw new errors.PaidError({
188
+ statusCode: _response.error.statusCode,
189
+ body: _response.error.rawBody,
190
+ rawResponse: _response.rawResponse,
191
+ });
192
+ case "timeout":
193
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling PATCH /webhooks/{webhookName}.");
194
+ case "unknown":
195
+ throw new errors.PaidError({
196
+ message: _response.error.errorMessage,
197
+ rawResponse: _response.rawResponse,
198
+ });
199
+ }
200
+ });
201
+ }
202
+ /**
203
+ * Send a synthetic webhook delivery to the configured destination for this webhook.
204
+ *
205
+ * @param {Paid.TestWebhookRequest} request
206
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
207
+ *
208
+ * @throws {@link Paid.BadRequestError}
209
+ * @throws {@link Paid.ForbiddenError}
210
+ * @throws {@link Paid.NotFoundError}
211
+ * @throws {@link Paid.InternalServerError}
212
+ *
213
+ * @example
214
+ * await client.webhooks.testWebhook({
215
+ * webhookName: "billing-invoice-created"
216
+ * })
217
+ */
218
+ testWebhook(request, requestOptions) {
219
+ return core.HttpResponsePromise.fromPromise(this.__testWebhook(request, requestOptions));
220
+ }
221
+ __testWebhook(request, requestOptions) {
222
+ return __awaiter(this, void 0, void 0, function* () {
223
+ var _a, _b, _c, _d, _e, _f, _g, _h;
224
+ const { webhookName } = request, _body = __rest(request, ["webhookName"]);
225
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
226
+ const _response = yield core.fetcher({
227
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Default, `webhooks/${core.url.encodePathParam(webhookName)}/test`),
228
+ method: "POST",
229
+ headers: _headers,
230
+ contentType: "application/json",
231
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
232
+ requestType: "json",
233
+ body: _body,
234
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
235
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
236
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
237
+ });
238
+ if (_response.ok) {
239
+ return { data: _response.body, rawResponse: _response.rawResponse };
240
+ }
241
+ if (_response.error.reason === "status-code") {
242
+ switch (_response.error.statusCode) {
243
+ case 400:
244
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
245
+ case 403:
246
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
247
+ case 404:
248
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
249
+ case 500:
250
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
251
+ default:
252
+ throw new errors.PaidError({
253
+ statusCode: _response.error.statusCode,
254
+ body: _response.error.body,
255
+ rawResponse: _response.rawResponse,
256
+ });
257
+ }
258
+ }
259
+ switch (_response.error.reason) {
260
+ case "non-json":
261
+ throw new errors.PaidError({
262
+ statusCode: _response.error.statusCode,
263
+ body: _response.error.rawBody,
264
+ rawResponse: _response.rawResponse,
265
+ });
266
+ case "timeout":
267
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /webhooks/{webhookName}/test.");
268
+ case "unknown":
269
+ throw new errors.PaidError({
270
+ message: _response.error.errorMessage,
271
+ rawResponse: _response.rawResponse,
272
+ });
273
+ }
274
+ });
275
+ }
276
+ _getAuthorizationHeader() {
277
+ return __awaiter(this, void 0, void 0, function* () {
278
+ return `Bearer ${yield core.Supplier.get(this._options.token)}`;
279
+ });
280
+ }
281
+ }
282
+ exports.Webhooks = Webhooks;
@@ -0,0 +1 @@
1
+ export * from "./requests/index.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("./requests/index.js"), exports);
@@ -0,0 +1,10 @@
1
+ import type * as Paid from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {
5
+ * webhookName: "billing-invoice-created"
6
+ * }
7
+ */
8
+ export interface TestWebhookRequest {
9
+ webhookName: Paid.TestWebhookRequestWebhookName;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import type * as Paid from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {
5
+ * webhookName: "billing-invoice-created"
6
+ * }
7
+ */
8
+ export interface UpdateWebhookRequest {
9
+ webhookName: Paid.UpdateWebhookRequestWebhookName;
10
+ /** Whether the webhook is enabled for delivery. */
11
+ enabled?: boolean;
12
+ /** The HTTPS endpoint Paid should deliver this webhook to. Set to null to clear it while disabled. */
13
+ url?: string | null;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export type { TestWebhookRequest } from "./TestWebhookRequest.js";
2
+ export type { UpdateWebhookRequest } from "./UpdateWebhookRequest.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.js";
2
+ export * from "./types/index.js";
@@ -0,0 +1,18 @@
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("./client/index.js"), exports);
18
+ __exportStar(require("./types/index.js"), exports);
@@ -0,0 +1,12 @@
1
+ export declare const TestWebhookRequestWebhookName: {
2
+ readonly BillingInvoiceCreated: "billing-invoice-created";
3
+ readonly BillingInvoicePaid: "billing-invoice-paid";
4
+ readonly BillingCheckoutCreated: "billing-checkout-created";
5
+ readonly BillingCheckoutCompleted: "billing-checkout-completed";
6
+ readonly BillingCheckoutExpired: "billing-checkout-expired";
7
+ readonly BillingPaymentSucceeded: "billing-payment-succeeded";
8
+ readonly BillingPaymentFailed: "billing-payment-failed";
9
+ readonly BillingCreditsDepleted: "billing-credits-depleted";
10
+ readonly BillingOverageIncurred: "billing-overage-incurred";
11
+ };
12
+ export type TestWebhookRequestWebhookName = (typeof TestWebhookRequestWebhookName)[keyof typeof TestWebhookRequestWebhookName];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TestWebhookRequestWebhookName = void 0;
5
+ exports.TestWebhookRequestWebhookName = {
6
+ BillingInvoiceCreated: "billing-invoice-created",
7
+ BillingInvoicePaid: "billing-invoice-paid",
8
+ BillingCheckoutCreated: "billing-checkout-created",
9
+ BillingCheckoutCompleted: "billing-checkout-completed",
10
+ BillingCheckoutExpired: "billing-checkout-expired",
11
+ BillingPaymentSucceeded: "billing-payment-succeeded",
12
+ BillingPaymentFailed: "billing-payment-failed",
13
+ BillingCreditsDepleted: "billing-credits-depleted",
14
+ BillingOverageIncurred: "billing-overage-incurred",
15
+ };
@@ -0,0 +1,12 @@
1
+ export declare const UpdateWebhookRequestWebhookName: {
2
+ readonly BillingInvoiceCreated: "billing-invoice-created";
3
+ readonly BillingInvoicePaid: "billing-invoice-paid";
4
+ readonly BillingCheckoutCreated: "billing-checkout-created";
5
+ readonly BillingCheckoutCompleted: "billing-checkout-completed";
6
+ readonly BillingCheckoutExpired: "billing-checkout-expired";
7
+ readonly BillingPaymentSucceeded: "billing-payment-succeeded";
8
+ readonly BillingPaymentFailed: "billing-payment-failed";
9
+ readonly BillingCreditsDepleted: "billing-credits-depleted";
10
+ readonly BillingOverageIncurred: "billing-overage-incurred";
11
+ };
12
+ export type UpdateWebhookRequestWebhookName = (typeof UpdateWebhookRequestWebhookName)[keyof typeof UpdateWebhookRequestWebhookName];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.UpdateWebhookRequestWebhookName = void 0;
5
+ exports.UpdateWebhookRequestWebhookName = {
6
+ BillingInvoiceCreated: "billing-invoice-created",
7
+ BillingInvoicePaid: "billing-invoice-paid",
8
+ BillingCheckoutCreated: "billing-checkout-created",
9
+ BillingCheckoutCompleted: "billing-checkout-completed",
10
+ BillingCheckoutExpired: "billing-checkout-expired",
11
+ BillingPaymentSucceeded: "billing-payment-succeeded",
12
+ BillingPaymentFailed: "billing-payment-failed",
13
+ BillingCreditsDepleted: "billing-credits-depleted",
14
+ BillingOverageIncurred: "billing-overage-incurred",
15
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./TestWebhookRequestWebhookName.js";
2
+ export * from "./UpdateWebhookRequestWebhookName.js";