@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
package/Client.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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 { Blasts } from "./api/resources/blasts/client/Client";
|
|
7
|
+
import { Contacts } from "./api/resources/contacts/client/Client";
|
|
8
|
+
import { Messages } from "./api/resources/messages/client/Client";
|
|
9
|
+
import { Users } from "./api/resources/users/client/Client";
|
|
10
|
+
import { Verifications } from "./api/resources/verifications/client/Client";
|
|
11
|
+
export declare namespace SurgeClient {
|
|
12
|
+
interface Options {
|
|
13
|
+
environment?: core.Supplier<environments.SurgeEnvironment | string>;
|
|
14
|
+
/** Specify a custom URL to connect the client to. */
|
|
15
|
+
baseUrl?: core.Supplier<string>;
|
|
16
|
+
token: core.Supplier<core.BearerToken>;
|
|
17
|
+
fetcher?: core.FetchFunction;
|
|
18
|
+
}
|
|
19
|
+
interface RequestOptions {
|
|
20
|
+
/** The maximum time to wait for a response in seconds. */
|
|
21
|
+
timeoutInSeconds?: number;
|
|
22
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
/** A hook to abort the request. */
|
|
25
|
+
abortSignal?: AbortSignal;
|
|
26
|
+
/** Additional headers to include in the request. */
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export declare class SurgeClient {
|
|
31
|
+
protected readonly _options: SurgeClient.Options;
|
|
32
|
+
protected _blasts: Blasts | undefined;
|
|
33
|
+
protected _contacts: Contacts | undefined;
|
|
34
|
+
protected _messages: Messages | undefined;
|
|
35
|
+
protected _users: Users | undefined;
|
|
36
|
+
protected _verifications: Verifications | undefined;
|
|
37
|
+
constructor(_options: SurgeClient.Options);
|
|
38
|
+
get blasts(): Blasts;
|
|
39
|
+
get contacts(): Contacts;
|
|
40
|
+
get messages(): Messages;
|
|
41
|
+
get users(): Users;
|
|
42
|
+
get verifications(): Verifications;
|
|
43
|
+
}
|
package/Client.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SurgeClient = void 0;
|
|
7
|
+
const Client_1 = require("./api/resources/blasts/client/Client");
|
|
8
|
+
const Client_2 = require("./api/resources/contacts/client/Client");
|
|
9
|
+
const Client_3 = require("./api/resources/messages/client/Client");
|
|
10
|
+
const Client_4 = require("./api/resources/users/client/Client");
|
|
11
|
+
const Client_5 = require("./api/resources/verifications/client/Client");
|
|
12
|
+
class SurgeClient {
|
|
13
|
+
constructor(_options) {
|
|
14
|
+
this._options = _options;
|
|
15
|
+
}
|
|
16
|
+
get blasts() {
|
|
17
|
+
var _a;
|
|
18
|
+
return ((_a = this._blasts) !== null && _a !== void 0 ? _a : (this._blasts = new Client_1.Blasts(this._options)));
|
|
19
|
+
}
|
|
20
|
+
get contacts() {
|
|
21
|
+
var _a;
|
|
22
|
+
return ((_a = this._contacts) !== null && _a !== void 0 ? _a : (this._contacts = new Client_2.Contacts(this._options)));
|
|
23
|
+
}
|
|
24
|
+
get messages() {
|
|
25
|
+
var _a;
|
|
26
|
+
return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new Client_3.Messages(this._options)));
|
|
27
|
+
}
|
|
28
|
+
get users() {
|
|
29
|
+
var _a;
|
|
30
|
+
return ((_a = this._users) !== null && _a !== void 0 ? _a : (this._users = new Client_4.Users(this._options)));
|
|
31
|
+
}
|
|
32
|
+
get verifications() {
|
|
33
|
+
var _a;
|
|
34
|
+
return ((_a = this._verifications) !== null && _a !== void 0 ? _a : (this._verifications = new Client_5.Verifications(this._options)));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.SurgeClient = SurgeClient;
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Surge.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Surge TypeScript Library
|
|
2
|
+
|
|
3
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fsurgemsg%2Ftypescript-sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/@surgeapi/node)
|
|
5
|
+
|
|
6
|
+
The Surge TypeScript library provides convenient access to the Surge API from TypeScript.
|
|
7
|
+
|
|
8
|
+
## Documentation
|
|
9
|
+
|
|
10
|
+
API reference documentation is available [here](https://surge.app).
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm i -s @surgeapi/node
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Reference
|
|
19
|
+
|
|
20
|
+
A full reference for this library is available [here](./reference.md).
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
Instantiate and use the client with the following:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { SurgeClient } from "@surgeapi/node";
|
|
28
|
+
|
|
29
|
+
const client = new SurgeClient({ token: "YOUR_TOKEN" });
|
|
30
|
+
await client.messages.send("acct_01j9a43avnfqzbjfch6pygv1td", {
|
|
31
|
+
attachments: [
|
|
32
|
+
{
|
|
33
|
+
url: "https://toretto.family/coronas.gif",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
body: "Thought you could leave without saying goodbye?",
|
|
37
|
+
conversation: {
|
|
38
|
+
contact: {
|
|
39
|
+
first_name: "Dominic",
|
|
40
|
+
id: "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
|
|
41
|
+
last_name: "Toretto",
|
|
42
|
+
phone_number: "+18015551234",
|
|
43
|
+
},
|
|
44
|
+
id: "cnv_01j9e0dgmdfkj86c877ws0znae",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Request And Response Types
|
|
50
|
+
|
|
51
|
+
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
|
|
52
|
+
following namespace:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { Surge } from "@surgeapi/node";
|
|
56
|
+
|
|
57
|
+
const request: Surge.BlastRequest = {
|
|
58
|
+
...
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Exception Handling
|
|
63
|
+
|
|
64
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
65
|
+
will be thrown.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { SurgeError } from "@surgeapi/node";
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
await client.messages.send(...);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
if (err instanceof SurgeError) {
|
|
74
|
+
console.log(err.statusCode);
|
|
75
|
+
console.log(err.message);
|
|
76
|
+
console.log(err.body);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Advanced
|
|
82
|
+
|
|
83
|
+
### Additional Headers
|
|
84
|
+
|
|
85
|
+
If you would like to send additional headers as part of the request, use the `headers` request option.
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const response = await client.messages.send(..., {
|
|
89
|
+
headers: {
|
|
90
|
+
'X-Custom-Header': 'custom value'
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Retries
|
|
96
|
+
|
|
97
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
98
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
99
|
+
retry limit (default: 2).
|
|
100
|
+
|
|
101
|
+
A request is deemed retryable when any of the following HTTP status codes is returned:
|
|
102
|
+
|
|
103
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
104
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
105
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
106
|
+
|
|
107
|
+
Use the `maxRetries` request option to configure this behavior.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const response = await client.messages.send(..., {
|
|
111
|
+
maxRetries: 0 // override maxRetries at the request level
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Timeouts
|
|
116
|
+
|
|
117
|
+
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
const response = await client.messages.send(..., {
|
|
121
|
+
timeoutInSeconds: 30 // override timeout to 30s
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Aborting Requests
|
|
126
|
+
|
|
127
|
+
The SDK allows users to abort requests at any point by passing in an abort signal.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
const controller = new AbortController();
|
|
131
|
+
const response = await client.messages.send(..., {
|
|
132
|
+
abortSignal: controller.signal
|
|
133
|
+
});
|
|
134
|
+
controller.abort(); // aborts the request
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Runtime Compatibility
|
|
138
|
+
|
|
139
|
+
The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following
|
|
140
|
+
runtimes:
|
|
141
|
+
|
|
142
|
+
- Node.js 18+
|
|
143
|
+
- Vercel
|
|
144
|
+
- Cloudflare Workers
|
|
145
|
+
- Deno v1.25+
|
|
146
|
+
- Bun 1.0+
|
|
147
|
+
- React Native
|
|
148
|
+
|
|
149
|
+
### Customizing Fetch Client
|
|
150
|
+
|
|
151
|
+
The SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an
|
|
152
|
+
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { SurgeClient } from "@surgeapi/node";
|
|
156
|
+
|
|
157
|
+
const client = new SurgeClient({
|
|
158
|
+
...
|
|
159
|
+
fetcher: // provide your implementation here
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Contributing
|
|
164
|
+
|
|
165
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
166
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
167
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
168
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
169
|
+
an issue first to discuss with us!
|
|
170
|
+
|
|
171
|
+
On the other hand, contributions to the README are always very welcome!
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as errors from "../../errors/index";
|
|
5
|
+
import * as Surge from "../index";
|
|
6
|
+
export declare class ConflictError extends errors.SurgeError {
|
|
7
|
+
constructor(body: Surge.VerificationCheckAlreadyVerifiedResponse);
|
|
8
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ConflictError = void 0;
|
|
40
|
+
const errors = __importStar(require("../../errors/index"));
|
|
41
|
+
class ConflictError extends errors.SurgeError {
|
|
42
|
+
constructor(body) {
|
|
43
|
+
super({
|
|
44
|
+
message: "ConflictError",
|
|
45
|
+
statusCode: 409,
|
|
46
|
+
body: body,
|
|
47
|
+
});
|
|
48
|
+
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.ConflictError = ConflictError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as errors from "../../errors/index";
|
|
5
|
+
import * as Surge from "../index";
|
|
6
|
+
export declare class UnprocessableEntityError extends errors.SurgeError {
|
|
7
|
+
constructor(body: Surge.VerificationCheckIncorrectResponse);
|
|
8
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.UnprocessableEntityError = void 0;
|
|
40
|
+
const errors = __importStar(require("../../errors/index"));
|
|
41
|
+
class UnprocessableEntityError extends errors.SurgeError {
|
|
42
|
+
constructor(body) {
|
|
43
|
+
super({
|
|
44
|
+
message: "UnprocessableEntityError",
|
|
45
|
+
statusCode: 422,
|
|
46
|
+
body: body,
|
|
47
|
+
});
|
|
48
|
+
Object.setPrototypeOf(this, UnprocessableEntityError.prototype);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.UnprocessableEntityError = UnprocessableEntityError;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ConflictError"), exports);
|
|
18
|
+
__exportStar(require("./UnprocessableEntityError"), exports);
|
package/api/index.d.ts
ADDED
package/api/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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("./types"), exports);
|
|
18
|
+
__exportStar(require("./errors"), exports);
|
|
19
|
+
__exportStar(require("./resources"), exports);
|
|
@@ -0,0 +1,50 @@
|
|
|
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 Blasts {
|
|
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 Blasts {
|
|
27
|
+
protected readonly _options: Blasts.Options;
|
|
28
|
+
constructor(_options: Blasts.Options);
|
|
29
|
+
/**
|
|
30
|
+
* Sends a Blast.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} accountId - The account for which the blast should be sent.
|
|
33
|
+
* @param {Surge.BlastRequest} request
|
|
34
|
+
* @param {Blasts.RequestOptions} requestOptions - Request-specific configuration.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* await client.blasts.send("acct_01j9a43avnfqzbjfch6pygv1td", {
|
|
38
|
+
* attachments: [{
|
|
39
|
+
* url: "https://example.com/image.jpg"
|
|
40
|
+
* }],
|
|
41
|
+
* body: "Join us for our grand opening!",
|
|
42
|
+
* contacts: ["ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"],
|
|
43
|
+
* name: "Grand Opening Announcement",
|
|
44
|
+
* segments: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf"],
|
|
45
|
+
* send_at: "2024-02-01T15:00:00Z"
|
|
46
|
+
* })
|
|
47
|
+
*/
|
|
48
|
+
send(accountId: string, request?: Surge.BlastRequest, requestOptions?: Blasts.RequestOptions): Promise<Surge.BlastResponse>;
|
|
49
|
+
protected _getAuthorizationHeader(): Promise<string>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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.Blasts = 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 Blasts {
|
|
57
|
+
constructor(_options) {
|
|
58
|
+
this._options = _options;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sends a Blast.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} accountId - The account for which the blast should be sent.
|
|
64
|
+
* @param {Surge.BlastRequest} request
|
|
65
|
+
* @param {Blasts.RequestOptions} requestOptions - Request-specific configuration.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* await client.blasts.send("acct_01j9a43avnfqzbjfch6pygv1td", {
|
|
69
|
+
* attachments: [{
|
|
70
|
+
* url: "https://example.com/image.jpg"
|
|
71
|
+
* }],
|
|
72
|
+
* body: "Join us for our grand opening!",
|
|
73
|
+
* contacts: ["ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"],
|
|
74
|
+
* name: "Grand Opening Announcement",
|
|
75
|
+
* segments: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf"],
|
|
76
|
+
* send_at: "2024-02-01T15:00:00Z"
|
|
77
|
+
* })
|
|
78
|
+
*/
|
|
79
|
+
send(accountId_1) {
|
|
80
|
+
return __awaiter(this, arguments, void 0, function* (accountId, request = {}, requestOptions) {
|
|
81
|
+
var _a, _b, _c;
|
|
82
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
83
|
+
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)}/blasts`),
|
|
84
|
+
method: "POST",
|
|
85
|
+
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),
|
|
86
|
+
contentType: "application/json",
|
|
87
|
+
requestType: "json",
|
|
88
|
+
body: request,
|
|
89
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
90
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
91
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
92
|
+
});
|
|
93
|
+
if (_response.ok) {
|
|
94
|
+
return _response.body;
|
|
95
|
+
}
|
|
96
|
+
if (_response.error.reason === "status-code") {
|
|
97
|
+
throw new errors.SurgeError({
|
|
98
|
+
statusCode: _response.error.statusCode,
|
|
99
|
+
body: _response.error.body,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
switch (_response.error.reason) {
|
|
103
|
+
case "non-json":
|
|
104
|
+
throw new errors.SurgeError({
|
|
105
|
+
statusCode: _response.error.statusCode,
|
|
106
|
+
body: _response.error.rawBody,
|
|
107
|
+
});
|
|
108
|
+
case "timeout":
|
|
109
|
+
throw new errors.SurgeTimeoutError("Timeout exceeded when calling POST /accounts/{account_id}/blasts.");
|
|
110
|
+
case "unknown":
|
|
111
|
+
throw new errors.SurgeError({
|
|
112
|
+
message: _response.error.errorMessage,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
_getAuthorizationHeader() {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
return `Bearer ${yield core.Supplier.get(this._options.token)}`;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.Blasts = Blasts;
|
|
@@ -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,30 @@
|
|
|
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://example.com/image.jpg"
|
|
10
|
+
* }],
|
|
11
|
+
* body: "Join us for our grand opening!",
|
|
12
|
+
* contacts: ["ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"],
|
|
13
|
+
* name: "Grand Opening Announcement",
|
|
14
|
+
* segments: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf"],
|
|
15
|
+
* send_at: "2024-02-01T15:00:00Z"
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export interface BlastRequest {
|
|
19
|
+
attachments?: Surge.AttachmentParams[];
|
|
20
|
+
/** The message body. */
|
|
21
|
+
body?: string;
|
|
22
|
+
/** List of contact IDs to send the blast to. */
|
|
23
|
+
contacts?: string[];
|
|
24
|
+
/** Optional name for the blast. */
|
|
25
|
+
name?: string;
|
|
26
|
+
/** List of segment IDs to send the blast to. */
|
|
27
|
+
segments?: string[];
|
|
28
|
+
/** When to send the blast. If not provided, sends immediately. */
|
|
29
|
+
send_at?: string;
|
|
30
|
+
}
|