rcs-js 2.0.23 → 2.0.24-rc.2

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 (94) hide show
  1. package/dist/cjs/Client.d.ts +3 -0
  2. package/dist/cjs/Client.js +21 -16
  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/ServiceUnavailableError.d.ts +6 -0
  6. package/dist/cjs/api/errors/ServiceUnavailableError.js +50 -0
  7. package/dist/cjs/api/errors/index.d.ts +2 -0
  8. package/dist/cjs/api/errors/index.js +2 -0
  9. package/dist/cjs/api/resources/faxes/client/Client.d.ts +129 -0
  10. package/dist/cjs/api/resources/faxes/client/Client.js +438 -0
  11. package/dist/cjs/api/resources/faxes/client/index.d.ts +1 -0
  12. package/dist/cjs/api/resources/faxes/client/index.js +17 -0
  13. package/dist/cjs/api/resources/faxes/client/requests/FaxesListRequest.d.ts +13 -0
  14. package/dist/cjs/api/resources/faxes/client/requests/FaxesListRequest.js +3 -0
  15. package/dist/cjs/api/resources/faxes/client/requests/SendFaxParams.d.ts +27 -0
  16. package/dist/cjs/api/resources/faxes/client/requests/SendFaxParams.js +3 -0
  17. package/dist/cjs/api/resources/faxes/client/requests/index.d.ts +2 -0
  18. package/dist/cjs/api/resources/faxes/client/requests/index.js +2 -0
  19. package/dist/cjs/api/resources/faxes/index.d.ts +1 -0
  20. package/dist/cjs/api/resources/faxes/index.js +17 -0
  21. package/dist/cjs/api/resources/index.d.ts +2 -0
  22. package/dist/cjs/api/resources/index.js +3 -1
  23. package/dist/cjs/api/types/Fax.d.ts +27 -0
  24. package/dist/cjs/api/types/Fax.js +3 -0
  25. package/dist/cjs/api/types/FaxBillingStatusEnum.d.ts +6 -0
  26. package/dist/cjs/api/types/FaxBillingStatusEnum.js +9 -0
  27. package/dist/cjs/api/types/FaxDetail.d.ts +29 -0
  28. package/dist/cjs/api/types/FaxDetail.js +3 -0
  29. package/dist/cjs/api/types/FaxDirectionEnum.d.ts +6 -0
  30. package/dist/cjs/api/types/FaxDirectionEnum.js +9 -0
  31. package/dist/cjs/api/types/FaxEvent.d.ts +19 -0
  32. package/dist/cjs/api/types/FaxEvent.js +11 -0
  33. package/dist/cjs/api/types/FaxFailureReasonEnum.d.ts +19 -0
  34. package/dist/cjs/api/types/FaxFailureReasonEnum.js +22 -0
  35. package/dist/cjs/api/types/FaxQualityEnum.d.ts +19 -0
  36. package/dist/cjs/api/types/FaxQualityEnum.js +22 -0
  37. package/dist/cjs/api/types/FaxStatusEnum.d.ts +29 -0
  38. package/dist/cjs/api/types/FaxStatusEnum.js +32 -0
  39. package/dist/cjs/api/types/ListFaxesResponse.d.ts +6 -0
  40. package/dist/cjs/api/types/ListFaxesResponse.js +3 -0
  41. package/dist/cjs/api/types/WebhookEventEnum.d.ts +2 -0
  42. package/dist/cjs/api/types/WebhookEventEnum.js +2 -0
  43. package/dist/cjs/api/types/index.d.ts +9 -0
  44. package/dist/cjs/api/types/index.js +9 -0
  45. package/dist/cjs/version.d.ts +1 -1
  46. package/dist/cjs/version.js +1 -1
  47. package/dist/esm/Client.d.mts +3 -0
  48. package/dist/esm/Client.mjs +7 -2
  49. package/dist/esm/api/errors/ConflictError.d.mts +6 -0
  50. package/dist/esm/api/errors/ConflictError.mjs +13 -0
  51. package/dist/esm/api/errors/ServiceUnavailableError.d.mts +6 -0
  52. package/dist/esm/api/errors/ServiceUnavailableError.mjs +13 -0
  53. package/dist/esm/api/errors/index.d.mts +2 -0
  54. package/dist/esm/api/errors/index.mjs +2 -0
  55. package/dist/esm/api/resources/faxes/client/Client.d.mts +129 -0
  56. package/dist/esm/api/resources/faxes/client/Client.mjs +401 -0
  57. package/dist/esm/api/resources/faxes/client/index.d.mts +1 -0
  58. package/dist/esm/api/resources/faxes/client/index.mjs +1 -0
  59. package/dist/esm/api/resources/faxes/client/requests/FaxesListRequest.d.mts +13 -0
  60. package/dist/esm/api/resources/faxes/client/requests/FaxesListRequest.mjs +2 -0
  61. package/dist/esm/api/resources/faxes/client/requests/SendFaxParams.d.mts +27 -0
  62. package/dist/esm/api/resources/faxes/client/requests/SendFaxParams.mjs +2 -0
  63. package/dist/esm/api/resources/faxes/client/requests/index.d.mts +2 -0
  64. package/dist/esm/api/resources/faxes/client/requests/index.mjs +1 -0
  65. package/dist/esm/api/resources/faxes/index.d.mts +1 -0
  66. package/dist/esm/api/resources/faxes/index.mjs +1 -0
  67. package/dist/esm/api/resources/index.d.mts +2 -0
  68. package/dist/esm/api/resources/index.mjs +2 -0
  69. package/dist/esm/api/types/Fax.d.mts +27 -0
  70. package/dist/esm/api/types/Fax.mjs +2 -0
  71. package/dist/esm/api/types/FaxBillingStatusEnum.d.mts +6 -0
  72. package/dist/esm/api/types/FaxBillingStatusEnum.mjs +6 -0
  73. package/dist/esm/api/types/FaxDetail.d.mts +29 -0
  74. package/dist/esm/api/types/FaxDetail.mjs +2 -0
  75. package/dist/esm/api/types/FaxDirectionEnum.d.mts +6 -0
  76. package/dist/esm/api/types/FaxDirectionEnum.mjs +6 -0
  77. package/dist/esm/api/types/FaxEvent.d.mts +19 -0
  78. package/dist/esm/api/types/FaxEvent.mjs +8 -0
  79. package/dist/esm/api/types/FaxFailureReasonEnum.d.mts +19 -0
  80. package/dist/esm/api/types/FaxFailureReasonEnum.mjs +19 -0
  81. package/dist/esm/api/types/FaxQualityEnum.d.mts +19 -0
  82. package/dist/esm/api/types/FaxQualityEnum.mjs +19 -0
  83. package/dist/esm/api/types/FaxStatusEnum.d.mts +29 -0
  84. package/dist/esm/api/types/FaxStatusEnum.mjs +29 -0
  85. package/dist/esm/api/types/ListFaxesResponse.d.mts +6 -0
  86. package/dist/esm/api/types/ListFaxesResponse.mjs +2 -0
  87. package/dist/esm/api/types/WebhookEventEnum.d.mts +2 -0
  88. package/dist/esm/api/types/WebhookEventEnum.mjs +2 -0
  89. package/dist/esm/api/types/index.d.mts +9 -0
  90. package/dist/esm/api/types/index.mjs +9 -0
  91. package/dist/esm/version.d.mts +1 -1
  92. package/dist/esm/version.mjs +1 -1
  93. package/package.json +1 -1
  94. package/reference.md +295 -0
@@ -0,0 +1,438 @@
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.Faxes = 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 Pinnacle = __importStar(require("../../../index.js"));
63
+ class Faxes {
64
+ constructor(_options) {
65
+ this._options = _options;
66
+ }
67
+ /**
68
+ * List your team's fax history, newest first.
69
+ *
70
+ * **HIPAA only:** this endpoint exists only in Pinnacle's HIPAA cell and is unavailable at `https://api.pinnacle.sh`.
71
+ *
72
+ * Results contain complete faxes only. Use `nextOffset` until it is null. The maximum page size is 100 records and the maximum offset is 100,000.
73
+ *
74
+ * @param {Pinnacle.FaxesListRequest} request
75
+ * @param {Faxes.RequestOptions} requestOptions - Request-specific configuration.
76
+ *
77
+ * @throws {@link Pinnacle.BadRequestError}
78
+ * @throws {@link Pinnacle.UnauthorizedError}
79
+ * @throws {@link Pinnacle.ForbiddenError}
80
+ * @throws {@link Pinnacle.InternalServerError}
81
+ * @throws {@link Pinnacle.ServiceUnavailableError}
82
+ *
83
+ * @example
84
+ * await client.faxes.list()
85
+ */
86
+ list(request = {}, requestOptions) {
87
+ return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
88
+ }
89
+ __list() {
90
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
91
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
92
+ const { limit, offset, direction } = request;
93
+ const _queryParams = {};
94
+ if (limit != null) {
95
+ _queryParams.limit = limit.toString();
96
+ }
97
+ if (offset != null) {
98
+ _queryParams.offset = offset.toString();
99
+ }
100
+ if (direction != null) {
101
+ _queryParams.direction = direction;
102
+ }
103
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
104
+ const _response = yield core.fetcher({
105
+ 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.PinnacleEnvironment.Default, "fax"),
106
+ method: "GET",
107
+ headers: _headers,
108
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
109
+ 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,
110
+ 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,
111
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
112
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
113
+ logging: this._options.logging,
114
+ });
115
+ if (_response.ok) {
116
+ return { data: _response.body, rawResponse: _response.rawResponse };
117
+ }
118
+ if (_response.error.reason === "status-code") {
119
+ switch (_response.error.statusCode) {
120
+ case 400:
121
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
122
+ case 401:
123
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
124
+ case 403:
125
+ throw new Pinnacle.ForbiddenError(_response.error.body, _response.rawResponse);
126
+ case 500:
127
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
128
+ case 503:
129
+ throw new Pinnacle.ServiceUnavailableError(_response.error.body, _response.rawResponse);
130
+ default:
131
+ throw new errors.PinnacleError({
132
+ statusCode: _response.error.statusCode,
133
+ body: _response.error.body,
134
+ rawResponse: _response.rawResponse,
135
+ });
136
+ }
137
+ }
138
+ switch (_response.error.reason) {
139
+ case "non-json":
140
+ throw new errors.PinnacleError({
141
+ statusCode: _response.error.statusCode,
142
+ body: _response.error.rawBody,
143
+ rawResponse: _response.rawResponse,
144
+ });
145
+ case "timeout":
146
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling GET /fax.");
147
+ case "unknown":
148
+ throw new errors.PinnacleError({
149
+ message: _response.error.errorMessage,
150
+ rawResponse: _response.rawResponse,
151
+ });
152
+ }
153
+ });
154
+ }
155
+ /**
156
+ * Send one PDF, TIFF, JPEG, PNG, DOC, DOCX, RTF, or TXT document from a configured fax number.
157
+ *
158
+ * **HIPAA only:** this endpoint exists only in Pinnacle's HIPAA cell. Complete HIPAA onboarding and use the connection details provided by Pinnacle. It is not available at `https://api.pinnacle.sh`.
159
+ *
160
+ * **Availability:** `from` must be an enabled fax number owned by your team. Fax sending is unavailable for development-mode teams and sandbox numbers. Each request accepts exactly one document; cover pages and per-request webhook URLs are not supported.
161
+ *
162
+ * **Source URL:** `mediaUrl` must be a publicly reachable HTTPS URL on port 443. Signed query parameters are supported. URLs with credentials, redirects, private or local network addresses, and non-200 responses are rejected. Downloads must complete within 30 seconds.
163
+ *
164
+ * **Document limits:** the document must contain 1–3,500 pages and be no larger than 50 MB. Documents over 350 pages are split automatically and remain one fax in the API. File extensions and response headers do not override file validation.
165
+ *
166
+ * **Document safety:** encrypted files, macros, ActiveX controls, embedded objects, symbolic links, unsafe archive paths, and malformed documents are rejected.
167
+ *
168
+ * **Quality:** `HIGH` is the default and recommended choice for most documents. Use `NORMAL` when speed matters more than detail, `VERY_HIGH` for small text and fine lines, `ULTRA_LIGHT` for image-heavy documents, or `ULTRA_DARK` for text-heavy documents.
169
+ *
170
+ * **Asynchronous processing:** the request returns 202 after preparation is queued. Downloading, validation, conversion, splitting, and archival happen afterward. A 202 response does not mean the document is valid or delivered. Watch `FAX.STATUS` webhooks or retrieve the fax for the final result. The initial status is `PREPARING`, `reservedCost` is zero, and `hasMedia` is false.
171
+ *
172
+ * **Multipart delivery:** the original `id` identifies the complete fax across list, detail, cancellation, billing, media, and webhooks. Parts are sent in order. If a part fails, later parts are not sent. The fax becomes `FAILED`, and `partialContent` is true if any earlier pages were transmitted.
173
+ *
174
+ * **Pricing:** sent and received faxes cost $0.025 per transmitted page. Quality does not change the rate. Pinnacle reserves the estimated cost after preparation, charges only for transmitted pages, and returns unused reserved credits. If your balance is too low, the fax becomes `FAILED` with `failureReason: INSUFFICIENT_CREDITS`.
175
+ *
176
+ * **Delivery uncertainty:** Pinnacle does not automatically retry a fax after transmission may have started, which prevents duplicate delivery and charges. If transmission cannot be confirmed, status becomes `SUBMISSION_UNKNOWN` while Pinnacle reconciles the fax.
177
+ *
178
+ * **Idempotency:** `Idempotency-Key` is optional. Without it, each request creates a new fax, including retries. For retry-safe sending, generate a UUID for each intended fax and retain it until the outcome is known. After a client timeout, retry with the same key and identical body. The key is scoped to your team and covers `from`, `to`, `mediaUrl`, and `quality`. Reusing it with an identical body returns the existing fax; changing any of those fields returns 409.
179
+ *
180
+ * @param {Pinnacle.SendFaxParams} request
181
+ * @param {Faxes.RequestOptions} requestOptions - Request-specific configuration.
182
+ *
183
+ * @throws {@link Pinnacle.BadRequestError}
184
+ * @throws {@link Pinnacle.UnauthorizedError}
185
+ * @throws {@link Pinnacle.ForbiddenError}
186
+ * @throws {@link Pinnacle.NotFoundError}
187
+ * @throws {@link Pinnacle.ConflictError}
188
+ * @throws {@link Pinnacle.InternalServerError}
189
+ * @throws {@link Pinnacle.ServiceUnavailableError}
190
+ *
191
+ * @example
192
+ * await client.faxes.send({
193
+ * from: "from",
194
+ * to: "to",
195
+ * mediaUrl: "mediaUrl"
196
+ * })
197
+ */
198
+ send(request, requestOptions) {
199
+ return core.HttpResponsePromise.fromPromise(this.__send(request, requestOptions));
200
+ }
201
+ __send(request, requestOptions) {
202
+ return __awaiter(this, void 0, void 0, function* () {
203
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
204
+ const { "Idempotency-Key": idempotencyKey } = request, _body = __rest(request, ["Idempotency-Key"]);
205
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ "Idempotency-Key": idempotencyKey != null ? idempotencyKey : undefined }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
206
+ const _response = yield core.fetcher({
207
+ 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.PinnacleEnvironment.Default, "fax"),
208
+ method: "POST",
209
+ headers: _headers,
210
+ contentType: "application/json",
211
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
212
+ requestType: "json",
213
+ body: _body,
214
+ 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,
215
+ 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,
216
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
217
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
218
+ logging: this._options.logging,
219
+ });
220
+ if (_response.ok) {
221
+ return { data: _response.body, rawResponse: _response.rawResponse };
222
+ }
223
+ if (_response.error.reason === "status-code") {
224
+ switch (_response.error.statusCode) {
225
+ case 400:
226
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
227
+ case 401:
228
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
229
+ case 403:
230
+ throw new Pinnacle.ForbiddenError(_response.error.body, _response.rawResponse);
231
+ case 404:
232
+ throw new Pinnacle.NotFoundError(_response.error.body, _response.rawResponse);
233
+ case 409:
234
+ throw new Pinnacle.ConflictError(_response.error.body, _response.rawResponse);
235
+ case 500:
236
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
237
+ case 503:
238
+ throw new Pinnacle.ServiceUnavailableError(_response.error.body, _response.rawResponse);
239
+ default:
240
+ throw new errors.PinnacleError({
241
+ statusCode: _response.error.statusCode,
242
+ body: _response.error.body,
243
+ rawResponse: _response.rawResponse,
244
+ });
245
+ }
246
+ }
247
+ switch (_response.error.reason) {
248
+ case "non-json":
249
+ throw new errors.PinnacleError({
250
+ statusCode: _response.error.statusCode,
251
+ body: _response.error.rawBody,
252
+ rawResponse: _response.rawResponse,
253
+ });
254
+ case "timeout":
255
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling POST /fax.");
256
+ case "unknown":
257
+ throw new errors.PinnacleError({
258
+ message: _response.error.errorMessage,
259
+ rawResponse: _response.rawResponse,
260
+ });
261
+ }
262
+ });
263
+ }
264
+ /**
265
+ * Retrieve a fax and a one-hour signed document URL when its media is available.
266
+ *
267
+ * **HIPAA only:** this endpoint exists only in Pinnacle's HIPAA cell and is unavailable at `https://api.pinnacle.sh`.
268
+ *
269
+ * Only faxes owned by your team are accessible. Unknown IDs and records removed by your team's HIPAA retention policy return 404. `mediaUrl` is null until archival completes and expires one hour after retrieval; request the fax again for a new URL.
270
+ *
271
+ * @param {string} id - Fax ID returned by send, list, or a fax webhook.
272
+ * @param {Faxes.RequestOptions} requestOptions - Request-specific configuration.
273
+ *
274
+ * @throws {@link Pinnacle.BadRequestError}
275
+ * @throws {@link Pinnacle.UnauthorizedError}
276
+ * @throws {@link Pinnacle.ForbiddenError}
277
+ * @throws {@link Pinnacle.NotFoundError}
278
+ * @throws {@link Pinnacle.InternalServerError}
279
+ * @throws {@link Pinnacle.ServiceUnavailableError}
280
+ *
281
+ * @example
282
+ * await client.faxes.get("id")
283
+ */
284
+ get(id, requestOptions) {
285
+ return core.HttpResponsePromise.fromPromise(this.__get(id, requestOptions));
286
+ }
287
+ __get(id, requestOptions) {
288
+ return __awaiter(this, void 0, void 0, function* () {
289
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
290
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
291
+ const _response = yield core.fetcher({
292
+ 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.PinnacleEnvironment.Default, `fax/${core.url.encodePathParam(id)}`),
293
+ method: "GET",
294
+ headers: _headers,
295
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
296
+ 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,
297
+ 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,
298
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
299
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
300
+ logging: this._options.logging,
301
+ });
302
+ if (_response.ok) {
303
+ return { data: _response.body, rawResponse: _response.rawResponse };
304
+ }
305
+ if (_response.error.reason === "status-code") {
306
+ switch (_response.error.statusCode) {
307
+ case 400:
308
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
309
+ case 401:
310
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
311
+ case 403:
312
+ throw new Pinnacle.ForbiddenError(_response.error.body, _response.rawResponse);
313
+ case 404:
314
+ throw new Pinnacle.NotFoundError(_response.error.body, _response.rawResponse);
315
+ case 500:
316
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
317
+ case 503:
318
+ throw new Pinnacle.ServiceUnavailableError(_response.error.body, _response.rawResponse);
319
+ default:
320
+ throw new errors.PinnacleError({
321
+ statusCode: _response.error.statusCode,
322
+ body: _response.error.body,
323
+ rawResponse: _response.rawResponse,
324
+ });
325
+ }
326
+ }
327
+ switch (_response.error.reason) {
328
+ case "non-json":
329
+ throw new errors.PinnacleError({
330
+ statusCode: _response.error.statusCode,
331
+ body: _response.error.rawBody,
332
+ rawResponse: _response.rawResponse,
333
+ });
334
+ case "timeout":
335
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling GET /fax/{id}.");
336
+ case "unknown":
337
+ throw new errors.PinnacleError({
338
+ message: _response.error.errorMessage,
339
+ rawResponse: _response.rawResponse,
340
+ });
341
+ }
342
+ });
343
+ }
344
+ /**
345
+ * Cancel an outbound fax before transmission starts.
346
+ *
347
+ * Cancellation stops queued preparation and every unsent part, releases the credit reservation, and changes the status to `CANCELLED`. Repeating a successful cancellation returns the same fax.
348
+ *
349
+ * Cancellation is unavailable for inbound faxes, completed faxes, and `SUBMISSION_UNKNOWN` faxes. Pinnacle returns 409 once transmission may have started, even when later parts remain unsent.
350
+ *
351
+ * **HIPAA only:** this endpoint exists only in Pinnacle's HIPAA cell and is unavailable at `https://api.pinnacle.sh`.
352
+ *
353
+ * Only a fax ID owned by your team is accepted. Unknown IDs return 404.
354
+ *
355
+ * @param {string} id - Fax ID returned by send, list, or a fax webhook.
356
+ * @param {Faxes.RequestOptions} requestOptions - Request-specific configuration.
357
+ *
358
+ * @throws {@link Pinnacle.BadRequestError}
359
+ * @throws {@link Pinnacle.UnauthorizedError}
360
+ * @throws {@link Pinnacle.ForbiddenError}
361
+ * @throws {@link Pinnacle.NotFoundError}
362
+ * @throws {@link Pinnacle.ConflictError}
363
+ * @throws {@link Pinnacle.InternalServerError}
364
+ * @throws {@link Pinnacle.ServiceUnavailableError}
365
+ *
366
+ * @example
367
+ * await client.faxes.cancel("id")
368
+ */
369
+ cancel(id, requestOptions) {
370
+ return core.HttpResponsePromise.fromPromise(this.__cancel(id, requestOptions));
371
+ }
372
+ __cancel(id, requestOptions) {
373
+ return __awaiter(this, void 0, void 0, function* () {
374
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
375
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
376
+ const _response = yield core.fetcher({
377
+ 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.PinnacleEnvironment.Default, `fax/${core.url.encodePathParam(id)}/cancel`),
378
+ method: "POST",
379
+ headers: _headers,
380
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
381
+ 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,
382
+ 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,
383
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
384
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
385
+ logging: this._options.logging,
386
+ });
387
+ if (_response.ok) {
388
+ return { data: _response.body, rawResponse: _response.rawResponse };
389
+ }
390
+ if (_response.error.reason === "status-code") {
391
+ switch (_response.error.statusCode) {
392
+ case 400:
393
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
394
+ case 401:
395
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
396
+ case 403:
397
+ throw new Pinnacle.ForbiddenError(_response.error.body, _response.rawResponse);
398
+ case 404:
399
+ throw new Pinnacle.NotFoundError(_response.error.body, _response.rawResponse);
400
+ case 409:
401
+ throw new Pinnacle.ConflictError(_response.error.body, _response.rawResponse);
402
+ case 500:
403
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
404
+ case 503:
405
+ throw new Pinnacle.ServiceUnavailableError(_response.error.body, _response.rawResponse);
406
+ default:
407
+ throw new errors.PinnacleError({
408
+ statusCode: _response.error.statusCode,
409
+ body: _response.error.body,
410
+ rawResponse: _response.rawResponse,
411
+ });
412
+ }
413
+ }
414
+ switch (_response.error.reason) {
415
+ case "non-json":
416
+ throw new errors.PinnacleError({
417
+ statusCode: _response.error.statusCode,
418
+ body: _response.error.rawBody,
419
+ rawResponse: _response.rawResponse,
420
+ });
421
+ case "timeout":
422
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling POST /fax/{id}/cancel.");
423
+ case "unknown":
424
+ throw new errors.PinnacleError({
425
+ message: _response.error.errorMessage,
426
+ rawResponse: _response.rawResponse,
427
+ });
428
+ }
429
+ });
430
+ }
431
+ _getCustomAuthorizationHeaders() {
432
+ return __awaiter(this, void 0, void 0, function* () {
433
+ const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
434
+ return { "PINNACLE-API-KEY": apiKeyValue };
435
+ });
436
+ }
437
+ }
438
+ exports.Faxes = Faxes;
@@ -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,13 @@
1
+ import type * as Pinnacle from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface FaxesListRequest {
7
+ /** Maximum logical faxes to return. Defaults to 25. */
8
+ limit?: number;
9
+ /** Zero-based number of logical faxes to skip. Defaults to 0. */
10
+ offset?: number;
11
+ /** Return only inbound or outbound logical faxes. */
12
+ direction?: Pinnacle.FaxDirectionEnum;
13
+ }
@@ -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,27 @@
1
+ import type * as Pinnacle from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {
5
+ * from: "from",
6
+ * to: "to",
7
+ * mediaUrl: "mediaUrl"
8
+ * }
9
+ */
10
+ export interface SendFaxParams {
11
+ /** Optional unique key for one logical send. Without it, every request creates a new fax. Use 1–128 ASCII letters, numbers, periods, underscores, or hyphens. Reuse it only with the identical `from`, `to`, `mediaUrl`, and effective `quality`; any change returns 409. */
12
+ "Idempotency-Key"?: string;
13
+ /** Fax-enabled, non-sandbox number owned by your HIPAA team, in E.164 format (`+` followed by 10–15 digits; the first digit cannot be zero). The number must remain enabled and configured through preparation. Fax sending is unavailable to development-mode teams. */
14
+ from: string;
15
+ /** Recipient fax number in E.164 format (`+` followed by 10–15 digits; the first digit cannot be zero). */
16
+ to: string;
17
+ /**
18
+ * Public HTTPS URL on port 443 for one PDF, TIFF, JPEG, PNG, DOC, DOCX, RTF, or TXT document. The URL must contain 9–8,192 characters, including signed query parameters. Usernames, passwords, redirects, private or local addresses, IPv6-only hosts, and non-200 responses are rejected.
19
+ *
20
+ * The origin must complete the download within 30 seconds and return no more than 16 KiB of response headers. If present, `Content-Length` must be a non-negative decimal integer no greater than 50,000,000, and `Content-Type` must be one of the accepted types listed in the endpoint description. The source and processed document must each be no larger than 50,000,000 bytes. The document must contain 1–3,500 pages.
21
+ *
22
+ * A permitted URL extension or `Content-Type` is not sufficient: file signatures and structure must identify a supported format. JPEG/PNG images are limited to 250,000,000 pixels and TIFF images to 2,000,000,000 pixels. DOCX archives must be non-encrypted and free of macros, ActiveX controls, embedded objects, symbolic links, and unsafe paths; ZIP64 and multi-disk containers are not accepted. See the endpoint description for the complete DOCX archive and document-processing limits.
23
+ */
24
+ mediaUrl: string;
25
+ /** Rendering profile applied to the fax. Defaults to `HIGH`. Higher-detail profiles can take longer to process but do not change the $0.025 per-page price or any document limit. */
26
+ quality?: Pinnacle.FaxQualityEnum;
27
+ }
@@ -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 { FaxesListRequest } from "./FaxesListRequest.js";
2
+ export type { SendFaxParams } from "./SendFaxParams.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client/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("./client/index.js"), exports);
@@ -9,6 +9,8 @@ export * as contacts from "./contacts/index.js";
9
9
  export * from "./conversations/client/requests/index.js";
10
10
  export * as conversations from "./conversations/index.js";
11
11
  export * from "./conversations/types/index.js";
12
+ export * from "./faxes/client/requests/index.js";
13
+ export * as faxes from "./faxes/index.js";
12
14
  export * from "./forms/client/requests/index.js";
13
15
  export * as forms from "./forms/index.js";
14
16
  export * from "./forms/types/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.webhooks = exports.tools = exports.status = exports.rcs = exports.phoneNumbers = exports.messages = exports.forms = exports.conversations = exports.contacts = exports.campaigns = exports.brands = exports.audiences = void 0;
39
+ exports.webhooks = exports.tools = exports.status = exports.rcs = exports.phoneNumbers = exports.messages = exports.forms = exports.faxes = exports.conversations = exports.contacts = exports.campaigns = exports.brands = exports.audiences = void 0;
40
40
  __exportStar(require("./audiences/client/requests/index.js"), exports);
41
41
  exports.audiences = __importStar(require("./audiences/index.js"));
42
42
  __exportStar(require("./audiences/types/index.js"), exports);
@@ -48,6 +48,8 @@ exports.contacts = __importStar(require("./contacts/index.js"));
48
48
  __exportStar(require("./conversations/client/requests/index.js"), exports);
49
49
  exports.conversations = __importStar(require("./conversations/index.js"));
50
50
  __exportStar(require("./conversations/types/index.js"), exports);
51
+ __exportStar(require("./faxes/client/requests/index.js"), exports);
52
+ exports.faxes = __importStar(require("./faxes/index.js"));
51
53
  __exportStar(require("./forms/client/requests/index.js"), exports);
52
54
  exports.forms = __importStar(require("./forms/index.js"));
53
55
  __exportStar(require("./forms/types/index.js"), exports);
@@ -0,0 +1,27 @@
1
+ import type * as Pinnacle from "../index.js";
2
+ export interface Fax {
3
+ id: string;
4
+ direction: Pinnacle.FaxDirectionEnum;
5
+ /** Sender number in E.164 format. */
6
+ from: string;
7
+ /** Recipient number in E.164 format. */
8
+ to: string;
9
+ status: Pinnacle.FaxStatusEnum;
10
+ /** Transmitted page count across the fax. This can be zero before transmission and can include only transmitted pages after a partial failure. Outbound documents can contain at most 3,500 pages. */
11
+ pages: number;
12
+ /** Total transmission duration in seconds. */
13
+ durationSeconds: number;
14
+ /** Whether only part of the document was delivered, including when an earlier part succeeded before a later part failed. */
15
+ partialContent: boolean;
16
+ failureReason: Pinnacle.FaxFailureReasonEnum | null;
17
+ /** Settled fax cost in USD, calculated at $0.025 per final transmitted page. Quality does not change the rate. */
18
+ cost: number;
19
+ /** Credit reserved after document preparation for an unsettled outbound fax, in USD. This equals $0.025 multiplied by the prepared page count, regardless of quality, and is zero while status is `PREPARING`. */
20
+ reservedCost: number;
21
+ /** `PENDING` while a reservation or uncertain submission remains open; `SETTLED` after final charging, refund, or cancellation. */
22
+ billingStatus: Pinnacle.FaxBillingStatusEnum;
23
+ /** Whether Pinnacle has archived the fax document. */
24
+ hasMedia: boolean;
25
+ createdAt: string;
26
+ updatedAt: string;
27
+ }
@@ -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,6 @@
1
+ /** Billing state for the fax. */
2
+ export declare const FaxBillingStatusEnum: {
3
+ readonly Pending: "PENDING";
4
+ readonly Settled: "SETTLED";
5
+ };
6
+ export type FaxBillingStatusEnum = (typeof FaxBillingStatusEnum)[keyof typeof FaxBillingStatusEnum];
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FaxBillingStatusEnum = void 0;
5
+ /** Billing state for the fax. */
6
+ exports.FaxBillingStatusEnum = {
7
+ Pending: "PENDING",
8
+ Settled: "SETTLED",
9
+ };