@unlimited-messaging/sdk 0.1.15 → 0.1.17
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/package.json +1 -1
- package/src/Client.d.ts +3 -0
- package/src/Client.js +15 -10
- package/src/api/resources/index.d.ts +3 -0
- package/src/api/resources/index.js +4 -1
- package/src/api/resources/media/client/Client.d.ts +48 -0
- package/src/api/resources/media/client/Client.js +148 -0
- package/src/api/resources/media/client/index.d.ts +1 -0
- package/src/api/resources/media/client/index.js +17 -0
- package/src/api/resources/media/client/requests/MediaUploadRequest.d.ts +9 -0
- package/src/api/resources/media/client/requests/MediaUploadRequest.js +5 -0
- package/src/api/resources/media/client/requests/index.d.ts +1 -0
- package/src/api/resources/media/client/requests/index.js +2 -0
- package/src/api/resources/media/index.d.ts +2 -0
- package/src/api/resources/media/index.js +18 -0
- package/src/api/resources/media/types/MediaUploadResponse.d.ts +8 -0
- package/src/api/resources/media/types/MediaUploadResponse.js +5 -0
- package/src/api/resources/media/types/index.d.ts +1 -0
- package/src/api/resources/media/types/index.js +17 -0
- package/src/api/resources/messages/client/Client.d.ts +3 -5
- package/src/api/resources/messages/client/Client.js +5 -7
- package/src/api/resources/messages/client/requests/MessageSendRequest.d.ts +8 -4
- package/src/api/resources/messages/types/MessageFindAllResponseDataItem.d.ts +6 -1
- package/src/api/resources/messages/types/MessageFindOneResponse.d.ts +6 -1
- package/src/api/resources/messages/types/MessageSendRequestMediaType.d.ts +9 -0
- package/src/api/resources/messages/types/MessageSendRequestMediaType.js +11 -0
- package/src/api/resources/messages/types/MessageSendRequestProductData.d.ts +17 -0
- package/src/api/resources/messages/types/MessageSendRequestProductData.js +5 -0
- package/src/api/resources/messages/types/MessageSendResponse.d.ts +6 -1
- package/src/api/resources/messages/types/index.d.ts +2 -0
- package/src/api/resources/messages/types/index.js +2 -0
- package/src/core/form-data-utils/FormDataWrapper.d.ts +63 -0
- package/src/core/form-data-utils/FormDataWrapper.js +227 -0
- package/src/core/form-data-utils/encodeAsFormParameter.d.ts +4 -0
- package/src/core/form-data-utils/encodeAsFormParameter.js +18 -0
- package/src/core/form-data-utils/index.d.ts +2 -0
- package/src/core/form-data-utils/index.js +20 -0
- package/src/core/index.d.ts +1 -0
- package/src/core/index.js +1 -0
- package/src/serialization/resources/index.d.ts +2 -0
- package/src/serialization/resources/index.js +3 -1
- package/src/serialization/resources/media/index.d.ts +1 -0
- package/src/serialization/resources/media/index.js +17 -0
- package/src/serialization/resources/media/types/MediaUploadResponse.d.ts +14 -0
- package/src/serialization/resources/media/types/MediaUploadResponse.js +45 -0
- package/src/serialization/resources/media/types/index.d.ts +1 -0
- package/src/serialization/resources/media/types/index.js +17 -0
- package/src/serialization/resources/messages/client/requests/MessageSendRequest.d.ts +8 -1
- package/src/serialization/resources/messages/client/requests/MessageSendRequest.js +8 -1
- package/src/serialization/resources/messages/types/MessageFindAllResponseDataItem.d.ts +6 -1
- package/src/serialization/resources/messages/types/MessageFindAllResponseDataItem.js +6 -1
- package/src/serialization/resources/messages/types/MessageFindOneResponse.d.ts +6 -1
- package/src/serialization/resources/messages/types/MessageFindOneResponse.js +6 -1
- package/src/serialization/resources/messages/types/MessageSendRequestMediaType.d.ts +10 -0
- package/src/serialization/resources/messages/types/MessageSendRequestMediaType.js +41 -0
- package/src/serialization/resources/messages/types/MessageSendRequestProductData.d.ts +23 -0
- package/src/serialization/resources/messages/types/MessageSendRequestProductData.js +54 -0
- package/src/serialization/resources/messages/types/MessageSendResponse.d.ts +6 -1
- package/src/serialization/resources/messages/types/MessageSendResponse.js +6 -1
- package/src/serialization/resources/messages/types/index.d.ts +2 -0
- package/src/serialization/resources/messages/types/index.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unlimited-messaging/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "TypeScript / Node.js SDK for the Unlimited Messaging API — send and receive WhatsApp messages programmatically",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
package/src/Client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as environments from "./environments";
|
|
5
5
|
import * as core from "./core";
|
|
6
|
+
import { Media } from "./api/resources/media/client/Client";
|
|
6
7
|
import { Messages } from "./api/resources/messages/client/Client";
|
|
7
8
|
import { Accounts } from "./api/resources/accounts/client/Client";
|
|
8
9
|
import { SiMsDeprecated } from "./api/resources/siMsDeprecated/client/Client";
|
|
@@ -28,12 +29,14 @@ export declare namespace UnlimitedMessagingApiClient {
|
|
|
28
29
|
}
|
|
29
30
|
export declare class UnlimitedMessagingApiClient {
|
|
30
31
|
protected readonly _options: UnlimitedMessagingApiClient.Options;
|
|
32
|
+
protected _media: Media | undefined;
|
|
31
33
|
protected _messages: Messages | undefined;
|
|
32
34
|
protected _accounts: Accounts | undefined;
|
|
33
35
|
protected _siMsDeprecated: SiMsDeprecated | undefined;
|
|
34
36
|
protected _webhooks: Webhooks | undefined;
|
|
35
37
|
protected _apiKeys: ApiKeys | undefined;
|
|
36
38
|
constructor(_options: UnlimitedMessagingApiClient.Options);
|
|
39
|
+
get media(): Media;
|
|
37
40
|
get messages(): Messages;
|
|
38
41
|
get accounts(): Accounts;
|
|
39
42
|
get siMsDeprecated(): SiMsDeprecated;
|
package/src/Client.js
CHANGED
|
@@ -4,34 +4,39 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.UnlimitedMessagingApiClient = void 0;
|
|
7
|
-
const Client_1 = require("./api/resources/
|
|
8
|
-
const Client_2 = require("./api/resources/
|
|
9
|
-
const Client_3 = require("./api/resources/
|
|
10
|
-
const Client_4 = require("./api/resources/
|
|
11
|
-
const Client_5 = require("./api/resources/
|
|
7
|
+
const Client_1 = require("./api/resources/media/client/Client");
|
|
8
|
+
const Client_2 = require("./api/resources/messages/client/Client");
|
|
9
|
+
const Client_3 = require("./api/resources/accounts/client/Client");
|
|
10
|
+
const Client_4 = require("./api/resources/siMsDeprecated/client/Client");
|
|
11
|
+
const Client_5 = require("./api/resources/webhooks/client/Client");
|
|
12
|
+
const Client_6 = require("./api/resources/apiKeys/client/Client");
|
|
12
13
|
class UnlimitedMessagingApiClient {
|
|
13
14
|
constructor(_options) {
|
|
14
15
|
this._options = _options;
|
|
15
16
|
}
|
|
17
|
+
get media() {
|
|
18
|
+
var _a;
|
|
19
|
+
return ((_a = this._media) !== null && _a !== void 0 ? _a : (this._media = new Client_1.Media(this._options)));
|
|
20
|
+
}
|
|
16
21
|
get messages() {
|
|
17
22
|
var _a;
|
|
18
|
-
return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new
|
|
23
|
+
return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new Client_2.Messages(this._options)));
|
|
19
24
|
}
|
|
20
25
|
get accounts() {
|
|
21
26
|
var _a;
|
|
22
|
-
return ((_a = this._accounts) !== null && _a !== void 0 ? _a : (this._accounts = new
|
|
27
|
+
return ((_a = this._accounts) !== null && _a !== void 0 ? _a : (this._accounts = new Client_3.Accounts(this._options)));
|
|
23
28
|
}
|
|
24
29
|
get siMsDeprecated() {
|
|
25
30
|
var _a;
|
|
26
|
-
return ((_a = this._siMsDeprecated) !== null && _a !== void 0 ? _a : (this._siMsDeprecated = new
|
|
31
|
+
return ((_a = this._siMsDeprecated) !== null && _a !== void 0 ? _a : (this._siMsDeprecated = new Client_4.SiMsDeprecated(this._options)));
|
|
27
32
|
}
|
|
28
33
|
get webhooks() {
|
|
29
34
|
var _a;
|
|
30
|
-
return ((_a = this._webhooks) !== null && _a !== void 0 ? _a : (this._webhooks = new
|
|
35
|
+
return ((_a = this._webhooks) !== null && _a !== void 0 ? _a : (this._webhooks = new Client_5.Webhooks(this._options)));
|
|
31
36
|
}
|
|
32
37
|
get apiKeys() {
|
|
33
38
|
var _a;
|
|
34
|
-
return ((_a = this._apiKeys) !== null && _a !== void 0 ? _a : (this._apiKeys = new
|
|
39
|
+
return ((_a = this._apiKeys) !== null && _a !== void 0 ? _a : (this._apiKeys = new Client_6.ApiKeys(this._options)));
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
exports.UnlimitedMessagingApiClient = UnlimitedMessagingApiClient;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * as media from "./media";
|
|
2
|
+
export * from "./media/types";
|
|
1
3
|
export * as messages from "./messages";
|
|
2
4
|
export * from "./messages/types";
|
|
3
5
|
export * as accounts from "./accounts";
|
|
@@ -8,6 +10,7 @@ export * as webhooks from "./webhooks";
|
|
|
8
10
|
export * from "./webhooks/types";
|
|
9
11
|
export * as apiKeys from "./apiKeys";
|
|
10
12
|
export * from "./apiKeys/types";
|
|
13
|
+
export * from "./media/client/requests";
|
|
11
14
|
export * from "./messages/client/requests";
|
|
12
15
|
export * from "./accounts/client/requests";
|
|
13
16
|
export * from "./siMsDeprecated/client/requests";
|
|
@@ -36,7 +36,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.apiKeys = exports.webhooks = exports.siMsDeprecated = exports.accounts = exports.messages = void 0;
|
|
39
|
+
exports.apiKeys = exports.webhooks = exports.siMsDeprecated = exports.accounts = exports.messages = exports.media = void 0;
|
|
40
|
+
exports.media = __importStar(require("./media"));
|
|
41
|
+
__exportStar(require("./media/types"), exports);
|
|
40
42
|
exports.messages = __importStar(require("./messages"));
|
|
41
43
|
__exportStar(require("./messages/types"), exports);
|
|
42
44
|
exports.accounts = __importStar(require("./accounts"));
|
|
@@ -47,6 +49,7 @@ exports.webhooks = __importStar(require("./webhooks"));
|
|
|
47
49
|
__exportStar(require("./webhooks/types"), exports);
|
|
48
50
|
exports.apiKeys = __importStar(require("./apiKeys"));
|
|
49
51
|
__exportStar(require("./apiKeys/types"), exports);
|
|
52
|
+
__exportStar(require("./media/client/requests"), exports);
|
|
50
53
|
__exportStar(require("./messages/client/requests"), exports);
|
|
51
54
|
__exportStar(require("./accounts/client/requests"), exports);
|
|
52
55
|
__exportStar(require("./siMsDeprecated/client/requests"), exports);
|
|
@@ -0,0 +1,48 @@
|
|
|
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 UnlimitedMessagingApi from "../../../index";
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import { Blob } from "buffer";
|
|
9
|
+
export declare namespace Media {
|
|
10
|
+
interface Options {
|
|
11
|
+
environment?: core.Supplier<environments.UnlimitedMessagingApiEnvironment | string>;
|
|
12
|
+
/** Specify a custom URL to connect the client to. */
|
|
13
|
+
baseUrl?: core.Supplier<string>;
|
|
14
|
+
token: core.Supplier<core.BearerToken>;
|
|
15
|
+
}
|
|
16
|
+
interface RequestOptions {
|
|
17
|
+
/** The maximum time to wait for a response in seconds. */
|
|
18
|
+
timeoutInSeconds?: number;
|
|
19
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
/** A hook to abort the request. */
|
|
22
|
+
abortSignal?: AbortSignal;
|
|
23
|
+
/** Additional headers to include in the request. */
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export declare class Media {
|
|
28
|
+
protected readonly _options: Media.Options;
|
|
29
|
+
constructor(_options: Media.Options);
|
|
30
|
+
/**
|
|
31
|
+
* **Protection**: Protected endpoint. Allowed roles: USER, ADMIN. Required scopes: OTHER:WRITE
|
|
32
|
+
*
|
|
33
|
+
* Uploads a media file and returns a temporary URL valid for 10 minutes. Pass that URL as `mediaUrl` in `POST /message` to send it as a WhatsApp message. Accepted types: images (`image/jpeg`, `image/png`, `image/webp`, `image/gif`), documents (`application/pdf`), and audio (`audio/webm`, `audio/ogg`, `audio/mpeg`, `audio/mp4`, `audio/aac`). Maximum file size: 16 MB. Audio files from browsers (WebM/Opus recorded via the MediaRecorder API) are automatically transcoded to OGG/Opus and delivered as WhatsApp voice notes (PTT) when sent via `POST /message`.
|
|
34
|
+
*
|
|
35
|
+
* @param {File | fs.ReadStream | Blob} file
|
|
36
|
+
* @param {Media.RequestOptions} requestOptions - Request-specific configuration.
|
|
37
|
+
*
|
|
38
|
+
* @throws {@link UnlimitedMessagingApi.BadRequestError}
|
|
39
|
+
* @throws {@link UnlimitedMessagingApi.UnauthorizedError}
|
|
40
|
+
* @throws {@link UnlimitedMessagingApi.ForbiddenError}
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* await client.media.upload(fs.createReadStream("/path/to/your/file"))
|
|
44
|
+
*/
|
|
45
|
+
upload(file: File | fs.ReadStream | Blob, requestOptions?: Media.RequestOptions): core.HttpResponsePromise<UnlimitedMessagingApi.MediaUploadResponse>;
|
|
46
|
+
private __upload;
|
|
47
|
+
protected _getAuthorizationHeader(): Promise<string>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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.Media = void 0;
|
|
52
|
+
const environments = __importStar(require("../../../../environments"));
|
|
53
|
+
const core = __importStar(require("../../../../core"));
|
|
54
|
+
const UnlimitedMessagingApi = __importStar(require("../../../index"));
|
|
55
|
+
const url_join_1 = __importDefault(require("url-join"));
|
|
56
|
+
const serializers = __importStar(require("../../../../serialization/index"));
|
|
57
|
+
const errors = __importStar(require("../../../../errors/index"));
|
|
58
|
+
class Media {
|
|
59
|
+
constructor(_options) {
|
|
60
|
+
this._options = _options;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* **Protection**: Protected endpoint. Allowed roles: USER, ADMIN. Required scopes: OTHER:WRITE
|
|
64
|
+
*
|
|
65
|
+
* Uploads a media file and returns a temporary URL valid for 10 minutes. Pass that URL as `mediaUrl` in `POST /message` to send it as a WhatsApp message. Accepted types: images (`image/jpeg`, `image/png`, `image/webp`, `image/gif`), documents (`application/pdf`), and audio (`audio/webm`, `audio/ogg`, `audio/mpeg`, `audio/mp4`, `audio/aac`). Maximum file size: 16 MB. Audio files from browsers (WebM/Opus recorded via the MediaRecorder API) are automatically transcoded to OGG/Opus and delivered as WhatsApp voice notes (PTT) when sent via `POST /message`.
|
|
66
|
+
*
|
|
67
|
+
* @param {File | fs.ReadStream | Blob} file
|
|
68
|
+
* @param {Media.RequestOptions} requestOptions - Request-specific configuration.
|
|
69
|
+
*
|
|
70
|
+
* @throws {@link UnlimitedMessagingApi.BadRequestError}
|
|
71
|
+
* @throws {@link UnlimitedMessagingApi.UnauthorizedError}
|
|
72
|
+
* @throws {@link UnlimitedMessagingApi.ForbiddenError}
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* await client.media.upload(fs.createReadStream("/path/to/your/file"))
|
|
76
|
+
*/
|
|
77
|
+
upload(file, requestOptions) {
|
|
78
|
+
return core.HttpResponsePromise.fromPromise(this.__upload(file, requestOptions));
|
|
79
|
+
}
|
|
80
|
+
__upload(file, requestOptions) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
const _request = yield core.newFormData();
|
|
84
|
+
yield _request.appendFile("file", file);
|
|
85
|
+
const _maybeEncodedRequest = yield _request.getRequest();
|
|
86
|
+
const _response = yield core.fetcher({
|
|
87
|
+
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.UnlimitedMessagingApiEnvironment.Production, "media"),
|
|
88
|
+
method: "POST",
|
|
89
|
+
headers: Object.assign(Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
90
|
+
requestType: "file",
|
|
91
|
+
duplex: _maybeEncodedRequest.duplex,
|
|
92
|
+
body: _maybeEncodedRequest.body,
|
|
93
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
94
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
95
|
+
withCredentials: true,
|
|
96
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
97
|
+
});
|
|
98
|
+
if (_response.ok) {
|
|
99
|
+
return {
|
|
100
|
+
data: serializers.MediaUploadResponse.parseOrThrow(_response.body, {
|
|
101
|
+
unrecognizedObjectKeys: "passthrough",
|
|
102
|
+
allowUnrecognizedUnionMembers: true,
|
|
103
|
+
allowUnrecognizedEnumValues: true,
|
|
104
|
+
breadcrumbsPrefix: ["response"],
|
|
105
|
+
}),
|
|
106
|
+
rawResponse: _response.rawResponse,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (_response.error.reason === "status-code") {
|
|
110
|
+
switch (_response.error.statusCode) {
|
|
111
|
+
case 400:
|
|
112
|
+
throw new UnlimitedMessagingApi.BadRequestError(_response.error.body, _response.rawResponse);
|
|
113
|
+
case 401:
|
|
114
|
+
throw new UnlimitedMessagingApi.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
115
|
+
case 403:
|
|
116
|
+
throw new UnlimitedMessagingApi.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
117
|
+
default:
|
|
118
|
+
throw new errors.UnlimitedMessagingApiError({
|
|
119
|
+
statusCode: _response.error.statusCode,
|
|
120
|
+
body: _response.error.body,
|
|
121
|
+
rawResponse: _response.rawResponse,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
switch (_response.error.reason) {
|
|
126
|
+
case "non-json":
|
|
127
|
+
throw new errors.UnlimitedMessagingApiError({
|
|
128
|
+
statusCode: _response.error.statusCode,
|
|
129
|
+
body: _response.error.rawBody,
|
|
130
|
+
rawResponse: _response.rawResponse,
|
|
131
|
+
});
|
|
132
|
+
case "timeout":
|
|
133
|
+
throw new errors.UnlimitedMessagingApiTimeoutError("Timeout exceeded when calling POST /media.");
|
|
134
|
+
case "unknown":
|
|
135
|
+
throw new errors.UnlimitedMessagingApiError({
|
|
136
|
+
message: _response.error.errorMessage,
|
|
137
|
+
rawResponse: _response.rawResponse,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
_getAuthorizationHeader() {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
return `Bearer ${yield core.Supplier.get(this._options.token)}`;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.Media = Media;
|
|
@@ -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 @@
|
|
|
1
|
+
export { type MediaUploadRequest } from "./MediaUploadRequest";
|
|
@@ -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("./types"), exports);
|
|
18
|
+
__exportStar(require("./client"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./MediaUploadResponse";
|
|
@@ -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("./MediaUploadResponse"), exports);
|
|
@@ -48,7 +48,7 @@ export declare class Messages {
|
|
|
48
48
|
/**
|
|
49
49
|
* **Protection**: Protected endpoint. Allowed roles: USER, ADMIN. Required scopes: OTHER:WRITE
|
|
50
50
|
*
|
|
51
|
-
* Queues a WhatsApp message for delivery to the specified `recipient`: a phone number (E.164 format) for a 1:1 chat, or a WhatsApp group id (numeric, with or without its `@g.us` suffix) to address a group directly. If `accountId` is omitted, the platform resolves an account automatically using this priority order: (1) if the caller has exactly one active account, it is used; (2) if the caller has no account, the shared system account is used as fallback; (3) if the caller has multiple active accounts, a `400` is returned asking to specify `accountId`. Returns `404` if no account is available at all. Message text is limited to 1 600 characters. Provide `replyToMessageId` instead of `recipient` to send a quoted reply to a message already in the account's history: the conversation (a group included) and the account used are both derived from that message, and `accountId` is ignored. Beta (whatsmeow) WhatsApp accounts only for now. `simId` is a deprecated alias for `accountId`, removed 2026-12-16.
|
|
51
|
+
* Queues a WhatsApp message for delivery to the specified `recipient`: a phone number (E.164 format) for a 1:1 chat, or a WhatsApp group id (numeric, with or without its `@g.us` suffix) to address a group directly. If `accountId` is omitted, the platform resolves an account automatically using this priority order: (1) if the caller has exactly one active account, it is used; (2) if the caller has no account, the shared system account is used as fallback; (3) if the caller has multiple active accounts, a `400` is returned asking to specify `accountId`. Returns `404` if no account is available at all. Message text is limited to 1 600 characters. Provide `replyToMessageId` instead of `recipient` to send a quoted reply to a message already in the account's history: the conversation (a group included) and the account used are both derived from that message, and `accountId` is ignored. Beta (whatsmeow) WhatsApp accounts only for now. `simId` is a deprecated alias for `accountId`, removed 2026-12-16. To send a media file, upload it first with `POST /media` to get a temp URL, then pass that URL as `mediaUrl` with the matching `mediaType` (`image`, `document`, or `audio`) in this body.
|
|
52
52
|
*
|
|
53
53
|
* @param {UnlimitedMessagingApi.MessageSendRequest} request
|
|
54
54
|
* @param {Messages.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -61,11 +61,9 @@ export declare class Messages {
|
|
|
61
61
|
* @throws {@link UnlimitedMessagingApi.UnprocessableEntityError}
|
|
62
62
|
*
|
|
63
63
|
* @example
|
|
64
|
-
* await client.messages.messageSend(
|
|
65
|
-
* text: "text"
|
|
66
|
-
* })
|
|
64
|
+
* await client.messages.messageSend()
|
|
67
65
|
*/
|
|
68
|
-
messageSend(request
|
|
66
|
+
messageSend(request?: UnlimitedMessagingApi.MessageSendRequest, requestOptions?: Messages.RequestOptions): core.HttpResponsePromise<UnlimitedMessagingApi.MessageSendResponse>;
|
|
69
67
|
private __messageSend;
|
|
70
68
|
/**
|
|
71
69
|
* **Protection**: Protected endpoint. Allowed roles: USER, ADMIN. Required scopes: OTHER:READ
|
|
@@ -174,7 +174,7 @@ class Messages {
|
|
|
174
174
|
/**
|
|
175
175
|
* **Protection**: Protected endpoint. Allowed roles: USER, ADMIN. Required scopes: OTHER:WRITE
|
|
176
176
|
*
|
|
177
|
-
* Queues a WhatsApp message for delivery to the specified `recipient`: a phone number (E.164 format) for a 1:1 chat, or a WhatsApp group id (numeric, with or without its `@g.us` suffix) to address a group directly. If `accountId` is omitted, the platform resolves an account automatically using this priority order: (1) if the caller has exactly one active account, it is used; (2) if the caller has no account, the shared system account is used as fallback; (3) if the caller has multiple active accounts, a `400` is returned asking to specify `accountId`. Returns `404` if no account is available at all. Message text is limited to 1 600 characters. Provide `replyToMessageId` instead of `recipient` to send a quoted reply to a message already in the account's history: the conversation (a group included) and the account used are both derived from that message, and `accountId` is ignored. Beta (whatsmeow) WhatsApp accounts only for now. `simId` is a deprecated alias for `accountId`, removed 2026-12-16.
|
|
177
|
+
* Queues a WhatsApp message for delivery to the specified `recipient`: a phone number (E.164 format) for a 1:1 chat, or a WhatsApp group id (numeric, with or without its `@g.us` suffix) to address a group directly. If `accountId` is omitted, the platform resolves an account automatically using this priority order: (1) if the caller has exactly one active account, it is used; (2) if the caller has no account, the shared system account is used as fallback; (3) if the caller has multiple active accounts, a `400` is returned asking to specify `accountId`. Returns `404` if no account is available at all. Message text is limited to 1 600 characters. Provide `replyToMessageId` instead of `recipient` to send a quoted reply to a message already in the account's history: the conversation (a group included) and the account used are both derived from that message, and `accountId` is ignored. Beta (whatsmeow) WhatsApp accounts only for now. `simId` is a deprecated alias for `accountId`, removed 2026-12-16. To send a media file, upload it first with `POST /media` to get a temp URL, then pass that URL as `mediaUrl` with the matching `mediaType` (`image`, `document`, or `audio`) in this body.
|
|
178
178
|
*
|
|
179
179
|
* @param {UnlimitedMessagingApi.MessageSendRequest} request
|
|
180
180
|
* @param {Messages.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -187,15 +187,13 @@ class Messages {
|
|
|
187
187
|
* @throws {@link UnlimitedMessagingApi.UnprocessableEntityError}
|
|
188
188
|
*
|
|
189
189
|
* @example
|
|
190
|
-
* await client.messages.messageSend(
|
|
191
|
-
* text: "text"
|
|
192
|
-
* })
|
|
190
|
+
* await client.messages.messageSend()
|
|
193
191
|
*/
|
|
194
|
-
messageSend(request, requestOptions) {
|
|
192
|
+
messageSend(request = {}, requestOptions) {
|
|
195
193
|
return core.HttpResponsePromise.fromPromise(this.__messageSend(request, requestOptions));
|
|
196
194
|
}
|
|
197
|
-
__messageSend(
|
|
198
|
-
return __awaiter(this,
|
|
195
|
+
__messageSend() {
|
|
196
|
+
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
199
197
|
var _a, _b;
|
|
200
198
|
const _response = yield core.fetcher({
|
|
201
199
|
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.UnlimitedMessagingApiEnvironment.Production, "message"),
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
|
+
import * as UnlimitedMessagingApi from "../../../../index";
|
|
4
5
|
/**
|
|
5
6
|
* @example
|
|
6
|
-
* {
|
|
7
|
-
* text: "text"
|
|
8
|
-
* }
|
|
7
|
+
* {}
|
|
9
8
|
*/
|
|
10
9
|
export interface MessageSendRequest {
|
|
11
10
|
recipient?: string;
|
|
12
|
-
text
|
|
11
|
+
text?: string;
|
|
12
|
+
mediaUrl?: string;
|
|
13
|
+
mediaType?: UnlimitedMessagingApi.MessageSendRequestMediaType;
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
filename?: string;
|
|
16
|
+
productData?: UnlimitedMessagingApi.MessageSendRequestProductData;
|
|
13
17
|
accountId?: string | null;
|
|
14
18
|
simId?: string | null;
|
|
15
19
|
replyToMessageId?: string;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import * as UnlimitedMessagingApi from "../../../index";
|
|
5
5
|
export interface MessageFindAllResponseDataItem {
|
|
6
6
|
id: string;
|
|
7
|
-
content: string;
|
|
7
|
+
content: string | null;
|
|
8
8
|
direction: UnlimitedMessagingApi.MessageFindAllResponseDataItemDirection;
|
|
9
9
|
/** True when the account holder sent this message (direction OUT), false when they received it (direction IN). Redundant with direction, but spares the client from having to know which enum value means "we sent it" - the same convention as WhatsApp's own fromMe. */
|
|
10
10
|
fromMe: boolean;
|
|
@@ -24,6 +24,11 @@ export interface MessageFindAllResponseDataItem {
|
|
|
24
24
|
channel: UnlimitedMessagingApi.MessageFindAllResponseDataItemChannel;
|
|
25
25
|
accountChannel: UnlimitedMessagingApi.MessageFindAllResponseDataItemAccountChannel;
|
|
26
26
|
watermarked: boolean;
|
|
27
|
+
mediaUrl: string | null;
|
|
28
|
+
mediaType: string | null;
|
|
29
|
+
mimeType: string | null;
|
|
30
|
+
mediaFilename: string | null;
|
|
31
|
+
productData: Record<string, unknown> | null;
|
|
27
32
|
createdAt: Date;
|
|
28
33
|
updatedAt: Date;
|
|
29
34
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import * as UnlimitedMessagingApi from "../../../index";
|
|
5
5
|
export interface MessageFindOneResponse {
|
|
6
6
|
id: string;
|
|
7
|
-
content: string;
|
|
7
|
+
content: string | null;
|
|
8
8
|
direction: UnlimitedMessagingApi.MessageFindOneResponseDirection;
|
|
9
9
|
/** True when the account holder sent this message (direction OUT), false when they received it (direction IN). Redundant with direction, but spares the client from having to know which enum value means "we sent it" - the same convention as WhatsApp's own fromMe. */
|
|
10
10
|
fromMe: boolean;
|
|
@@ -24,6 +24,11 @@ export interface MessageFindOneResponse {
|
|
|
24
24
|
channel: UnlimitedMessagingApi.MessageFindOneResponseChannel;
|
|
25
25
|
accountChannel: UnlimitedMessagingApi.MessageFindOneResponseAccountChannel;
|
|
26
26
|
watermarked: boolean;
|
|
27
|
+
mediaUrl: string | null;
|
|
28
|
+
mediaType: string | null;
|
|
29
|
+
mimeType: string | null;
|
|
30
|
+
mediaFilename: string | null;
|
|
31
|
+
productData: Record<string, unknown> | null;
|
|
27
32
|
createdAt: Date;
|
|
28
33
|
updatedAt: Date;
|
|
29
34
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
export type MessageSendRequestMediaType = "image" | "document" | "audio";
|
|
5
|
+
export declare const MessageSendRequestMediaType: {
|
|
6
|
+
readonly Image: "image";
|
|
7
|
+
readonly Document: "document";
|
|
8
|
+
readonly Audio: "audio";
|
|
9
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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.MessageSendRequestMediaType = void 0;
|
|
7
|
+
exports.MessageSendRequestMediaType = {
|
|
8
|
+
Image: "image",
|
|
9
|
+
Document: "document",
|
|
10
|
+
Audio: "audio",
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
export interface MessageSendRequestProductData {
|
|
5
|
+
productId: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
currencyCode: string;
|
|
9
|
+
priceAmount1000: number;
|
|
10
|
+
salePriceAmount1000?: number;
|
|
11
|
+
retailerId?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
imageUrl?: string;
|
|
14
|
+
businessOwnerJid: string;
|
|
15
|
+
body?: string;
|
|
16
|
+
footer?: string;
|
|
17
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import * as UnlimitedMessagingApi from "../../../index";
|
|
5
5
|
export interface MessageSendResponse {
|
|
6
6
|
id: string;
|
|
7
|
-
content: string;
|
|
7
|
+
content: string | null;
|
|
8
8
|
direction: UnlimitedMessagingApi.MessageSendResponseDirection;
|
|
9
9
|
/** True when the account holder sent this message (direction OUT), false when they received it (direction IN). Redundant with direction, but spares the client from having to know which enum value means "we sent it" - the same convention as WhatsApp's own fromMe. */
|
|
10
10
|
fromMe: boolean;
|
|
@@ -24,6 +24,11 @@ export interface MessageSendResponse {
|
|
|
24
24
|
channel: UnlimitedMessagingApi.MessageSendResponseChannel;
|
|
25
25
|
accountChannel: UnlimitedMessagingApi.MessageSendResponseAccountChannel;
|
|
26
26
|
watermarked: boolean;
|
|
27
|
+
mediaUrl: string | null;
|
|
28
|
+
mediaType: string | null;
|
|
29
|
+
mimeType: string | null;
|
|
30
|
+
mediaFilename: string | null;
|
|
31
|
+
productData: Record<string, unknown> | null;
|
|
27
32
|
createdAt: Date;
|
|
28
33
|
updatedAt: Date;
|
|
29
34
|
}
|
|
@@ -7,6 +7,8 @@ export * from "./MessageFindAllResponseDataItemChannel";
|
|
|
7
7
|
export * from "./MessageFindAllResponseDataItemAccountChannel";
|
|
8
8
|
export * from "./MessageFindAllResponseDataItem";
|
|
9
9
|
export * from "./MessageFindAllResponse";
|
|
10
|
+
export * from "./MessageSendRequestMediaType";
|
|
11
|
+
export * from "./MessageSendRequestProductData";
|
|
10
12
|
export * from "./MessageSendResponseDirection";
|
|
11
13
|
export * from "./MessageSendResponseStatus";
|
|
12
14
|
export * from "./MessageSendResponseChannel";
|