@ohunkohun/termii-sdk 1.0.0
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/README.md +208 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/client.d.ts +23 -0
- package/dist/resources/client.d.ts.map +1 -0
- package/dist/resources/client.js +38 -0
- package/dist/resources/client.js.map +1 -0
- package/dist/resources/hooks.d.ts +4 -0
- package/dist/resources/hooks.d.ts.map +1 -0
- package/dist/resources/hooks.js +16 -0
- package/dist/resources/hooks.js.map +1 -0
- package/dist/types/api-response.d.ts +30 -0
- package/dist/types/api-response.d.ts.map +1 -0
- package/dist/types/api-response.js +2 -0
- package/dist/types/api-response.js.map +1 -0
- package/dist/types/config.d.ts +5 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/email.d.ts +72 -0
- package/dist/types/email.d.ts.map +1 -0
- package/dist/types/email.js +2 -0
- package/dist/types/email.js.map +1 -0
- package/dist/types/sender-id.d.ts +134 -0
- package/dist/types/sender-id.d.ts.map +1 -0
- package/dist/types/sender-id.js +2 -0
- package/dist/types/sender-id.js.map +1 -0
- package/dist/types/sms.d.ts +173 -0
- package/dist/types/sms.d.ts.map +1 -0
- package/dist/types/sms.js +2 -0
- package/dist/types/sms.js.map +1 -0
- package/dist/types/whatsapp.d.ts +83 -0
- package/dist/types/whatsapp.d.ts.map +1 -0
- package/dist/types/whatsapp.js +2 -0
- package/dist/types/whatsapp.js.map +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Termii SDK for Node.js
|
|
2
|
+
|
|
3
|
+
A TypeScript/Node.js SDK for interacting with the [Termii](https://developers.termii.com/) API.
|
|
4
|
+
|
|
5
|
+
## Coverage
|
|
6
|
+
|
|
7
|
+
This SDK currently supports Termii's messaging APIs, including SMS, bulk messaging, WhatsApp messaging/templates, Sender ID management, and email notifications.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
You can install the published npm package directly:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @ohunkohun/termii-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then import and initialize the SDK:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { Termii } from "@ohunkohun/termii-sdk";
|
|
21
|
+
|
|
22
|
+
const client = Termii({
|
|
23
|
+
api_key: "YOUR_API_KEY",
|
|
24
|
+
base_url: "https://BASE_URL",
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
You can now use the available API resources through the client:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const response = await client.sms.send({
|
|
32
|
+
to: "234XXXXXXXXXX",
|
|
33
|
+
from: "YourSender",
|
|
34
|
+
sms: "Hello from Termii SDK",
|
|
35
|
+
channel: "generic",
|
|
36
|
+
type: "plain",
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
> Replace the package name and API configuration with the values appropriate for your environment.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Working With the Repository
|
|
45
|
+
|
|
46
|
+
If you have cloned this repository and want to work with the source code directly, install the dependencies first:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Build the SDK with:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm run build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The compiled package will be generated in the `dist` directory.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Testing the SDK Locally
|
|
63
|
+
|
|
64
|
+
There are two ways to test the SDK after cloning the repository.
|
|
65
|
+
|
|
66
|
+
### Use the source directly
|
|
67
|
+
|
|
68
|
+
Some examples and development utilities in this repository are intended to run locally.
|
|
69
|
+
|
|
70
|
+
If an example uses environment variables, create a `.env` file in the root of the project:
|
|
71
|
+
|
|
72
|
+
```env
|
|
73
|
+
IS_LOCAL_MACHINE="true"
|
|
74
|
+
API_KEY="your-api-key"
|
|
75
|
+
BASE_URL="https://your-base-url"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Some variables and constants used in the examples are loaded from the `.env` file. You can also define these values directly in your code instead of using environment variables.
|
|
79
|
+
|
|
80
|
+
For example:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const config = {
|
|
84
|
+
api_key: "your-api-key",
|
|
85
|
+
base_url: "https://your-base-url",
|
|
86
|
+
};
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Test the SDK as an installed npm package
|
|
90
|
+
|
|
91
|
+
If you want to test the SDK exactly as a consumer would, you can install the published npm package instead of working directly with the source files.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm install @ohunkohun/termii-sdk
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This is useful for testing the package's:
|
|
98
|
+
|
|
99
|
+
- Public exports
|
|
100
|
+
- TypeScript declarations
|
|
101
|
+
- Auto-completion
|
|
102
|
+
- API surface
|
|
103
|
+
- Package entry points
|
|
104
|
+
- Production build
|
|
105
|
+
|
|
106
|
+
You can then import the SDK normally:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { Termii } from "@ohunkohun/termii-sdk";
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Testing a Local Package Build
|
|
115
|
+
|
|
116
|
+
If you want to test the **current local changes** before publishing them to npm, you can create a package archive with:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm run build
|
|
120
|
+
npm run pack
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This generates a `.tgz` file, for example:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
ohunkohun-termii-sdk-1.0.0.tgz
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
You can install that package in another project:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm install C://absolute/or/relative/path/to/ohunkohun-termii-sdk-1.0.0.tgz
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
This allows you to test the SDK as an actual installed npm package while still using your local, unpublished changes.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Development
|
|
140
|
+
|
|
141
|
+
Start the development environment with:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run dev
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
To watch for TypeScript errors without generating build files:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm run types:watch
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
To create a production build:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm run build
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Environment Variables
|
|
162
|
+
|
|
163
|
+
Environment variables are only required for examples or local development that use them.
|
|
164
|
+
|
|
165
|
+
A typical `.env` file may look like:
|
|
166
|
+
|
|
167
|
+
```env
|
|
168
|
+
IS_LOCAL_MACHINE="true"
|
|
169
|
+
API_KEY="your-api-key"
|
|
170
|
+
BASE_URL="https://your-base-url"
|
|
171
|
+
SEND_SMS_FROM="YourSender"
|
|
172
|
+
SEND_SMS_TO="234XXXXXXXXXX"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
You are not required to use `.env`. Configuration values can be supplied directly when initializing the SDK:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
const client = Termii({
|
|
179
|
+
api_key: "your-api-key",
|
|
180
|
+
base_url: "https://your-base-url",
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Package vs. Repository
|
|
187
|
+
|
|
188
|
+
If you only want to **use the SDK**, installing the npm package is recommended:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm install @ohunkohun/termii-sdk
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
If you want to **contribute to, modify, or inspect the SDK source code**, clone this repository and install its dependencies:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
git clone <repository-url>
|
|
198
|
+
cd <repository-folder>
|
|
199
|
+
npm install
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
If you want to test your local changes as a real npm package without publishing them, use `npm run pack` and install the generated `.tgz` file in another project.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Disclaimer
|
|
207
|
+
|
|
208
|
+
This is a community-built, unofficial Node.js/TypeScript SDK for the Termii API. It is not an official Termii package unless otherwise stated by Termii.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Termii } from "./resources/client.js";
|
|
2
|
+
export type * from "./types/api-response.js";
|
|
3
|
+
export type * from "./types/config.js";
|
|
4
|
+
export type * from "./types/email.js";
|
|
5
|
+
export type * from "./types/sender-id.js";
|
|
6
|
+
export type * from "./types/sms.js";
|
|
7
|
+
export type * from "./types/whatsapp.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ApiErrorResponse } from "../types/api-response.js";
|
|
2
|
+
import { TermiiConfig } from "../types/config.js";
|
|
3
|
+
import { SendEmailTemplateBody, SendEmailTemplateResponse } from "../types/email.js";
|
|
4
|
+
import { ListSenderIdParams, ListSenderIdResponse, RequestSenderIdBody, RequestSenderIdResponse } from "../types/sender-id.js";
|
|
5
|
+
import { BulkSmsBody, SendSmsBody, SmsResponse } from "../types/sms.js";
|
|
6
|
+
import { SendWhatsAppTemplateBody } from "../types/whatsapp.js";
|
|
7
|
+
export declare const Termii: (config: TermiiConfig) => {
|
|
8
|
+
sender_id: {
|
|
9
|
+
list: (query?: ListSenderIdParams) => Promise<ApiErrorResponse | ListSenderIdResponse | undefined>;
|
|
10
|
+
request: (body: RequestSenderIdBody) => Promise<ApiErrorResponse | RequestSenderIdResponse | undefined>;
|
|
11
|
+
};
|
|
12
|
+
sms: {
|
|
13
|
+
send: (body: SendSmsBody) => Promise<ApiErrorResponse | SmsResponse | undefined>;
|
|
14
|
+
send_bulk: (body: BulkSmsBody) => Promise<ApiErrorResponse | SmsResponse | undefined>;
|
|
15
|
+
};
|
|
16
|
+
email_template: {
|
|
17
|
+
send: (body: SendEmailTemplateBody) => Promise<ApiErrorResponse | SendEmailTemplateResponse | undefined>;
|
|
18
|
+
};
|
|
19
|
+
whatsapp_template: {
|
|
20
|
+
send: (body: SendWhatsAppTemplateBody) => Promise<ApiErrorResponse | RequestSenderIdResponse | undefined>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/resources/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,eAAO,MAAM,MAAM,WAAY,YAAY;;QAuB/B,IAAI,WAAiB,kBAAkB;QACvC,OAAO,SAAe,mBAAmB;;;QAGzC,IAAI,SAAe,WAAW;QAC9B,SAAS,SAAe,WAAW;;;QAGnC,IAAI,SAAe,qBAAqB;;;QAGxC,IAAI,SAAe,wBAAwB;;CAKtD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { create } from "axios";
|
|
2
|
+
import { useTryCatch } from "./hooks.js";
|
|
3
|
+
export const Termii = (config) => {
|
|
4
|
+
const trycatch = useTryCatch();
|
|
5
|
+
const req = create({
|
|
6
|
+
baseURL: config.base_url,
|
|
7
|
+
headers: {
|
|
8
|
+
"Content-Type": "application/json",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
const callApi = async (method, urlPath, data) => {
|
|
12
|
+
return await trycatch.wrap(async () => {
|
|
13
|
+
const resp = await (method === 'post' ? req.post(urlPath, { api_key: config.api_key, ...data }) :
|
|
14
|
+
req.get(urlPath, { params: { api_key: config.api_key, ...data } }));
|
|
15
|
+
return resp?.data;
|
|
16
|
+
}, (error) => {
|
|
17
|
+
return error?.response?.data;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const handles = {
|
|
21
|
+
sender_id: {
|
|
22
|
+
list: async (query) => await callApi('get', `/api/sender-id`, query),
|
|
23
|
+
request: async (body) => await callApi('post', `/api/sender-id/request`, body),
|
|
24
|
+
},
|
|
25
|
+
sms: {
|
|
26
|
+
send: async (body) => await callApi('post', `/api/sms/send`, body),
|
|
27
|
+
send_bulk: async (body) => await callApi('post', `/api/sms/send/bulk`, body),
|
|
28
|
+
},
|
|
29
|
+
email_template: {
|
|
30
|
+
send: async (body) => await callApi('post', `/api/templates/send-email`, body),
|
|
31
|
+
},
|
|
32
|
+
whatsapp_template: {
|
|
33
|
+
send: async (body) => await callApi('post', `/api/send/template${Object.keys(body.media || {}).length ? `/media` : ``}`, body),
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
return { ...handles };
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/resources/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAoB,EAAE,EAAE;IAC3C,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC,QAAQ;QACxB,OAAO,EAAE;YACL,cAAc,EAAE,kBAAkB;SACrC;KACJ,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,KAAK,EAAM,MAAsB,EAAE,OAAe,EAAE,IAAqC,EAAE,EAAE;QACzG,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAuB,KAAK,IAAI,EAAE;YACxD,MAAM,IAAI,GAAG,MAAM,CACf,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,EAAC,CAAC,CAAC,CAAC;gBAC3E,GAAG,CAAC,GAAG,C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AC,GAAG,OAAO,EAAC,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/resources/hooks.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW;WAEF,CAAC,YAAY,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,KAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CAW9H,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const useTryCatch = () => {
|
|
2
|
+
const handles = {
|
|
3
|
+
wrap: async (callback, onErrorCaught) => {
|
|
4
|
+
try {
|
|
5
|
+
return await callback();
|
|
6
|
+
}
|
|
7
|
+
catch (err) {
|
|
8
|
+
// console.log('--tryCatchWrapper', err);
|
|
9
|
+
if (onErrorCaught)
|
|
10
|
+
return await onErrorCaught?.(err);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
return { ...handles };
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/resources/hooks.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG;QACX,IAAI,EAAE,KAAK,EAAK,QAA8B,EAAE,aAA6C,EAA0B,EAAE;YACtH,IAAI,CAAC;gBACD,OAAO,MAAM,QAAQ,EAAE,CAAC;YAC5B,CAAC;YACD,OAAM,GAAG,EAAC,CAAC;gBACP,yCAAyC;gBACzC,IAAG,aAAa;oBAAE,OAAO,MAAM,aAAa,EAAE,CAAC,GAAG,CAAC,CAAA;YACvD,CAAC;QACL,CAAC;KACJ,CAAC;IACF,OAAO,EAAC,GAAG,OAAO,EAAC,CAAA;AACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error response returned by the API.
|
|
3
|
+
*/
|
|
4
|
+
export interface ApiErrorResponse {
|
|
5
|
+
/**
|
|
6
|
+
* Error code returned by the API.
|
|
7
|
+
*/
|
|
8
|
+
code?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Human-readable error message.
|
|
11
|
+
*/
|
|
12
|
+
message?: string;
|
|
13
|
+
/**
|
|
14
|
+
* HTTP status code.
|
|
15
|
+
*/
|
|
16
|
+
status?: number;
|
|
17
|
+
/**
|
|
18
|
+
* API endpoint that generated the error.
|
|
19
|
+
*/
|
|
20
|
+
path?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Time at which the error occurred.
|
|
23
|
+
*/
|
|
24
|
+
timestamp?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Additional error description.
|
|
27
|
+
*/
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=api-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.d.ts","sourceRoot":"","sources":["../../src/types/api-response.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.js","sourceRoot":"","sources":["../../src/types/api-response.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic variables used to populate an email template.
|
|
3
|
+
*
|
|
4
|
+
* Each key should correspond to a variable defined
|
|
5
|
+
* in the email template.
|
|
6
|
+
*/
|
|
7
|
+
export type EmailTemplateVariables = Record<string, string | number | boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Request body for sending a templated email notification.
|
|
10
|
+
*/
|
|
11
|
+
export interface SendEmailTemplateBody {
|
|
12
|
+
/**
|
|
13
|
+
* Recipient's email address.
|
|
14
|
+
*
|
|
15
|
+
* Example: `test@termii.com`
|
|
16
|
+
*/
|
|
17
|
+
email: string;
|
|
18
|
+
/**
|
|
19
|
+
* Subject line displayed in the recipient's inbox.
|
|
20
|
+
*/
|
|
21
|
+
subject: string;
|
|
22
|
+
/**
|
|
23
|
+
* ID of the email configuration created
|
|
24
|
+
* on the Termii dashboard.
|
|
25
|
+
*/
|
|
26
|
+
email_configuration_id: string;
|
|
27
|
+
/**
|
|
28
|
+
* ID of the email template created
|
|
29
|
+
* on the Termii dashboard.
|
|
30
|
+
*/
|
|
31
|
+
template_id: string;
|
|
32
|
+
/**
|
|
33
|
+
* Dynamic values used to populate variables
|
|
34
|
+
* defined in the email template.
|
|
35
|
+
*
|
|
36
|
+
* Example:
|
|
37
|
+
* {
|
|
38
|
+
* name: "Priscilla",
|
|
39
|
+
* balance: "333444"
|
|
40
|
+
* }
|
|
41
|
+
*/
|
|
42
|
+
variables: EmailTemplateVariables;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Response returned after successfully
|
|
46
|
+
* sending a templated email.
|
|
47
|
+
*/
|
|
48
|
+
export interface SendEmailTemplateResponse {
|
|
49
|
+
/**
|
|
50
|
+
* Indicates whether the email was successfully sent.
|
|
51
|
+
*/
|
|
52
|
+
code: "ok";
|
|
53
|
+
/**
|
|
54
|
+
* Remaining account balance.
|
|
55
|
+
*
|
|
56
|
+
* The API currently returns this value as a string.
|
|
57
|
+
*/
|
|
58
|
+
balance: string | number;
|
|
59
|
+
/**
|
|
60
|
+
* Unique ID of the sent message.
|
|
61
|
+
*/
|
|
62
|
+
message_id: string;
|
|
63
|
+
/**
|
|
64
|
+
* Human-readable response message.
|
|
65
|
+
*/
|
|
66
|
+
message: string;
|
|
67
|
+
/**
|
|
68
|
+
* Name of the user associated with the account.
|
|
69
|
+
*/
|
|
70
|
+
user: string;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/types/email.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,CACvC,MAAM,EACN,MAAM,GAAG,MAAM,GAAG,OAAO,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAE/B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;OASG;IACH,SAAS,EAAE,sBAAsB,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACtC;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/types/email.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported Sender ID statuses.
|
|
3
|
+
*/
|
|
4
|
+
export type SenderIdStatus = "active" | "pending" | "blocked";
|
|
5
|
+
/**
|
|
6
|
+
* Query parameters for fetching Sender IDs.
|
|
7
|
+
*
|
|
8
|
+
* Both parameters are optional and can be used to filter
|
|
9
|
+
* Sender IDs by name and/or registration status.
|
|
10
|
+
*/
|
|
11
|
+
export interface ListSenderIdParams {
|
|
12
|
+
/**
|
|
13
|
+
* Filter results by Sender ID name.
|
|
14
|
+
*/
|
|
15
|
+
name?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Filter results by Sender ID status.
|
|
18
|
+
*/
|
|
19
|
+
status?: SenderIdStatus;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A registered Sender ID associated with an account.
|
|
23
|
+
*
|
|
24
|
+
* `company` and `usecase` are only returned for some
|
|
25
|
+
* Sender IDs, such as pending registration requests.
|
|
26
|
+
*/
|
|
27
|
+
export interface SenderId {
|
|
28
|
+
/**
|
|
29
|
+
* Country associated with the Sender ID.
|
|
30
|
+
*/
|
|
31
|
+
country: string;
|
|
32
|
+
/**
|
|
33
|
+
* Current registration status.
|
|
34
|
+
*/
|
|
35
|
+
status: SenderIdStatus;
|
|
36
|
+
/**
|
|
37
|
+
* Date and time the Sender ID was created.
|
|
38
|
+
*
|
|
39
|
+
* Format: YYYY-MM-DD HH:mm:ss
|
|
40
|
+
*/
|
|
41
|
+
createdAt: string;
|
|
42
|
+
/**
|
|
43
|
+
* The registered Sender ID.
|
|
44
|
+
*/
|
|
45
|
+
sender_id: string;
|
|
46
|
+
/**
|
|
47
|
+
* Company associated with the Sender ID.
|
|
48
|
+
*/
|
|
49
|
+
company?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Use case associated with the Sender ID.
|
|
52
|
+
*
|
|
53
|
+
* Note: The API returns this property as `usecase`.
|
|
54
|
+
*/
|
|
55
|
+
usecase?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Sort information returned by the Sender ID API.
|
|
59
|
+
*/
|
|
60
|
+
export interface SenderIdSort {
|
|
61
|
+
/**
|
|
62
|
+
* Whether the sort configuration is empty.
|
|
63
|
+
*/
|
|
64
|
+
empty: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the results are sorted.
|
|
67
|
+
*/
|
|
68
|
+
sorted: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the results are unsorted.
|
|
71
|
+
*/
|
|
72
|
+
unsorted: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Pagination information returned by the Sender ID API.
|
|
76
|
+
*/
|
|
77
|
+
export interface SenderIdPageable {
|
|
78
|
+
sort: SenderIdSort;
|
|
79
|
+
offset: number;
|
|
80
|
+
pageNumber: number;
|
|
81
|
+
pageSize: number;
|
|
82
|
+
paged: boolean;
|
|
83
|
+
unpaged: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Response returned when fetching Sender IDs.
|
|
87
|
+
*/
|
|
88
|
+
export interface ListSenderIdResponse {
|
|
89
|
+
content: SenderId[];
|
|
90
|
+
pageable: SenderIdPageable;
|
|
91
|
+
totalElements: number;
|
|
92
|
+
last: boolean;
|
|
93
|
+
totalPages: number;
|
|
94
|
+
sort: SenderIdSort;
|
|
95
|
+
size: number;
|
|
96
|
+
number: number;
|
|
97
|
+
first: boolean;
|
|
98
|
+
numberOfElements: number;
|
|
99
|
+
empty: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Request body for registering a new Sender ID.
|
|
103
|
+
*/
|
|
104
|
+
export interface RequestSenderIdBody {
|
|
105
|
+
/**
|
|
106
|
+
* Sender ID to register.
|
|
107
|
+
*
|
|
108
|
+
* Can be alphanumeric or numeric.
|
|
109
|
+
* Alphanumeric Sender IDs must be between 3 and 11 characters.
|
|
110
|
+
*/
|
|
111
|
+
sender_id: string;
|
|
112
|
+
/**
|
|
113
|
+
* A sample of the type of message that will be sent.
|
|
114
|
+
*/
|
|
115
|
+
use_case: string;
|
|
116
|
+
/**
|
|
117
|
+
* Name of the company associated with the Sender ID.
|
|
118
|
+
*/
|
|
119
|
+
company: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Response returned after submitting a Sender ID registration request.
|
|
123
|
+
*/
|
|
124
|
+
export interface RequestSenderIdResponse {
|
|
125
|
+
/**
|
|
126
|
+
* Indicates whether the request was successful.
|
|
127
|
+
*/
|
|
128
|
+
code: "ok";
|
|
129
|
+
/**
|
|
130
|
+
* Confirmation message from the API.
|
|
131
|
+
*/
|
|
132
|
+
message: string;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=sender-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sender-id.d.ts","sourceRoot":"","sources":["../../src/types/sender-id.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GACpB,QAAQ,GACR,SAAS,GACT,SAAS,CAAC;AAEhB;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAA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@@
|
|
|
1
|
+
{"version":3,"file":"sender-id.js","sourceRoot":"","sources":["../../src/types/sender-id.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export interface SmsRecipient {
|
|
2
|
+
/**
|
|
3
|
+
* Destination phone number(s) in international format.
|
|
4
|
+
*
|
|
5
|
+
* A maximum of 100 phone numbers can be provided.
|
|
6
|
+
*
|
|
7
|
+
* Example: `23490126727`
|
|
8
|
+
*/
|
|
9
|
+
to: string | string[];
|
|
10
|
+
}
|
|
11
|
+
export interface SmsSender {
|
|
12
|
+
/**
|
|
13
|
+
* Sender ID.
|
|
14
|
+
*
|
|
15
|
+
* Alphanumeric sender IDs must be between 3 and 11 characters.
|
|
16
|
+
*
|
|
17
|
+
* Example: `CompanyName`
|
|
18
|
+
*/
|
|
19
|
+
from: string;
|
|
20
|
+
}
|
|
21
|
+
export interface SmsContent {
|
|
22
|
+
/**
|
|
23
|
+
* Text message to be delivered.
|
|
24
|
+
*
|
|
25
|
+
* For voice messages containing verification codes,
|
|
26
|
+
* add spaces between the digits for better text-to-speech
|
|
27
|
+
* interpretation.
|
|
28
|
+
*/
|
|
29
|
+
sms: string;
|
|
30
|
+
}
|
|
31
|
+
export interface SmsEncryptionOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Encryption algorithm.
|
|
34
|
+
*
|
|
35
|
+
* AES is strongly recommended.
|
|
36
|
+
*/
|
|
37
|
+
algorithm: string;
|
|
38
|
+
/**
|
|
39
|
+
* Secret key used for encryption.
|
|
40
|
+
*/
|
|
41
|
+
secret_key: string;
|
|
42
|
+
/**
|
|
43
|
+
* Initialization vector.
|
|
44
|
+
*
|
|
45
|
+
* Required depending on the selected encryption mode.
|
|
46
|
+
*/
|
|
47
|
+
iv: string;
|
|
48
|
+
}
|
|
49
|
+
export interface SmsMedia {
|
|
50
|
+
/**
|
|
51
|
+
* URL of the media resource.
|
|
52
|
+
*/
|
|
53
|
+
url: string;
|
|
54
|
+
/**
|
|
55
|
+
* Optional caption for the media.
|
|
56
|
+
*/
|
|
57
|
+
caption?: string;
|
|
58
|
+
}
|
|
59
|
+
type SmsBase = SmsRecipient & SmsSender;
|
|
60
|
+
/**
|
|
61
|
+
* Standard SMS message.
|
|
62
|
+
*/
|
|
63
|
+
export type PlainSmsBody = SmsBase & SmsContent & {
|
|
64
|
+
channel: "dnd" | "generic";
|
|
65
|
+
type: "plain";
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Unicode SMS message for special characters
|
|
69
|
+
* or non-Latin scripts.
|
|
70
|
+
*/
|
|
71
|
+
export type UnicodeSmsBody = SmsBase & SmsContent & {
|
|
72
|
+
channel: "dnd" | "generic";
|
|
73
|
+
type: "unicode";
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Encrypted SMS message.
|
|
77
|
+
*/
|
|
78
|
+
export type EncryptedSmsBody = SmsBase & SmsContent & {
|
|
79
|
+
channel: "dnd" | "generic";
|
|
80
|
+
type: "encrypted";
|
|
81
|
+
encryption: SmsEncryptionOptions;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Voice message.
|
|
85
|
+
*/
|
|
86
|
+
export type VoiceSmsBody = SmsBase & SmsContent & {
|
|
87
|
+
channel: "voice";
|
|
88
|
+
type: "voice";
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* WhatsApp text message.
|
|
92
|
+
*/
|
|
93
|
+
export type WhatsappTextBody = SmsBase & SmsContent & {
|
|
94
|
+
channel: "whatsapp";
|
|
95
|
+
type: "plain";
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* WhatsApp media message.
|
|
99
|
+
*
|
|
100
|
+
* The `sms` field must not be provided when sending media.
|
|
101
|
+
*/
|
|
102
|
+
export type WhatsappMediaBody = SmsBase & {
|
|
103
|
+
channel: "whatsapp";
|
|
104
|
+
type: "plain";
|
|
105
|
+
media: SmsMedia;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Request body for sending a single message.
|
|
109
|
+
*/
|
|
110
|
+
export type SendSmsBody = PlainSmsBody | UnicodeSmsBody | EncryptedSmsBody | VoiceSmsBody | WhatsappTextBody | WhatsappMediaBody;
|
|
111
|
+
/**
|
|
112
|
+
* Base fields shared by bulk SMS requests.
|
|
113
|
+
*/
|
|
114
|
+
type BulkSmsBase = Omit<SmsBase, "to"> & {
|
|
115
|
+
/**
|
|
116
|
+
* Destination phone numbers.
|
|
117
|
+
*
|
|
118
|
+
* A maximum of 100 phone numbers can be provided.
|
|
119
|
+
*/
|
|
120
|
+
to: string[];
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Standard bulk SMS message.
|
|
124
|
+
*/
|
|
125
|
+
export type BulkPlainSmsBody = BulkSmsBase & SmsContent & {
|
|
126
|
+
channel: "dnd" | "generic";
|
|
127
|
+
type: "plain" | "unicode";
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Encrypted bulk SMS message.
|
|
131
|
+
*/
|
|
132
|
+
export type BulkEncryptedSmsBody = BulkSmsBase & SmsContent & {
|
|
133
|
+
channel: "dnd" | "generic";
|
|
134
|
+
type: "encrypted";
|
|
135
|
+
encryption: SmsEncryptionOptions;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Request body for bulk SMS.
|
|
139
|
+
*/
|
|
140
|
+
export type BulkSmsBody = BulkPlainSmsBody | BulkEncryptedSmsBody;
|
|
141
|
+
export type SmsChannel = SendSmsBody['channel'];
|
|
142
|
+
export type SmsType = SendSmsBody['type'];
|
|
143
|
+
/**
|
|
144
|
+
* Successful response returned by the messaging endpoints.
|
|
145
|
+
*/
|
|
146
|
+
export interface SmsResponse {
|
|
147
|
+
/**
|
|
148
|
+
* Indicates the result of the request.
|
|
149
|
+
*/
|
|
150
|
+
code: "ok";
|
|
151
|
+
/**
|
|
152
|
+
* Remaining account balance.
|
|
153
|
+
*/
|
|
154
|
+
balance: number;
|
|
155
|
+
/**
|
|
156
|
+
* Unique identifier for the sent message.
|
|
157
|
+
*/
|
|
158
|
+
message_id: string;
|
|
159
|
+
/**
|
|
160
|
+
* Human-readable response message.
|
|
161
|
+
*/
|
|
162
|
+
message: string;
|
|
163
|
+
/**
|
|
164
|
+
* Name of the account user.
|
|
165
|
+
*/
|
|
166
|
+
user: string;
|
|
167
|
+
/**
|
|
168
|
+
* Message ID represented as a string.
|
|
169
|
+
*/
|
|
170
|
+
message_id_str: string;
|
|
171
|
+
}
|
|
172
|
+
export {};
|
|
173
|
+
//# sourceMappingURL=sms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.d.ts","sourceRoot":"","sources":["../../src/types/sms.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB;;;;;;OAMG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACtB;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACvB;;;;;;OAMG;IACH,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACjC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACrB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAC9B,UAAU,GAAG;IACT,OAAO,EAAE,KAAK,GAAG,SAAS,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC;CACjB,CAAC;AAEN;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GACh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AAE,KAAK,GAAG,SAAS,CAAC;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,oBAAoB,CAAC;CACpC,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,oBAAoB,CAAC;AAG3B,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;AAEhD,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAG1C;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../src/types/sms.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variables used to populate placeholders in a WhatsApp template.
|
|
3
|
+
*
|
|
4
|
+
* For authentication (OTP) templates, only `otp` is supported.
|
|
5
|
+
*/
|
|
6
|
+
export type WhatsAppTemplateData = Record<string, string | number>;
|
|
7
|
+
/**
|
|
8
|
+
* Media attachment included in a WhatsApp template message.
|
|
9
|
+
*/
|
|
10
|
+
export interface WhatsAppTemplateMedia {
|
|
11
|
+
/**
|
|
12
|
+
* Caption describing the attached media.
|
|
13
|
+
*/
|
|
14
|
+
caption: string;
|
|
15
|
+
/**
|
|
16
|
+
* Publicly accessible and downloadable URL
|
|
17
|
+
* of the media file.
|
|
18
|
+
*/
|
|
19
|
+
url: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Request body for sending a WhatsApp template message.
|
|
23
|
+
*
|
|
24
|
+
* Media is optional. When provided, the template message
|
|
25
|
+
* will include the specified media attachment.
|
|
26
|
+
*/
|
|
27
|
+
export interface SendWhatsAppTemplateBody {
|
|
28
|
+
/**
|
|
29
|
+
* Destination phone number in international format.
|
|
30
|
+
*
|
|
31
|
+
* Example: `23490126727`
|
|
32
|
+
*/
|
|
33
|
+
phone_number: string;
|
|
34
|
+
/**
|
|
35
|
+
* WhatsApp Device ID.
|
|
36
|
+
*/
|
|
37
|
+
device_id: string;
|
|
38
|
+
/**
|
|
39
|
+
* ID of the approved WhatsApp template.
|
|
40
|
+
*/
|
|
41
|
+
template_id: string;
|
|
42
|
+
/**
|
|
43
|
+
* Variables used to populate the template placeholders.
|
|
44
|
+
*/
|
|
45
|
+
data: WhatsAppTemplateData;
|
|
46
|
+
/**
|
|
47
|
+
* Optional media attachment.
|
|
48
|
+
*
|
|
49
|
+
* Authentication (OTP) templates do not support media.
|
|
50
|
+
*/
|
|
51
|
+
media?: WhatsAppTemplateMedia;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Response returned after successfully sending
|
|
55
|
+
* a WhatsApp template message.
|
|
56
|
+
*/
|
|
57
|
+
export interface SendWhatsAppTemplateResponse {
|
|
58
|
+
/**
|
|
59
|
+
* Indicates whether the message was successfully sent.
|
|
60
|
+
*/
|
|
61
|
+
code: "ok";
|
|
62
|
+
/**
|
|
63
|
+
* Remaining account balance.
|
|
64
|
+
*/
|
|
65
|
+
balance: number;
|
|
66
|
+
/**
|
|
67
|
+
* Message ID returned by Termii.
|
|
68
|
+
*/
|
|
69
|
+
message_id: string;
|
|
70
|
+
/**
|
|
71
|
+
* Human-readable response message.
|
|
72
|
+
*/
|
|
73
|
+
message: string;
|
|
74
|
+
/**
|
|
75
|
+
* Name of the user associated with the account.
|
|
76
|
+
*/
|
|
77
|
+
user: string;
|
|
78
|
+
/**
|
|
79
|
+
* Message ID returned as a string.
|
|
80
|
+
*/
|
|
81
|
+
message_id_str: string;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=whatsapp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp.d.ts","sourceRoot":"","sources":["../../src/types/whatsapp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CACrC,MAAM,EACN,MAAM,GAAG,MAAM,CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACrC;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,IAAI,EAAE,oBAAoB,CAAC;IAE3B;;;;OAIG;IACH,KAAK,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp.js","sourceRoot":"","sources":["../../src/types/whatsapp.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ohunkohun/termii-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A TypeScript SDK for the Termii API",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "tsx watch examples/server.ts",
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"types:watch": "npx tsc --noEmit --watch",
|
|
9
|
+
"pack:dry": "npm pack --dry-run",
|
|
10
|
+
"pack": "npm pack",
|
|
11
|
+
"publish": "npm publish --access public"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["termii", "sdk", "typescript", "javascript", "node", "js", "ts"],
|
|
14
|
+
"author": "Ohunkóhun",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": ["dist"],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"axios": "^1.20.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/express": "^5.0.6",
|
|
32
|
+
"@types/node": "^26.5.1",
|
|
33
|
+
"dotenv": "^17.4.2",
|
|
34
|
+
"express": "^5.2.1",
|
|
35
|
+
"tsx": "^4.23.13",
|
|
36
|
+
"typescript": "^7.0.2"
|
|
37
|
+
}
|
|
38
|
+
}
|