@paid-ai/paid-node 1.2.0 → 1.2.1

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 (70) hide show
  1. package/dist/cjs/Client.d.ts +3 -0
  2. package/dist/cjs/Client.js +7 -2
  3. package/dist/cjs/api/resources/checkouts/client/requests/CreateCheckoutRequest.d.ts +2 -0
  4. package/dist/cjs/api/resources/customers/client/Client.d.ts +2 -0
  5. package/dist/cjs/api/resources/customers/client/Client.js +6 -0
  6. package/dist/cjs/api/resources/index.d.ts +2 -0
  7. package/dist/cjs/api/resources/index.js +3 -1
  8. package/dist/cjs/api/resources/valueReceipts/client/Client.d.ts +75 -0
  9. package/dist/cjs/api/resources/valueReceipts/client/Client.js +347 -0
  10. package/dist/cjs/api/resources/valueReceipts/client/index.d.ts +1 -0
  11. package/dist/cjs/api/resources/valueReceipts/client/index.js +17 -0
  12. package/dist/cjs/api/resources/valueReceipts/client/requests/GetValueReceiptByIdRequest.d.ts +9 -0
  13. package/dist/cjs/api/resources/valueReceipts/client/requests/GetValueReceiptByIdRequest.js +3 -0
  14. package/dist/cjs/api/resources/valueReceipts/client/requests/ListValueReceiptsRequest.d.ts +10 -0
  15. package/dist/cjs/api/resources/valueReceipts/client/requests/ListValueReceiptsRequest.js +3 -0
  16. package/dist/cjs/api/resources/valueReceipts/client/requests/PublishValueReceiptBody.d.ts +10 -0
  17. package/dist/cjs/api/resources/valueReceipts/client/requests/PublishValueReceiptBody.js +3 -0
  18. package/dist/cjs/api/resources/valueReceipts/client/requests/UnpublishValueReceiptRequest.d.ts +9 -0
  19. package/dist/cjs/api/resources/valueReceipts/client/requests/UnpublishValueReceiptRequest.js +3 -0
  20. package/dist/cjs/api/resources/valueReceipts/client/requests/index.d.ts +4 -0
  21. package/dist/cjs/api/resources/valueReceipts/client/requests/index.js +2 -0
  22. package/dist/cjs/api/resources/valueReceipts/index.d.ts +1 -0
  23. package/dist/cjs/api/resources/valueReceipts/index.js +17 -0
  24. package/dist/cjs/api/types/Checkout.d.ts +1 -0
  25. package/dist/cjs/api/types/ValueReceiptDetail.d.ts +19 -0
  26. package/dist/cjs/api/types/ValueReceiptDetail.js +3 -0
  27. package/dist/cjs/api/types/ValueReceiptListResponse.d.ts +5 -0
  28. package/dist/cjs/api/types/ValueReceiptListResponse.js +3 -0
  29. package/dist/cjs/api/types/ValueReceiptSummary.d.ts +16 -0
  30. package/dist/cjs/api/types/ValueReceiptSummary.js +3 -0
  31. package/dist/cjs/api/types/index.d.ts +3 -0
  32. package/dist/cjs/api/types/index.js +3 -0
  33. package/dist/cjs/version.d.ts +1 -1
  34. package/dist/cjs/version.js +1 -1
  35. package/dist/esm/Client.d.mts +3 -0
  36. package/dist/esm/Client.mjs +7 -2
  37. package/dist/esm/api/resources/checkouts/client/requests/CreateCheckoutRequest.d.mts +2 -0
  38. package/dist/esm/api/resources/customers/client/Client.d.mts +2 -0
  39. package/dist/esm/api/resources/customers/client/Client.mjs +6 -0
  40. package/dist/esm/api/resources/index.d.mts +2 -0
  41. package/dist/esm/api/resources/index.mjs +2 -0
  42. package/dist/esm/api/resources/valueReceipts/client/Client.d.mts +75 -0
  43. package/dist/esm/api/resources/valueReceipts/client/Client.mjs +310 -0
  44. package/dist/esm/api/resources/valueReceipts/client/index.d.mts +1 -0
  45. package/dist/esm/api/resources/valueReceipts/client/index.mjs +1 -0
  46. package/dist/esm/api/resources/valueReceipts/client/requests/GetValueReceiptByIdRequest.d.mts +9 -0
  47. package/dist/esm/api/resources/valueReceipts/client/requests/GetValueReceiptByIdRequest.mjs +2 -0
  48. package/dist/esm/api/resources/valueReceipts/client/requests/ListValueReceiptsRequest.d.mts +10 -0
  49. package/dist/esm/api/resources/valueReceipts/client/requests/ListValueReceiptsRequest.mjs +2 -0
  50. package/dist/esm/api/resources/valueReceipts/client/requests/PublishValueReceiptBody.d.mts +10 -0
  51. package/dist/esm/api/resources/valueReceipts/client/requests/PublishValueReceiptBody.mjs +2 -0
  52. package/dist/esm/api/resources/valueReceipts/client/requests/UnpublishValueReceiptRequest.d.mts +9 -0
  53. package/dist/esm/api/resources/valueReceipts/client/requests/UnpublishValueReceiptRequest.mjs +2 -0
  54. package/dist/esm/api/resources/valueReceipts/client/requests/index.d.mts +4 -0
  55. package/dist/esm/api/resources/valueReceipts/client/requests/index.mjs +1 -0
  56. package/dist/esm/api/resources/valueReceipts/index.d.mts +1 -0
  57. package/dist/esm/api/resources/valueReceipts/index.mjs +1 -0
  58. package/dist/esm/api/types/Checkout.d.mts +1 -0
  59. package/dist/esm/api/types/ValueReceiptDetail.d.mts +19 -0
  60. package/dist/esm/api/types/ValueReceiptDetail.mjs +2 -0
  61. package/dist/esm/api/types/ValueReceiptListResponse.d.mts +5 -0
  62. package/dist/esm/api/types/ValueReceiptListResponse.mjs +2 -0
  63. package/dist/esm/api/types/ValueReceiptSummary.d.mts +16 -0
  64. package/dist/esm/api/types/ValueReceiptSummary.mjs +2 -0
  65. package/dist/esm/api/types/index.d.mts +3 -0
  66. package/dist/esm/api/types/index.mjs +3 -0
  67. package/dist/esm/version.d.mts +1 -1
  68. package/dist/esm/version.mjs +1 -1
  69. package/package.json +1 -1
  70. package/reference.md +259 -0
@@ -7,6 +7,7 @@ import { Invoices } from "./api/resources/invoices/client/Client.js";
7
7
  import { Orders } from "./api/resources/orders/client/Client.js";
8
8
  import { Products } from "./api/resources/products/client/Client.js";
9
9
  import { Signals } from "./api/resources/signals/client/Client.js";
10
+ import { ValueReceipts } from "./api/resources/valueReceipts/client/Client.js";
10
11
  import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
11
12
  export declare namespace PaidClient {
12
13
  interface Options extends BaseClientOptions {
@@ -25,6 +26,7 @@ export declare class PaidClient {
25
26
  protected _credits: Credits | undefined;
26
27
  protected _checkouts: Checkouts | undefined;
27
28
  protected _customerPortals: CustomerPortals | undefined;
29
+ protected _valueReceipts: ValueReceipts | undefined;
28
30
  constructor(_options: PaidClient.Options);
29
31
  get products(): Products;
30
32
  get customers(): Customers;
@@ -35,4 +37,5 @@ export declare class PaidClient {
35
37
  get credits(): Credits;
36
38
  get checkouts(): Checkouts;
37
39
  get customerPortals(): CustomerPortals;
40
+ get valueReceipts(): ValueReceipts;
38
41
  }
@@ -44,6 +44,7 @@ const Client_js_6 = require("./api/resources/invoices/client/Client.js");
44
44
  const Client_js_7 = require("./api/resources/orders/client/Client.js");
45
45
  const Client_js_8 = require("./api/resources/products/client/Client.js");
46
46
  const Client_js_9 = require("./api/resources/signals/client/Client.js");
47
+ const Client_js_10 = require("./api/resources/valueReceipts/client/Client.js");
47
48
  const headers_js_1 = require("./core/headers.js");
48
49
  const core = __importStar(require("./core/index.js"));
49
50
  class PaidClient {
@@ -51,8 +52,8 @@ class PaidClient {
51
52
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
52
53
  "X-Fern-Language": "JavaScript",
53
54
  "X-Fern-SDK-Name": "@paid-ai/paid-node",
54
- "X-Fern-SDK-Version": "1.2.0",
55
- "User-Agent": "@paid-ai/paid-node/1.2.0",
55
+ "X-Fern-SDK-Version": "1.2.1",
56
+ "User-Agent": "@paid-ai/paid-node/1.2.1",
56
57
  "X-Fern-Runtime": core.RUNTIME.type,
57
58
  "X-Fern-Runtime-Version": core.RUNTIME.version,
58
59
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -93,5 +94,9 @@ class PaidClient {
93
94
  var _a;
94
95
  return ((_a = this._customerPortals) !== null && _a !== void 0 ? _a : (this._customerPortals = new Client_js_4.CustomerPortals(this._options)));
95
96
  }
97
+ get valueReceipts() {
98
+ var _a;
99
+ return ((_a = this._valueReceipts) !== null && _a !== void 0 ? _a : (this._valueReceipts = new Client_js_10.ValueReceipts(this._options)));
100
+ }
96
101
  }
97
102
  exports.PaidClient = PaidClient;
@@ -20,4 +20,6 @@ export interface CreateCheckoutRequest {
20
20
  collectAddress?: boolean;
21
21
  collectPhone?: boolean;
22
22
  singleUse?: boolean;
23
+ /** Lock checkout to a specific currency. Omit to allow all currencies supported by the selected plans. */
24
+ currency?: string;
23
25
  }
@@ -84,6 +84,7 @@ export declare class Customers {
84
84
  * @param {Paid.DeleteCustomerByIdRequest} request
85
85
  * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
86
86
  *
87
+ * @throws {@link Paid.BadRequestError}
87
88
  * @throws {@link Paid.ForbiddenError}
88
89
  * @throws {@link Paid.NotFoundError}
89
90
  * @throws {@link Paid.InternalServerError}
@@ -137,6 +138,7 @@ export declare class Customers {
137
138
  * @param {Paid.DeleteCustomerByExternalIdRequest} request
138
139
  * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
139
140
  *
141
+ * @throws {@link Paid.BadRequestError}
140
142
  * @throws {@link Paid.ForbiddenError}
141
143
  * @throws {@link Paid.NotFoundError}
142
144
  * @throws {@link Paid.InternalServerError}
@@ -345,6 +345,7 @@ class Customers {
345
345
  * @param {Paid.DeleteCustomerByIdRequest} request
346
346
  * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
347
347
  *
348
+ * @throws {@link Paid.BadRequestError}
348
349
  * @throws {@link Paid.ForbiddenError}
349
350
  * @throws {@link Paid.NotFoundError}
350
351
  * @throws {@link Paid.InternalServerError}
@@ -376,6 +377,8 @@ class Customers {
376
377
  }
377
378
  if (_response.error.reason === "status-code") {
378
379
  switch (_response.error.statusCode) {
380
+ case 400:
381
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
379
382
  case 403:
380
383
  throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
381
384
  case 404:
@@ -556,6 +559,7 @@ class Customers {
556
559
  * @param {Paid.DeleteCustomerByExternalIdRequest} request
557
560
  * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
558
561
  *
562
+ * @throws {@link Paid.BadRequestError}
559
563
  * @throws {@link Paid.ForbiddenError}
560
564
  * @throws {@link Paid.NotFoundError}
561
565
  * @throws {@link Paid.InternalServerError}
@@ -587,6 +591,8 @@ class Customers {
587
591
  }
588
592
  if (_response.error.reason === "status-code") {
589
593
  switch (_response.error.statusCode) {
594
+ case 400:
595
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
590
596
  case 403:
591
597
  throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
592
598
  case 404:
@@ -16,3 +16,5 @@ export * from "./products/client/requests/index.js";
16
16
  export * as products from "./products/index.js";
17
17
  export * from "./signals/client/requests/index.js";
18
18
  export * as signals from "./signals/index.js";
19
+ export * from "./valueReceipts/client/requests/index.js";
20
+ export * as valueReceipts from "./valueReceipts/index.js";
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.signals = exports.products = exports.orders = exports.invoices = exports.customers = exports.customerPortals = exports.credits = exports.contacts = exports.checkouts = void 0;
39
+ exports.valueReceipts = exports.signals = exports.products = exports.orders = exports.invoices = exports.customers = exports.customerPortals = exports.credits = exports.contacts = exports.checkouts = void 0;
40
40
  __exportStar(require("./checkouts/client/requests/index.js"), exports);
41
41
  exports.checkouts = __importStar(require("./checkouts/index.js"));
42
42
  __exportStar(require("./checkouts/types/index.js"), exports);
@@ -55,3 +55,5 @@ __exportStar(require("./products/client/requests/index.js"), exports);
55
55
  exports.products = __importStar(require("./products/index.js"));
56
56
  __exportStar(require("./signals/client/requests/index.js"), exports);
57
57
  exports.signals = __importStar(require("./signals/index.js"));
58
+ __exportStar(require("./valueReceipts/client/requests/index.js"), exports);
59
+ exports.valueReceipts = __importStar(require("./valueReceipts/index.js"));
@@ -0,0 +1,75 @@
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 ValueReceipts {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class ValueReceipts {
11
+ protected readonly _options: ValueReceipts.Options;
12
+ constructor(_options: ValueReceipts.Options);
13
+ /**
14
+ * List value receipts for the organization
15
+ *
16
+ * @param {Paid.ListValueReceiptsRequest} request
17
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
18
+ *
19
+ * @throws {@link Paid.InternalServerError}
20
+ *
21
+ * @example
22
+ * await client.valueReceipts.listValueReceipts()
23
+ */
24
+ listValueReceipts(request?: Paid.ListValueReceiptsRequest, requestOptions?: ValueReceipts.RequestOptions): core.HttpResponsePromise<Paid.ValueReceiptListResponse>;
25
+ private __listValueReceipts;
26
+ /**
27
+ * Get a value receipt by ID, including its publish/share state.
28
+ *
29
+ * @param {Paid.GetValueReceiptByIdRequest} request
30
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
31
+ *
32
+ * @throws {@link Paid.NotFoundError}
33
+ * @throws {@link Paid.InternalServerError}
34
+ *
35
+ * @example
36
+ * await client.valueReceipts.getValueReceiptById({
37
+ * id: "id"
38
+ * })
39
+ */
40
+ getValueReceiptById(request: Paid.GetValueReceiptByIdRequest, requestOptions?: ValueReceipts.RequestOptions): core.HttpResponsePromise<Paid.ValueReceiptDetail>;
41
+ private __getValueReceiptById;
42
+ /**
43
+ * Make a value receipt publicly accessible via URL.
44
+ *
45
+ * @param {Paid.PublishValueReceiptBody} request
46
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
47
+ *
48
+ * @throws {@link Paid.NotFoundError}
49
+ * @throws {@link Paid.InternalServerError}
50
+ *
51
+ * @example
52
+ * await client.valueReceipts.publishValueReceipt({
53
+ * id: "id"
54
+ * })
55
+ */
56
+ publishValueReceipt(request: Paid.PublishValueReceiptBody, requestOptions?: ValueReceipts.RequestOptions): core.HttpResponsePromise<Paid.ValueReceiptDetail>;
57
+ private __publishValueReceipt;
58
+ /**
59
+ * Revoke public access to a value receipt.
60
+ *
61
+ * @param {Paid.UnpublishValueReceiptRequest} request
62
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
63
+ *
64
+ * @throws {@link Paid.NotFoundError}
65
+ * @throws {@link Paid.InternalServerError}
66
+ *
67
+ * @example
68
+ * await client.valueReceipts.unpublishValueReceipt({
69
+ * id: "id"
70
+ * })
71
+ */
72
+ unpublishValueReceipt(request: Paid.UnpublishValueReceiptRequest, requestOptions?: ValueReceipts.RequestOptions): core.HttpResponsePromise<Paid.ValueReceiptDetail>;
73
+ private __unpublishValueReceipt;
74
+ protected _getAuthorizationHeader(): Promise<string>;
75
+ }
@@ -0,0 +1,347 @@
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.ValueReceipts = 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 ValueReceipts {
64
+ constructor(_options) {
65
+ this._options = _options;
66
+ }
67
+ /**
68
+ * List value receipts for the organization
69
+ *
70
+ * @param {Paid.ListValueReceiptsRequest} request
71
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
72
+ *
73
+ * @throws {@link Paid.InternalServerError}
74
+ *
75
+ * @example
76
+ * await client.valueReceipts.listValueReceipts()
77
+ */
78
+ listValueReceipts(request = {}, requestOptions) {
79
+ return core.HttpResponsePromise.fromPromise(this.__listValueReceipts(request, requestOptions));
80
+ }
81
+ __listValueReceipts() {
82
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
83
+ var _a, _b, _c, _d, _e, _f, _g, _h;
84
+ const { limit, offset, customerId, orderId } = request;
85
+ const _queryParams = {};
86
+ if (limit != null) {
87
+ _queryParams.limit = limit.toString();
88
+ }
89
+ if (offset != null) {
90
+ _queryParams.offset = offset.toString();
91
+ }
92
+ if (customerId != null) {
93
+ _queryParams.customerId = customerId;
94
+ }
95
+ if (orderId != null) {
96
+ _queryParams.orderId = orderId;
97
+ }
98
+ 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);
99
+ const _response = yield core.fetcher({
100
+ 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, "value-receipts/"),
101
+ method: "GET",
102
+ headers: _headers,
103
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
104
+ 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,
105
+ 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,
106
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
107
+ });
108
+ if (_response.ok) {
109
+ return { data: _response.body, rawResponse: _response.rawResponse };
110
+ }
111
+ if (_response.error.reason === "status-code") {
112
+ switch (_response.error.statusCode) {
113
+ case 500:
114
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
115
+ default:
116
+ throw new errors.PaidError({
117
+ statusCode: _response.error.statusCode,
118
+ body: _response.error.body,
119
+ rawResponse: _response.rawResponse,
120
+ });
121
+ }
122
+ }
123
+ switch (_response.error.reason) {
124
+ case "non-json":
125
+ throw new errors.PaidError({
126
+ statusCode: _response.error.statusCode,
127
+ body: _response.error.rawBody,
128
+ rawResponse: _response.rawResponse,
129
+ });
130
+ case "timeout":
131
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /value-receipts/.");
132
+ case "unknown":
133
+ throw new errors.PaidError({
134
+ message: _response.error.errorMessage,
135
+ rawResponse: _response.rawResponse,
136
+ });
137
+ }
138
+ });
139
+ }
140
+ /**
141
+ * Get a value receipt by ID, including its publish/share state.
142
+ *
143
+ * @param {Paid.GetValueReceiptByIdRequest} request
144
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
145
+ *
146
+ * @throws {@link Paid.NotFoundError}
147
+ * @throws {@link Paid.InternalServerError}
148
+ *
149
+ * @example
150
+ * await client.valueReceipts.getValueReceiptById({
151
+ * id: "id"
152
+ * })
153
+ */
154
+ getValueReceiptById(request, requestOptions) {
155
+ return core.HttpResponsePromise.fromPromise(this.__getValueReceiptById(request, requestOptions));
156
+ }
157
+ __getValueReceiptById(request, requestOptions) {
158
+ return __awaiter(this, void 0, void 0, function* () {
159
+ var _a, _b, _c, _d, _e, _f, _g, _h;
160
+ const { id } = request;
161
+ 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);
162
+ const _response = yield core.fetcher({
163
+ 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, `value-receipts/${core.url.encodePathParam(id)}`),
164
+ method: "GET",
165
+ headers: _headers,
166
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
167
+ 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,
168
+ 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,
169
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
170
+ });
171
+ if (_response.ok) {
172
+ return { data: _response.body, rawResponse: _response.rawResponse };
173
+ }
174
+ if (_response.error.reason === "status-code") {
175
+ switch (_response.error.statusCode) {
176
+ case 404:
177
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
178
+ case 500:
179
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
180
+ default:
181
+ throw new errors.PaidError({
182
+ statusCode: _response.error.statusCode,
183
+ body: _response.error.body,
184
+ rawResponse: _response.rawResponse,
185
+ });
186
+ }
187
+ }
188
+ switch (_response.error.reason) {
189
+ case "non-json":
190
+ throw new errors.PaidError({
191
+ statusCode: _response.error.statusCode,
192
+ body: _response.error.rawBody,
193
+ rawResponse: _response.rawResponse,
194
+ });
195
+ case "timeout":
196
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /value-receipts/{id}.");
197
+ case "unknown":
198
+ throw new errors.PaidError({
199
+ message: _response.error.errorMessage,
200
+ rawResponse: _response.rawResponse,
201
+ });
202
+ }
203
+ });
204
+ }
205
+ /**
206
+ * Make a value receipt publicly accessible via URL.
207
+ *
208
+ * @param {Paid.PublishValueReceiptBody} request
209
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
210
+ *
211
+ * @throws {@link Paid.NotFoundError}
212
+ * @throws {@link Paid.InternalServerError}
213
+ *
214
+ * @example
215
+ * await client.valueReceipts.publishValueReceipt({
216
+ * id: "id"
217
+ * })
218
+ */
219
+ publishValueReceipt(request, requestOptions) {
220
+ return core.HttpResponsePromise.fromPromise(this.__publishValueReceipt(request, requestOptions));
221
+ }
222
+ __publishValueReceipt(request, requestOptions) {
223
+ return __awaiter(this, void 0, void 0, function* () {
224
+ var _a, _b, _c, _d, _e, _f, _g, _h;
225
+ const { id } = request, _body = __rest(request, ["id"]);
226
+ 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);
227
+ const _response = yield core.fetcher({
228
+ 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, `value-receipts/${core.url.encodePathParam(id)}/publish`),
229
+ method: "POST",
230
+ headers: _headers,
231
+ contentType: "application/json",
232
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
233
+ requestType: "json",
234
+ body: _body,
235
+ 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,
236
+ 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,
237
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
238
+ });
239
+ if (_response.ok) {
240
+ return { data: _response.body, rawResponse: _response.rawResponse };
241
+ }
242
+ if (_response.error.reason === "status-code") {
243
+ switch (_response.error.statusCode) {
244
+ case 404:
245
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
246
+ case 500:
247
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
248
+ default:
249
+ throw new errors.PaidError({
250
+ statusCode: _response.error.statusCode,
251
+ body: _response.error.body,
252
+ rawResponse: _response.rawResponse,
253
+ });
254
+ }
255
+ }
256
+ switch (_response.error.reason) {
257
+ case "non-json":
258
+ throw new errors.PaidError({
259
+ statusCode: _response.error.statusCode,
260
+ body: _response.error.rawBody,
261
+ rawResponse: _response.rawResponse,
262
+ });
263
+ case "timeout":
264
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /value-receipts/{id}/publish.");
265
+ case "unknown":
266
+ throw new errors.PaidError({
267
+ message: _response.error.errorMessage,
268
+ rawResponse: _response.rawResponse,
269
+ });
270
+ }
271
+ });
272
+ }
273
+ /**
274
+ * Revoke public access to a value receipt.
275
+ *
276
+ * @param {Paid.UnpublishValueReceiptRequest} request
277
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
278
+ *
279
+ * @throws {@link Paid.NotFoundError}
280
+ * @throws {@link Paid.InternalServerError}
281
+ *
282
+ * @example
283
+ * await client.valueReceipts.unpublishValueReceipt({
284
+ * id: "id"
285
+ * })
286
+ */
287
+ unpublishValueReceipt(request, requestOptions) {
288
+ return core.HttpResponsePromise.fromPromise(this.__unpublishValueReceipt(request, requestOptions));
289
+ }
290
+ __unpublishValueReceipt(request, requestOptions) {
291
+ return __awaiter(this, void 0, void 0, function* () {
292
+ var _a, _b, _c, _d, _e, _f, _g, _h;
293
+ const { id } = request, _body = __rest(request, ["id"]);
294
+ 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);
295
+ const _response = yield core.fetcher({
296
+ 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, `value-receipts/${core.url.encodePathParam(id)}/unpublish`),
297
+ method: "POST",
298
+ headers: _headers,
299
+ contentType: "application/json",
300
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
301
+ requestType: "json",
302
+ body: _body,
303
+ 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,
304
+ 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,
305
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
306
+ });
307
+ if (_response.ok) {
308
+ return { data: _response.body, rawResponse: _response.rawResponse };
309
+ }
310
+ if (_response.error.reason === "status-code") {
311
+ switch (_response.error.statusCode) {
312
+ case 404:
313
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
314
+ case 500:
315
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
316
+ default:
317
+ throw new errors.PaidError({
318
+ statusCode: _response.error.statusCode,
319
+ body: _response.error.body,
320
+ rawResponse: _response.rawResponse,
321
+ });
322
+ }
323
+ }
324
+ switch (_response.error.reason) {
325
+ case "non-json":
326
+ throw new errors.PaidError({
327
+ statusCode: _response.error.statusCode,
328
+ body: _response.error.rawBody,
329
+ rawResponse: _response.rawResponse,
330
+ });
331
+ case "timeout":
332
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /value-receipts/{id}/unpublish.");
333
+ case "unknown":
334
+ throw new errors.PaidError({
335
+ message: _response.error.errorMessage,
336
+ rawResponse: _response.rawResponse,
337
+ });
338
+ }
339
+ });
340
+ }
341
+ _getAuthorizationHeader() {
342
+ return __awaiter(this, void 0, void 0, function* () {
343
+ return `Bearer ${yield core.Supplier.get(this._options.token)}`;
344
+ });
345
+ }
346
+ }
347
+ exports.ValueReceipts = ValueReceipts;
@@ -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,9 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id"
5
+ * }
6
+ */
7
+ export interface GetValueReceiptByIdRequest {
8
+ id: string;
9
+ }
@@ -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,10 @@
1
+ /**
2
+ * @example
3
+ * {}
4
+ */
5
+ export interface ListValueReceiptsRequest {
6
+ limit?: number;
7
+ offset?: number;
8
+ customerId?: string;
9
+ orderId?: string;
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,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id"
5
+ * }
6
+ */
7
+ export interface PublishValueReceiptBody {
8
+ id: string;
9
+ publishExpiresAt?: string | null;
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,9 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id"
5
+ * }
6
+ */
7
+ export interface UnpublishValueReceiptRequest {
8
+ id: string;
9
+ }
@@ -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,4 @@
1
+ export type { GetValueReceiptByIdRequest } from "./GetValueReceiptByIdRequest.js";
2
+ export type { ListValueReceiptsRequest } from "./ListValueReceiptsRequest.js";
3
+ export type { PublishValueReceiptBody } from "./PublishValueReceiptBody.js";
4
+ export type { UnpublishValueReceiptRequest } from "./UnpublishValueReceiptRequest.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client/index.js";