@kumbify/sdk 1.0.2 → 1.0.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/README.md +140 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kmail/KMailClient.d.ts +9 -0
- package/dist/kmail/KMailClient.js +38 -0
- package/dist/kmail/KMailClient.js.map +1 -0
- package/dist/kmail/KMailServer.js +1 -1
- package/dist/kmail/KMailServer.js.map +1 -1
- package/dist/ksms/KSMSClient.d.ts +8 -0
- package/dist/ksms/KSMSClient.js +29 -0
- package/dist/ksms/KSMSClient.js.map +1 -0
- package/dist/ksms/KSMSServer.d.ts +1 -1
- package/dist/ksms/KSMSServer.js +1 -1
- package/dist/ksms/KSMSServer.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,140 @@
|
|
|
1
|
-
Kumbify SDK
|
|
1
|
+
# 📦 Kumbify SDK
|
|
2
|
+
|
|
3
|
+
> A simple and powerful JavaScript/TypeScript SDK for sending **emails** and **SMS messages** through the Kumbify platform.
|
|
4
|
+
|
|
5
|
+
[Oficial Documentation](https://kumbify.com/en/api-docs?section=sdk)
|
|
6
|
+
|
|
7
|
+
This SDK makes it easy to integrate messaging (email + SMS) into your apps with minimal setup and clear type-safe APIs.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📌 Installation
|
|
12
|
+
|
|
13
|
+
Install using npm:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @kumbify/sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
or using Yarn:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add @kumbify/sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 🚀 Importing
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { KMailClient, KSMSClient } from "@kumbify/sdk";
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## ✉️ Email — KMailClient
|
|
34
|
+
|
|
35
|
+
### 📍 Create an Email Client
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const mailClient = new KMailClient({
|
|
39
|
+
apiKey: "YOUR_EMAIL_API_KEY",
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 📤 Send a Simple Email
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const sendMail = await mailClient.sendSimpleMail({
|
|
47
|
+
body_html: "<h1>Hello from Kumbify</h1><p>This is a test email</p>",
|
|
48
|
+
body_text: "Hello from Kumbify — this is a test email.",
|
|
49
|
+
from_address: "no-reply@kumbify.app",
|
|
50
|
+
subject: "Welcome Email",
|
|
51
|
+
to_address: ["recipient@example.com"],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
console.log("Email Response:", sendMail);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Parameters explained:**
|
|
58
|
+
|
|
59
|
+
| Property | Type | Description |
|
|
60
|
+
| -------------- | -------- | --------------------------------- |
|
|
61
|
+
| `body_html` | string | HTML email content |
|
|
62
|
+
| `body_text` | string | Plain text email content |
|
|
63
|
+
| `from_address` | string | Sender email address |
|
|
64
|
+
| `subject` | string | Email subject |
|
|
65
|
+
| `to_address` | string[] | List of recipient email addresses |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 📱 SMS — KSMSClient
|
|
70
|
+
|
|
71
|
+
### 📍 Create an SMS Client
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const smsClient = new KSMSClient({
|
|
75
|
+
apiKey: "YOUR_SMS_API_KEY",
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 📤 Send an SMS Message
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
await smsClient.sendSMS({
|
|
83
|
+
message: "Your verification code is 123456",
|
|
84
|
+
from: "kumbify-app",
|
|
85
|
+
to: "+1234567890",
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
console.log("SMS sent successfully!");
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Parameters explained:**
|
|
92
|
+
|
|
93
|
+
| Property | Type | Description |
|
|
94
|
+
| --------- | ------ | ------------------------------------ |
|
|
95
|
+
| `message` | string | SMS content |
|
|
96
|
+
| `from` | string | Sender identifier (visible to users) |
|
|
97
|
+
| `to` | string | Recipient phone number |
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 💡 Example Usage All Together
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { KMailClient, KSMSClient } from "@kumbify/sdk";
|
|
105
|
+
|
|
106
|
+
const mailClient = new KMailClient({ apiKey: "EMAIL_KEY" });
|
|
107
|
+
const smsClient = new KSMSClient({ apiKey: "SMS_KEY" });
|
|
108
|
+
|
|
109
|
+
// Send Email
|
|
110
|
+
await mailClient.sendSimpleMail({
|
|
111
|
+
body_html: "<p>Hello!</p>",
|
|
112
|
+
body_text: "Hello!",
|
|
113
|
+
from_address: "no-reply@kumbify.com",
|
|
114
|
+
subject: "Test Email",
|
|
115
|
+
to_address: ["user1@example.com"],
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Send SMS
|
|
119
|
+
await smsClient.sendSMS({
|
|
120
|
+
message: "Your code is 1234",
|
|
121
|
+
from: "KumbifyApp",
|
|
122
|
+
to: "+1234567890",
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🧠 Tips & Best Practices
|
|
129
|
+
|
|
130
|
+
✔️ Store your API keys in environment variables (never hardcode them).
|
|
131
|
+
✔️ Always handle promise rejections with `try/catch`.
|
|
132
|
+
✔️ Log or inspect response objects to monitor delivery success.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 💼 Supported Environments
|
|
137
|
+
|
|
138
|
+
✔ Node.js
|
|
139
|
+
✔ TypeScript
|
|
140
|
+
✔ Any JavaScript project that supports npm packages
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./kmail/
|
|
2
|
-
export * from "./ksms/
|
|
1
|
+
export * from "./kmail/KMailClient";
|
|
2
|
+
export * from "./ksms/KSMSClient";
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./kmail/
|
|
18
|
-
__exportStar(require("./ksms/
|
|
17
|
+
__exportStar(require("./kmail/KMailClient"), exports);
|
|
18
|
+
__exportStar(require("./ksms/KSMSClient"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IKMailResponseMail, IKMailSendMailSimpleMessage, IKMailSendMailTemplateMessage } from "../utils/types";
|
|
2
|
+
export declare class KMailClient {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
constructor({ apiKey }: {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
});
|
|
7
|
+
sendSimpleMail({ ...data }: IKMailSendMailSimpleMessage): Promise<IKMailResponseMail>;
|
|
8
|
+
sendTemplateMail({ ...data }: IKMailSendMailTemplateMessage): Promise<IKMailResponseMail>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.KMailClient = void 0;
|
|
7
|
+
const helpers_1 = require("../utils/helpers");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
class KMailClient {
|
|
10
|
+
apiKey;
|
|
11
|
+
constructor({ apiKey }) {
|
|
12
|
+
this.apiKey = apiKey;
|
|
13
|
+
}
|
|
14
|
+
async sendSimpleMail({ ...data }) {
|
|
15
|
+
try {
|
|
16
|
+
const response = await axios_1.default.post(helpers_1.APP_CONFIG.KMAIL_URL + "/send", {
|
|
17
|
+
...data,
|
|
18
|
+
}, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
|
|
19
|
+
return response.data;
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
throw new Error("Failed while send simple mail: " + err);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async sendTemplateMail({ ...data }) {
|
|
26
|
+
try {
|
|
27
|
+
const response = await axios_1.default.post(helpers_1.APP_CONFIG.KMAIL_URL + "/send", {
|
|
28
|
+
...data,
|
|
29
|
+
}, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
|
|
30
|
+
return response.data;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
throw new Error("Failed while send template mail: " + err);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.KMailClient = KMailClient;
|
|
38
|
+
//# sourceMappingURL=KMailClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KMailClient.js","sourceRoot":"","sources":["../../src/kmail/KMailClient.ts"],"names":[],"mappings":";;;;;;AAKA,8CAA8C;AAE9C,kDAA0B;AAE1B,MAAa,WAAW;IACtB,MAAM,CAAC;IACP,YAAY,EAAE,MAAM,EAAsB;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAE,GAAG,IAAI,EAA+B;QAC3D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,oBAAU,CAAC,SAAS,GAAG,OAAO,EAC9B;gBACE,GAAG,IAAI;aACR,EACD,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAC1D,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,GAAG,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,EAAE,GAAG,IAAI,EAAiC;QAC/D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,oBAAU,CAAC,SAAS,GAAG,OAAO,EAC9B;gBACE,GAAG,IAAI;aACR,EACD,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAC1D,CAAC;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,GAAG,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF;AApCD,kCAoCC"}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.KMailServer = void 0;
|
|
7
|
-
const helpers_1 = require("
|
|
7
|
+
const helpers_1 = require("../utils/helpers");
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
class KMailServer {
|
|
10
10
|
apiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KMailServer.js","sourceRoot":"","sources":["../../src/kmail/KMailServer.ts"],"names":[],"mappings":";;;;;;AAKA,
|
|
1
|
+
{"version":3,"file":"KMailServer.js","sourceRoot":"","sources":["../../src/kmail/KMailServer.ts"],"names":[],"mappings":";;;;;;AAKA,8CAA8C;AAE9C,kDAA0B;AAE1B,MAAa,WAAW;IACtB,MAAM,CAAC;IACP,YAAY,EAAE,MAAM,EAAsB;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAE,GAAG,IAAI,EAA+B;QAC3D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,oBAAU,CAAC,SAAS,GAAG,OAAO,EAC9B;gBACE,GAAG,IAAI;aACR,EACD,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAC1D,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,GAAG,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,EAAE,GAAG,IAAI,EAAiC;QAC/D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,oBAAU,CAAC,SAAS,GAAG,OAAO,EAC9B;gBACE,GAAG,IAAI;aACR,EACD,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAC1D,CAAC;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,GAAG,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF;AApCD,kCAoCC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.KSMSClient = void 0;
|
|
7
|
+
const helpers_1 = require("../utils/helpers");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
class KSMSClient {
|
|
10
|
+
apiKey;
|
|
11
|
+
constructor({ apiKey }) {
|
|
12
|
+
this.apiKey = apiKey;
|
|
13
|
+
}
|
|
14
|
+
async sendSMS({ ...data }) {
|
|
15
|
+
try {
|
|
16
|
+
const response = await axios_1.default.post(helpers_1.APP_CONFIG.KSMS_URL + "/send", {
|
|
17
|
+
body: data.message,
|
|
18
|
+
to: data.to,
|
|
19
|
+
from: data.from,
|
|
20
|
+
}, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
|
|
21
|
+
return response.data;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw new Error("Failed while send sms: ", error);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.KSMSClient = KSMSClient;
|
|
29
|
+
//# sourceMappingURL=KSMSClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KSMSClient.js","sourceRoot":"","sources":["../../src/ksms/KSMSClient.ts"],"names":[],"mappings":";;;;;;AAAA,8CAA8C;AAE9C,kDAA0B;AAE1B,MAAa,UAAU;IACrB,MAAM,CAAC;IAEP,YAAY,EAAE,MAAM,EAAsB;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,EAAoB;QACzC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,oBAAU,CAAC,QAAQ,GAAG,OAAO,EAC7B;gBACE,IAAI,EAAE,IAAI,CAAC,OAAO;gBAClB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,EACD,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAC1D,CAAC;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF;AAxBD,gCAwBC"}
|
package/dist/ksms/KSMSServer.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.KSMSServer = void 0;
|
|
7
|
-
const helpers_1 = require("
|
|
7
|
+
const helpers_1 = require("../utils/helpers");
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
class KSMSServer {
|
|
10
10
|
apiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KSMSServer.js","sourceRoot":"","sources":["../../src/ksms/KSMSServer.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"KSMSServer.js","sourceRoot":"","sources":["../../src/ksms/KSMSServer.ts"],"names":[],"mappings":";;;;;;AAAA,8CAA8C;AAE9C,kDAA0B;AAE1B,MAAa,UAAU;IACrB,MAAM,CAAC;IAEP,YAAY,EAAE,MAAM,EAAsB;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,EAAoB;QACzC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,oBAAU,CAAC,QAAQ,GAAG,OAAO,EAC7B;gBACE,IAAI,EAAE,IAAI,CAAC,OAAO;gBAClB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,EACD,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAC1D,CAAC;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF;AAxBD,gCAwBC"}
|
package/package.json
CHANGED