@surgeapi/node 0.25.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Client.d.ts +43 -0
- package/Client.js +37 -0
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/api/errors/ConflictError.d.ts +8 -0
- package/api/errors/ConflictError.js +51 -0
- package/api/errors/UnprocessableEntityError.d.ts +8 -0
- package/api/errors/UnprocessableEntityError.js +51 -0
- package/api/errors/index.d.ts +2 -0
- package/api/errors/index.js +18 -0
- package/api/index.d.ts +3 -0
- package/api/index.js +19 -0
- package/api/resources/blasts/client/Client.d.ts +50 -0
- package/api/resources/blasts/client/Client.js +123 -0
- package/api/resources/blasts/client/index.d.ts +1 -0
- package/api/resources/blasts/client/index.js +17 -0
- package/api/resources/blasts/client/requests/BlastRequest.d.ts +30 -0
- package/api/resources/blasts/client/requests/BlastRequest.js +5 -0
- package/api/resources/blasts/client/requests/index.d.ts +1 -0
- package/api/resources/blasts/client/requests/index.js +2 -0
- package/api/resources/blasts/index.d.ts +1 -0
- package/api/resources/blasts/index.js +17 -0
- package/api/resources/contacts/client/Client.d.ts +78 -0
- package/api/resources/contacts/client/Client.js +224 -0
- package/api/resources/contacts/client/index.d.ts +1 -0
- package/api/resources/contacts/client/index.js +2 -0
- package/api/resources/contacts/index.d.ts +1 -0
- package/api/resources/contacts/index.js +17 -0
- package/api/resources/index.d.ts +9 -0
- package/api/resources/index.js +48 -0
- package/api/resources/messages/client/Client.d.ts +55 -0
- package/api/resources/messages/client/Client.js +128 -0
- package/api/resources/messages/client/index.d.ts +1 -0
- package/api/resources/messages/client/index.js +17 -0
- package/api/resources/messages/client/requests/MessageRequest.d.ts +28 -0
- package/api/resources/messages/client/requests/MessageRequest.js +5 -0
- package/api/resources/messages/client/requests/index.d.ts +1 -0
- package/api/resources/messages/client/requests/index.js +2 -0
- package/api/resources/messages/index.d.ts +1 -0
- package/api/resources/messages/index.js +17 -0
- package/api/resources/users/client/Client.d.ts +59 -0
- package/api/resources/users/client/Client.js +168 -0
- package/api/resources/users/client/index.d.ts +1 -0
- package/api/resources/users/client/index.js +17 -0
- package/api/resources/users/client/requests/UserRequest.d.ts +25 -0
- package/api/resources/users/client/requests/UserRequest.js +5 -0
- package/api/resources/users/client/requests/index.d.ts +1 -0
- package/api/resources/users/client/requests/index.js +2 -0
- package/api/resources/users/index.d.ts +1 -0
- package/api/resources/users/index.js +17 -0
- package/api/resources/verifications/client/Client.d.ts +58 -0
- package/api/resources/verifications/client/Client.js +176 -0
- package/api/resources/verifications/client/index.d.ts +1 -0
- package/api/resources/verifications/client/index.js +17 -0
- package/api/resources/verifications/client/requests/VerificationCheckRequest.d.ts +13 -0
- package/api/resources/verifications/client/requests/VerificationCheckRequest.js +5 -0
- package/api/resources/verifications/client/requests/VerificationRequest.d.ts +13 -0
- package/api/resources/verifications/client/requests/VerificationRequest.js +5 -0
- package/api/resources/verifications/client/requests/index.d.ts +2 -0
- package/api/resources/verifications/client/requests/index.js +2 -0
- package/api/resources/verifications/index.d.ts +1 -0
- package/api/resources/verifications/index.js +17 -0
- package/api/types/AttachmentParams.d.ts +10 -0
- package/api/types/AttachmentParams.js +5 -0
- package/api/types/AttachmentResponse.d.ts +14 -0
- package/api/types/AttachmentResponse.js +5 -0
- package/api/types/BlastResponse.d.ts +18 -0
- package/api/types/BlastResponse.js +5 -0
- package/api/types/BlastResponseAttachmentsItem.d.ts +7 -0
- package/api/types/BlastResponseAttachmentsItem.js +5 -0
- package/api/types/Contact.d.ts +16 -0
- package/api/types/Contact.js +5 -0
- package/api/types/ContactRequest.d.ts +18 -0
- package/api/types/ContactRequest.js +5 -0
- package/api/types/ContactResponse.d.ts +20 -0
- package/api/types/ContactResponse.js +5 -0
- package/api/types/Conversation.d.ts +12 -0
- package/api/types/Conversation.js +5 -0
- package/api/types/MessageConversationContactParams.d.ts +16 -0
- package/api/types/MessageConversationContactParams.js +5 -0
- package/api/types/MessageConversationParams.d.ts +12 -0
- package/api/types/MessageConversationParams.js +5 -0
- package/api/types/MessageResponse.d.ts +15 -0
- package/api/types/MessageResponse.js +5 -0
- package/api/types/UserResponse.d.ts +18 -0
- package/api/types/UserResponse.js +5 -0
- package/api/types/Verification.d.ts +17 -0
- package/api/types/Verification.js +5 -0
- package/api/types/VerificationCheckAlreadyVerifiedResponse.d.ts +12 -0
- package/api/types/VerificationCheckAlreadyVerifiedResponse.js +5 -0
- package/api/types/VerificationCheckAlreadyVerifiedResponseResult.d.ts +14 -0
- package/api/types/VerificationCheckAlreadyVerifiedResponseResult.js +13 -0
- package/api/types/VerificationCheckIncorrectResponse.d.ts +12 -0
- package/api/types/VerificationCheckIncorrectResponse.js +5 -0
- package/api/types/VerificationCheckIncorrectResponseResult.d.ts +12 -0
- package/api/types/VerificationCheckIncorrectResponseResult.js +11 -0
- package/api/types/VerificationCheckOkResponse.d.ts +21 -0
- package/api/types/VerificationCheckOkResponse.js +5 -0
- package/api/types/VerificationCheckOkResponseResult.d.ts +21 -0
- package/api/types/VerificationCheckOkResponseResult.js +13 -0
- package/api/types/VerificationStatus.d.ts +13 -0
- package/api/types/VerificationStatus.js +12 -0
- package/api/types/index.d.ts +20 -0
- package/api/types/index.js +36 -0
- package/core/auth/BasicAuth.d.ts +8 -0
- package/core/auth/BasicAuth.js +26 -0
- package/core/auth/BearerToken.d.ts +5 -0
- package/core/auth/BearerToken.js +15 -0
- package/core/auth/index.d.ts +2 -0
- package/core/auth/index.js +7 -0
- package/core/fetcher/APIResponse.d.ts +10 -0
- package/core/fetcher/APIResponse.js +2 -0
- package/core/fetcher/Fetcher.d.ts +39 -0
- package/core/fetcher/Fetcher.js +100 -0
- package/core/fetcher/Supplier.d.ts +4 -0
- package/core/fetcher/Supplier.js +22 -0
- package/core/fetcher/createRequestUrl.d.ts +1 -0
- package/core/fetcher/createRequestUrl.js +12 -0
- package/core/fetcher/getFetchFn.d.ts +4 -0
- package/core/fetcher/getFetchFn.js +68 -0
- package/core/fetcher/getHeader.d.ts +1 -0
- package/core/fetcher/getHeader.js +11 -0
- package/core/fetcher/getRequestBody.d.ts +7 -0
- package/core/fetcher/getRequestBody.js +23 -0
- package/core/fetcher/getResponseBody.d.ts +1 -0
- package/core/fetcher/getResponseBody.js +54 -0
- package/core/fetcher/index.d.ts +5 -0
- package/core/fetcher/index.js +9 -0
- package/core/fetcher/makeRequest.d.ts +1 -0
- package/core/fetcher/makeRequest.js +42 -0
- package/core/fetcher/requestWithRetries.d.ts +1 -0
- package/core/fetcher/requestWithRetries.js +40 -0
- package/core/fetcher/signals.d.ts +11 -0
- package/core/fetcher/signals.js +36 -0
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +126 -0
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +59 -0
- package/core/index.d.ts +3 -0
- package/core/index.js +19 -0
- package/core/json.d.ts +15 -0
- package/core/json.js +24 -0
- package/core/runtime/index.d.ts +1 -0
- package/core/runtime/index.js +5 -0
- package/core/runtime/runtime.d.ts +9 -0
- package/core/runtime/runtime.js +103 -0
- package/dist/Client.d.ts +43 -0
- package/dist/Client.js +37 -0
- package/dist/api/errors/ConflictError.d.ts +8 -0
- package/dist/api/errors/ConflictError.js +51 -0
- package/dist/api/errors/UnprocessableEntityError.d.ts +8 -0
- package/dist/api/errors/UnprocessableEntityError.js +51 -0
- package/dist/api/errors/index.d.ts +2 -0
- package/dist/api/errors/index.js +18 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +19 -0
- package/dist/api/resources/blasts/client/Client.d.ts +50 -0
- package/dist/api/resources/blasts/client/Client.js +123 -0
- package/dist/api/resources/blasts/client/index.d.ts +1 -0
- package/dist/api/resources/blasts/client/index.js +17 -0
- package/dist/api/resources/blasts/client/requests/BlastRequest.d.ts +30 -0
- package/dist/api/resources/blasts/client/requests/BlastRequest.js +5 -0
- package/dist/api/resources/blasts/client/requests/index.d.ts +1 -0
- package/dist/api/resources/blasts/client/requests/index.js +2 -0
- package/dist/api/resources/blasts/index.d.ts +1 -0
- package/dist/api/resources/blasts/index.js +17 -0
- package/dist/api/resources/contacts/client/Client.d.ts +78 -0
- package/dist/api/resources/contacts/client/Client.js +224 -0
- package/dist/api/resources/contacts/client/index.d.ts +1 -0
- package/dist/api/resources/contacts/client/index.js +2 -0
- package/dist/api/resources/contacts/index.d.ts +1 -0
- package/dist/api/resources/contacts/index.js +17 -0
- package/dist/api/resources/index.d.ts +9 -0
- package/dist/api/resources/index.js +48 -0
- package/dist/api/resources/messages/client/Client.d.ts +55 -0
- package/dist/api/resources/messages/client/Client.js +128 -0
- package/dist/api/resources/messages/client/index.d.ts +1 -0
- package/dist/api/resources/messages/client/index.js +17 -0
- package/dist/api/resources/messages/client/requests/MessageRequest.d.ts +28 -0
- package/dist/api/resources/messages/client/requests/MessageRequest.js +5 -0
- package/dist/api/resources/messages/client/requests/index.d.ts +1 -0
- package/dist/api/resources/messages/client/requests/index.js +2 -0
- package/dist/api/resources/messages/index.d.ts +1 -0
- package/dist/api/resources/messages/index.js +17 -0
- package/dist/api/resources/users/client/Client.d.ts +59 -0
- package/dist/api/resources/users/client/Client.js +168 -0
- package/dist/api/resources/users/client/index.d.ts +1 -0
- package/dist/api/resources/users/client/index.js +17 -0
- package/dist/api/resources/users/client/requests/UserRequest.d.ts +25 -0
- package/dist/api/resources/users/client/requests/UserRequest.js +5 -0
- package/dist/api/resources/users/client/requests/index.d.ts +1 -0
- package/dist/api/resources/users/client/requests/index.js +2 -0
- package/dist/api/resources/users/index.d.ts +1 -0
- package/dist/api/resources/users/index.js +17 -0
- package/dist/api/resources/verifications/client/Client.d.ts +58 -0
- package/dist/api/resources/verifications/client/Client.js +176 -0
- package/dist/api/resources/verifications/client/index.d.ts +1 -0
- package/dist/api/resources/verifications/client/index.js +17 -0
- package/dist/api/resources/verifications/client/requests/VerificationCheckRequest.d.ts +13 -0
- package/dist/api/resources/verifications/client/requests/VerificationCheckRequest.js +5 -0
- package/dist/api/resources/verifications/client/requests/VerificationRequest.d.ts +13 -0
- package/dist/api/resources/verifications/client/requests/VerificationRequest.js +5 -0
- package/dist/api/resources/verifications/client/requests/index.d.ts +2 -0
- package/dist/api/resources/verifications/client/requests/index.js +2 -0
- package/dist/api/resources/verifications/index.d.ts +1 -0
- package/dist/api/resources/verifications/index.js +17 -0
- package/dist/api/types/AttachmentParams.d.ts +10 -0
- package/dist/api/types/AttachmentParams.js +5 -0
- package/dist/api/types/AttachmentResponse.d.ts +14 -0
- package/dist/api/types/AttachmentResponse.js +5 -0
- package/dist/api/types/BlastResponse.d.ts +18 -0
- package/dist/api/types/BlastResponse.js +5 -0
- package/dist/api/types/BlastResponseAttachmentsItem.d.ts +7 -0
- package/dist/api/types/BlastResponseAttachmentsItem.js +5 -0
- package/dist/api/types/Contact.d.ts +16 -0
- package/dist/api/types/Contact.js +5 -0
- package/dist/api/types/ContactRequest.d.ts +18 -0
- package/dist/api/types/ContactRequest.js +5 -0
- package/dist/api/types/ContactResponse.d.ts +20 -0
- package/dist/api/types/ContactResponse.js +5 -0
- package/dist/api/types/Conversation.d.ts +12 -0
- package/dist/api/types/Conversation.js +5 -0
- package/dist/api/types/MessageConversationContactParams.d.ts +16 -0
- package/dist/api/types/MessageConversationContactParams.js +5 -0
- package/dist/api/types/MessageConversationParams.d.ts +12 -0
- package/dist/api/types/MessageConversationParams.js +5 -0
- package/dist/api/types/MessageResponse.d.ts +15 -0
- package/dist/api/types/MessageResponse.js +5 -0
- package/dist/api/types/UserResponse.d.ts +18 -0
- package/dist/api/types/UserResponse.js +5 -0
- package/dist/api/types/Verification.d.ts +17 -0
- package/dist/api/types/Verification.js +5 -0
- package/dist/api/types/VerificationCheckAlreadyVerifiedResponse.d.ts +12 -0
- package/dist/api/types/VerificationCheckAlreadyVerifiedResponse.js +5 -0
- package/dist/api/types/VerificationCheckAlreadyVerifiedResponseResult.d.ts +14 -0
- package/dist/api/types/VerificationCheckAlreadyVerifiedResponseResult.js +13 -0
- package/dist/api/types/VerificationCheckIncorrectResponse.d.ts +12 -0
- package/dist/api/types/VerificationCheckIncorrectResponse.js +5 -0
- package/dist/api/types/VerificationCheckIncorrectResponseResult.d.ts +12 -0
- package/dist/api/types/VerificationCheckIncorrectResponseResult.js +11 -0
- package/dist/api/types/VerificationCheckOkResponse.d.ts +21 -0
- package/dist/api/types/VerificationCheckOkResponse.js +5 -0
- package/dist/api/types/VerificationCheckOkResponseResult.d.ts +21 -0
- package/dist/api/types/VerificationCheckOkResponseResult.js +13 -0
- package/dist/api/types/VerificationStatus.d.ts +13 -0
- package/dist/api/types/VerificationStatus.js +12 -0
- package/dist/api/types/index.d.ts +20 -0
- package/dist/api/types/index.js +36 -0
- package/dist/core/auth/BasicAuth.d.ts +8 -0
- package/dist/core/auth/BasicAuth.js +26 -0
- package/dist/core/auth/BearerToken.d.ts +5 -0
- package/dist/core/auth/BearerToken.js +15 -0
- package/dist/core/auth/index.d.ts +2 -0
- package/dist/core/auth/index.js +7 -0
- package/dist/core/fetcher/APIResponse.d.ts +10 -0
- package/dist/core/fetcher/APIResponse.js +2 -0
- package/dist/core/fetcher/Fetcher.d.ts +39 -0
- package/dist/core/fetcher/Fetcher.js +100 -0
- package/dist/core/fetcher/Supplier.d.ts +4 -0
- package/dist/core/fetcher/Supplier.js +22 -0
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +12 -0
- package/dist/core/fetcher/getFetchFn.d.ts +4 -0
- package/dist/core/fetcher/getFetchFn.js +68 -0
- package/dist/core/fetcher/getHeader.d.ts +1 -0
- package/dist/core/fetcher/getHeader.js +11 -0
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +23 -0
- package/dist/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getResponseBody.js +54 -0
- package/dist/core/fetcher/index.d.ts +5 -0
- package/dist/core/fetcher/index.js +9 -0
- package/dist/core/fetcher/makeRequest.d.ts +1 -0
- package/dist/core/fetcher/makeRequest.js +42 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +40 -0
- package/dist/core/fetcher/signals.d.ts +11 -0
- package/dist/core/fetcher/signals.js +36 -0
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +126 -0
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +59 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +19 -0
- package/dist/core/json.d.ts +15 -0
- package/dist/core/json.js +24 -0
- package/dist/core/runtime/index.d.ts +1 -0
- package/dist/core/runtime/index.js +5 -0
- package/dist/core/runtime/runtime.d.ts +9 -0
- package/dist/core/runtime/runtime.js +103 -0
- package/dist/environments.d.ts +7 -0
- package/dist/environments.js +9 -0
- package/dist/errors/SurgeError.d.ts +12 -0
- package/dist/errors/SurgeError.js +33 -0
- package/dist/errors/SurgeTimeoutError.d.ts +6 -0
- package/dist/errors/SurgeTimeoutError.js +13 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +44 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +4 -0
- package/environments.d.ts +7 -0
- package/environments.js +9 -0
- package/errors/SurgeError.d.ts +12 -0
- package/errors/SurgeError.js +33 -0
- package/errors/SurgeTimeoutError.d.ts +6 -0
- package/errors/SurgeTimeoutError.js +13 -0
- package/errors/index.d.ts +2 -0
- package/errors/index.js +7 -0
- package/index.d.ts +4 -0
- package/index.js +44 -0
- package/jest.config.mjs +8 -0
- package/package.json +44 -0
- package/reference.md +681 -0
- package/scripts/rename-to-esm-files.js +115 -0
- package/version.d.ts +1 -0
- package/version.js +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type BlastRequest } from "./BlastRequest";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./client";
|
|
@@ -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"), exports);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as environments from "../../../../environments";
|
|
5
|
+
import * as core from "../../../../core";
|
|
6
|
+
import * as Surge from "../../../index";
|
|
7
|
+
export declare namespace Contacts {
|
|
8
|
+
interface Options {
|
|
9
|
+
environment?: core.Supplier<environments.SurgeEnvironment | string>;
|
|
10
|
+
/** Specify a custom URL to connect the client to. */
|
|
11
|
+
baseUrl?: core.Supplier<string>;
|
|
12
|
+
token: core.Supplier<core.BearerToken>;
|
|
13
|
+
fetcher?: core.FetchFunction;
|
|
14
|
+
}
|
|
15
|
+
interface RequestOptions {
|
|
16
|
+
/** The maximum time to wait for a response in seconds. */
|
|
17
|
+
timeoutInSeconds?: number;
|
|
18
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
19
|
+
maxRetries?: number;
|
|
20
|
+
/** A hook to abort the request. */
|
|
21
|
+
abortSignal?: AbortSignal;
|
|
22
|
+
/** Additional headers to include in the request. */
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export declare class Contacts {
|
|
27
|
+
protected readonly _options: Contacts.Options;
|
|
28
|
+
constructor(_options: Contacts.Options);
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new Contact object.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} accountId - The account for which the contact should be created.
|
|
33
|
+
* @param {Surge.ContactRequest} request
|
|
34
|
+
* @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* await client.contacts.create("acct_01j9a43avnfqzbjfch6pygv1td", {
|
|
38
|
+
* email: "dom@toretto.family",
|
|
39
|
+
* first_name: "Dominic",
|
|
40
|
+
* last_name: "Toretto",
|
|
41
|
+
* metadata: {
|
|
42
|
+
* "car": "1970 Dodge Charger R/T"
|
|
43
|
+
* },
|
|
44
|
+
* phone_number: "+18015551234"
|
|
45
|
+
* })
|
|
46
|
+
*/
|
|
47
|
+
create(accountId: string, request: Surge.ContactRequest, requestOptions?: Contacts.RequestOptions): Promise<Surge.ContactResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves a Contact object.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} id -
|
|
52
|
+
* @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* await client.contacts.surgeWebContactControllerShow("ctc_01j9dy8mdzfn3r0e8x1tbdrdrf")
|
|
56
|
+
*/
|
|
57
|
+
surgeWebContactControllerShow(id: string, requestOptions?: Contacts.RequestOptions): Promise<Surge.ContactResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Updates the specified contact by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} id -
|
|
62
|
+
* @param {Surge.ContactRequest} request
|
|
63
|
+
* @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* await client.contacts.update("ctc_01j9dy8mdzfn3r0e8x1tbdrdrf", {
|
|
67
|
+
* email: "dom@toretto.family",
|
|
68
|
+
* first_name: "Dominic",
|
|
69
|
+
* last_name: "Toretto",
|
|
70
|
+
* metadata: {
|
|
71
|
+
* "car": "1970 Dodge Charger R/T"
|
|
72
|
+
* },
|
|
73
|
+
* phone_number: "+18015551234"
|
|
74
|
+
* })
|
|
75
|
+
*/
|
|
76
|
+
update(id: string, request: Surge.ContactRequest, requestOptions?: Contacts.RequestOptions): Promise<Surge.ContactResponse>;
|
|
77
|
+
protected _getAuthorizationHeader(): Promise<string>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
39
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.Contacts = void 0;
|
|
52
|
+
const environments = __importStar(require("../../../../environments"));
|
|
53
|
+
const core = __importStar(require("../../../../core"));
|
|
54
|
+
const url_join_1 = __importDefault(require("url-join"));
|
|
55
|
+
const errors = __importStar(require("../../../../errors/index"));
|
|
56
|
+
class Contacts {
|
|
57
|
+
constructor(_options) {
|
|
58
|
+
this._options = _options;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new Contact object.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} accountId - The account for which the contact should be created.
|
|
64
|
+
* @param {Surge.ContactRequest} request
|
|
65
|
+
* @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* await client.contacts.create("acct_01j9a43avnfqzbjfch6pygv1td", {
|
|
69
|
+
* email: "dom@toretto.family",
|
|
70
|
+
* first_name: "Dominic",
|
|
71
|
+
* last_name: "Toretto",
|
|
72
|
+
* metadata: {
|
|
73
|
+
* "car": "1970 Dodge Charger R/T"
|
|
74
|
+
* },
|
|
75
|
+
* phone_number: "+18015551234"
|
|
76
|
+
* })
|
|
77
|
+
*/
|
|
78
|
+
create(accountId, request, requestOptions) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
82
|
+
url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `accounts/${encodeURIComponent(accountId)}/contacts`),
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.3", "User-Agent": "@surgeapi/node/0.25.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
85
|
+
contentType: "application/json",
|
|
86
|
+
requestType: "json",
|
|
87
|
+
body: request,
|
|
88
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
89
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
90
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
91
|
+
});
|
|
92
|
+
if (_response.ok) {
|
|
93
|
+
return _response.body;
|
|
94
|
+
}
|
|
95
|
+
if (_response.error.reason === "status-code") {
|
|
96
|
+
throw new errors.SurgeError({
|
|
97
|
+
statusCode: _response.error.statusCode,
|
|
98
|
+
body: _response.error.body,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
switch (_response.error.reason) {
|
|
102
|
+
case "non-json":
|
|
103
|
+
throw new errors.SurgeError({
|
|
104
|
+
statusCode: _response.error.statusCode,
|
|
105
|
+
body: _response.error.rawBody,
|
|
106
|
+
});
|
|
107
|
+
case "timeout":
|
|
108
|
+
throw new errors.SurgeTimeoutError("Timeout exceeded when calling POST /accounts/{account_id}/contacts.");
|
|
109
|
+
case "unknown":
|
|
110
|
+
throw new errors.SurgeError({
|
|
111
|
+
message: _response.error.errorMessage,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves a Contact object.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} id -
|
|
120
|
+
* @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* await client.contacts.surgeWebContactControllerShow("ctc_01j9dy8mdzfn3r0e8x1tbdrdrf")
|
|
124
|
+
*/
|
|
125
|
+
surgeWebContactControllerShow(id, requestOptions) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
var _a, _b, _c;
|
|
128
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
129
|
+
url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `contacts/${encodeURIComponent(id)}`),
|
|
130
|
+
method: "GET",
|
|
131
|
+
headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.3", "User-Agent": "@surgeapi/node/0.25.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
132
|
+
contentType: "application/json",
|
|
133
|
+
requestType: "json",
|
|
134
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
135
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
136
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
137
|
+
});
|
|
138
|
+
if (_response.ok) {
|
|
139
|
+
return _response.body;
|
|
140
|
+
}
|
|
141
|
+
if (_response.error.reason === "status-code") {
|
|
142
|
+
throw new errors.SurgeError({
|
|
143
|
+
statusCode: _response.error.statusCode,
|
|
144
|
+
body: _response.error.body,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
switch (_response.error.reason) {
|
|
148
|
+
case "non-json":
|
|
149
|
+
throw new errors.SurgeError({
|
|
150
|
+
statusCode: _response.error.statusCode,
|
|
151
|
+
body: _response.error.rawBody,
|
|
152
|
+
});
|
|
153
|
+
case "timeout":
|
|
154
|
+
throw new errors.SurgeTimeoutError("Timeout exceeded when calling GET /contacts/{id}.");
|
|
155
|
+
case "unknown":
|
|
156
|
+
throw new errors.SurgeError({
|
|
157
|
+
message: _response.error.errorMessage,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Updates the specified contact by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
|
|
164
|
+
*
|
|
165
|
+
* @param {string} id -
|
|
166
|
+
* @param {Surge.ContactRequest} request
|
|
167
|
+
* @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* await client.contacts.update("ctc_01j9dy8mdzfn3r0e8x1tbdrdrf", {
|
|
171
|
+
* email: "dom@toretto.family",
|
|
172
|
+
* first_name: "Dominic",
|
|
173
|
+
* last_name: "Toretto",
|
|
174
|
+
* metadata: {
|
|
175
|
+
* "car": "1970 Dodge Charger R/T"
|
|
176
|
+
* },
|
|
177
|
+
* phone_number: "+18015551234"
|
|
178
|
+
* })
|
|
179
|
+
*/
|
|
180
|
+
update(id, request, requestOptions) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
var _a, _b, _c;
|
|
183
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
184
|
+
url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `contacts/${encodeURIComponent(id)}`),
|
|
185
|
+
method: "PUT",
|
|
186
|
+
headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.3", "User-Agent": "@surgeapi/node/0.25.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
187
|
+
contentType: "application/json",
|
|
188
|
+
requestType: "json",
|
|
189
|
+
body: request,
|
|
190
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
191
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
192
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
193
|
+
});
|
|
194
|
+
if (_response.ok) {
|
|
195
|
+
return _response.body;
|
|
196
|
+
}
|
|
197
|
+
if (_response.error.reason === "status-code") {
|
|
198
|
+
throw new errors.SurgeError({
|
|
199
|
+
statusCode: _response.error.statusCode,
|
|
200
|
+
body: _response.error.body,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
switch (_response.error.reason) {
|
|
204
|
+
case "non-json":
|
|
205
|
+
throw new errors.SurgeError({
|
|
206
|
+
statusCode: _response.error.statusCode,
|
|
207
|
+
body: _response.error.rawBody,
|
|
208
|
+
});
|
|
209
|
+
case "timeout":
|
|
210
|
+
throw new errors.SurgeTimeoutError("Timeout exceeded when calling PUT /contacts/{id}.");
|
|
211
|
+
case "unknown":
|
|
212
|
+
throw new errors.SurgeError({
|
|
213
|
+
message: _response.error.errorMessage,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
_getAuthorizationHeader() {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
return `Bearer ${yield core.Supplier.get(this._options.token)}`;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
exports.Contacts = Contacts;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./client";
|
|
@@ -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"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * as blasts from "./blasts";
|
|
2
|
+
export * as contacts from "./contacts";
|
|
3
|
+
export * as messages from "./messages";
|
|
4
|
+
export * as users from "./users";
|
|
5
|
+
export * as verifications from "./verifications";
|
|
6
|
+
export * from "./blasts/client/requests";
|
|
7
|
+
export * from "./messages/client/requests";
|
|
8
|
+
export * from "./users/client/requests";
|
|
9
|
+
export * from "./verifications/client/requests";
|
|
@@ -0,0 +1,48 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.verifications = exports.users = exports.messages = exports.contacts = exports.blasts = void 0;
|
|
40
|
+
exports.blasts = __importStar(require("./blasts"));
|
|
41
|
+
exports.contacts = __importStar(require("./contacts"));
|
|
42
|
+
exports.messages = __importStar(require("./messages"));
|
|
43
|
+
exports.users = __importStar(require("./users"));
|
|
44
|
+
exports.verifications = __importStar(require("./verifications"));
|
|
45
|
+
__exportStar(require("./blasts/client/requests"), exports);
|
|
46
|
+
__exportStar(require("./messages/client/requests"), exports);
|
|
47
|
+
__exportStar(require("./users/client/requests"), exports);
|
|
48
|
+
__exportStar(require("./verifications/client/requests"), exports);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as environments from "../../../../environments";
|
|
5
|
+
import * as core from "../../../../core";
|
|
6
|
+
import * as Surge from "../../../index";
|
|
7
|
+
export declare namespace Messages {
|
|
8
|
+
interface Options {
|
|
9
|
+
environment?: core.Supplier<environments.SurgeEnvironment | string>;
|
|
10
|
+
/** Specify a custom URL to connect the client to. */
|
|
11
|
+
baseUrl?: core.Supplier<string>;
|
|
12
|
+
token: core.Supplier<core.BearerToken>;
|
|
13
|
+
fetcher?: core.FetchFunction;
|
|
14
|
+
}
|
|
15
|
+
interface RequestOptions {
|
|
16
|
+
/** The maximum time to wait for a response in seconds. */
|
|
17
|
+
timeoutInSeconds?: number;
|
|
18
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
19
|
+
maxRetries?: number;
|
|
20
|
+
/** A hook to abort the request. */
|
|
21
|
+
abortSignal?: AbortSignal;
|
|
22
|
+
/** Additional headers to include in the request. */
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export declare class Messages {
|
|
27
|
+
protected readonly _options: Messages.Options;
|
|
28
|
+
constructor(_options: Messages.Options);
|
|
29
|
+
/**
|
|
30
|
+
* Sends a Message.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} accountId - The account for which the message should be sent.
|
|
33
|
+
* @param {Surge.MessageRequest} request
|
|
34
|
+
* @param {Messages.RequestOptions} requestOptions - Request-specific configuration.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* await client.messages.send("acct_01j9a43avnfqzbjfch6pygv1td", {
|
|
38
|
+
* attachments: [{
|
|
39
|
+
* url: "https://toretto.family/coronas.gif"
|
|
40
|
+
* }],
|
|
41
|
+
* body: "Thought you could leave without saying goodbye?",
|
|
42
|
+
* conversation: {
|
|
43
|
+
* contact: {
|
|
44
|
+
* first_name: "Dominic",
|
|
45
|
+
* id: "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
|
|
46
|
+
* last_name: "Toretto",
|
|
47
|
+
* phone_number: "+18015551234"
|
|
48
|
+
* },
|
|
49
|
+
* id: "cnv_01j9e0dgmdfkj86c877ws0znae"
|
|
50
|
+
* }
|
|
51
|
+
* })
|
|
52
|
+
*/
|
|
53
|
+
send(accountId: string, request: Surge.MessageRequest, requestOptions?: Messages.RequestOptions): Promise<Surge.MessageResponse>;
|
|
54
|
+
protected _getAuthorizationHeader(): Promise<string>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
39
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.Messages = void 0;
|
|
52
|
+
const environments = __importStar(require("../../../../environments"));
|
|
53
|
+
const core = __importStar(require("../../../../core"));
|
|
54
|
+
const url_join_1 = __importDefault(require("url-join"));
|
|
55
|
+
const errors = __importStar(require("../../../../errors/index"));
|
|
56
|
+
class Messages {
|
|
57
|
+
constructor(_options) {
|
|
58
|
+
this._options = _options;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sends a Message.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} accountId - The account for which the message should be sent.
|
|
64
|
+
* @param {Surge.MessageRequest} request
|
|
65
|
+
* @param {Messages.RequestOptions} requestOptions - Request-specific configuration.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* await client.messages.send("acct_01j9a43avnfqzbjfch6pygv1td", {
|
|
69
|
+
* attachments: [{
|
|
70
|
+
* url: "https://toretto.family/coronas.gif"
|
|
71
|
+
* }],
|
|
72
|
+
* body: "Thought you could leave without saying goodbye?",
|
|
73
|
+
* conversation: {
|
|
74
|
+
* contact: {
|
|
75
|
+
* first_name: "Dominic",
|
|
76
|
+
* id: "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
|
|
77
|
+
* last_name: "Toretto",
|
|
78
|
+
* phone_number: "+18015551234"
|
|
79
|
+
* },
|
|
80
|
+
* id: "cnv_01j9e0dgmdfkj86c877ws0znae"
|
|
81
|
+
* }
|
|
82
|
+
* })
|
|
83
|
+
*/
|
|
84
|
+
send(accountId, request, requestOptions) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
var _a, _b, _c;
|
|
87
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
88
|
+
url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `accounts/${encodeURIComponent(accountId)}/messages`),
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.3", "User-Agent": "@surgeapi/node/0.25.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
91
|
+
contentType: "application/json",
|
|
92
|
+
requestType: "json",
|
|
93
|
+
body: request,
|
|
94
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
95
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
96
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
97
|
+
});
|
|
98
|
+
if (_response.ok) {
|
|
99
|
+
return _response.body;
|
|
100
|
+
}
|
|
101
|
+
if (_response.error.reason === "status-code") {
|
|
102
|
+
throw new errors.SurgeError({
|
|
103
|
+
statusCode: _response.error.statusCode,
|
|
104
|
+
body: _response.error.body,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
switch (_response.error.reason) {
|
|
108
|
+
case "non-json":
|
|
109
|
+
throw new errors.SurgeError({
|
|
110
|
+
statusCode: _response.error.statusCode,
|
|
111
|
+
body: _response.error.rawBody,
|
|
112
|
+
});
|
|
113
|
+
case "timeout":
|
|
114
|
+
throw new errors.SurgeTimeoutError("Timeout exceeded when calling POST /accounts/{account_id}/messages.");
|
|
115
|
+
case "unknown":
|
|
116
|
+
throw new errors.SurgeError({
|
|
117
|
+
message: _response.error.errorMessage,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
_getAuthorizationHeader() {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
return `Bearer ${yield core.Supplier.get(this._options.token)}`;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.Messages = Messages;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests";
|
|
@@ -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"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as Surge from "../../../../index";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* {
|
|
8
|
+
* attachments: [{
|
|
9
|
+
* url: "https://toretto.family/coronas.gif"
|
|
10
|
+
* }],
|
|
11
|
+
* body: "Thought you could leave without saying goodbye?",
|
|
12
|
+
* conversation: {
|
|
13
|
+
* contact: {
|
|
14
|
+
* first_name: "Dominic",
|
|
15
|
+
* id: "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
|
|
16
|
+
* last_name: "Toretto",
|
|
17
|
+
* phone_number: "+18015551234"
|
|
18
|
+
* },
|
|
19
|
+
* id: "cnv_01j9e0dgmdfkj86c877ws0znae"
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
export interface MessageRequest {
|
|
24
|
+
attachments?: Surge.AttachmentParams[];
|
|
25
|
+
/** The message body. */
|
|
26
|
+
body?: string;
|
|
27
|
+
conversation: Surge.MessageConversationParams;
|
|
28
|
+
}
|