@kumbify/sdk 1.0.2 → 1.0.4

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 CHANGED
@@ -1 +1,139 @@
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
+ ### Email — KMailClient
33
+
34
+ #### 📍 Create an Email Client
35
+
36
+ ```ts
37
+ const mailClient = new KMailClient({
38
+ apiKey: "YOUR_EMAIL_API_KEY",
39
+ });
40
+ ```
41
+
42
+ ### 📤 Send a Simple Email
43
+
44
+ ```ts
45
+ const sendMail = await mailClient.sendSimpleMail({
46
+ body_html: "<h1>Hello from Kumbify</h1><p>This is a test email</p>",
47
+ body_text: "Hello from Kumbify — this is a test email.",
48
+ from_address: "no-reply@kumbify.app",
49
+ subject: "Welcome Email",
50
+ to_address: ["recipient@example.com"],
51
+ });
52
+
53
+ console.log("Email Response:", sendMail);
54
+ ```
55
+
56
+ **Parameters explained:**
57
+
58
+ | Property | Type | Description |
59
+ | -------------- | -------- | --------------------------------- |
60
+ | `body_html` | string | HTML email content |
61
+ | `body_text` | string | Plain text email content |
62
+ | `from_address` | string | Sender email address |
63
+ | `subject` | string | Email subject |
64
+ | `to_address` | string[] | List of recipient email addresses |
65
+
66
+ ---
67
+
68
+ ### SMS — KSMSClient
69
+
70
+ #### 📍 Create an SMS Client
71
+
72
+ ```ts
73
+ const smsClient = new KSMSClient({
74
+ apiKey: "YOUR_SMS_API_KEY",
75
+ });
76
+ ```
77
+
78
+ #### 📤 Send an SMS Message
79
+
80
+ ```ts
81
+ await smsClient.sendSMS({
82
+ message: "Your verification code is 123456",
83
+ from: "kumbify-app",
84
+ to: "+1234567890",
85
+ });
86
+
87
+ console.log("SMS sent successfully!");
88
+ ```
89
+
90
+ **Parameters explained:**
91
+
92
+ | Property | Type | Description |
93
+ | --------- | ------ | ------------------------------------ |
94
+ | `message` | string | SMS content |
95
+ | `from` | string | Sender identifier (visible to users) |
96
+ | `to` | string | Recipient phone number |
97
+
98
+ ---
99
+
100
+ ### Example Usage All Together
101
+
102
+ ```ts
103
+ import { KMailClient, KSMSClient } from "@kumbify/sdk";
104
+
105
+ const mailClient = new KMailClient({ apiKey: "EMAIL_KEY" });
106
+ const smsClient = new KSMSClient({ apiKey: "SMS_KEY" });
107
+
108
+ // Send Email
109
+ await mailClient.sendSimpleMail({
110
+ body_html: "<p>Hello!</p>",
111
+ body_text: "Hello!",
112
+ from_address: "no-reply@kumbify.com",
113
+ subject: "Test Email",
114
+ to_address: ["user1@example.com"],
115
+ });
116
+
117
+ // Send SMS
118
+ await smsClient.sendSMS({
119
+ message: "Your code is 1234",
120
+ from: "KumbifyApp",
121
+ to: "+1234567890",
122
+ });
123
+ ```
124
+
125
+ ---
126
+
127
+ ### Tips & Best Practices
128
+
129
+ ✔️ Store your API keys in environment variables (never hardcode them).
130
+ ✔️ Always handle promise rejections with `try/catch`.
131
+ ✔️ Log or inspect response objects to monitor delivery success.
132
+
133
+ ---
134
+
135
+ ### Supported Environments
136
+
137
+ ✔ Node.js
138
+ ✔ TypeScript
139
+ ✔ Any JavaScript project that supports npm packages
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./kmail/KMailServer";
2
- export * from "./ksms/KSMSServer";
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/KMailServer"), exports);
18
- __exportStar(require("./ksms/KSMSServer"), exports);
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,42 @@
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 = require("axios");
9
+ const axios_2 = __importDefault(require("axios"));
10
+ class KMailClient {
11
+ apiKey;
12
+ constructor({ apiKey }) {
13
+ this.apiKey = apiKey;
14
+ }
15
+ async sendSimpleMail({ ...data }) {
16
+ try {
17
+ const response = await axios_2.default.post(helpers_1.APP_CONFIG.KMAIL_URL + "/send", {
18
+ ...data,
19
+ }, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
20
+ return response.data;
21
+ }
22
+ catch (error) {
23
+ if (error instanceof axios_1.AxiosError) {
24
+ throw new Error("Message: " + error.response.data);
25
+ }
26
+ throw new Error("Failed while send simple mail: " + error);
27
+ }
28
+ }
29
+ async sendTemplateMail({ ...data }) {
30
+ try {
31
+ const response = await axios_2.default.post(helpers_1.APP_CONFIG.KMAIL_URL + "/send", {
32
+ ...data,
33
+ }, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
34
+ return response.data;
35
+ }
36
+ catch (err) {
37
+ throw new Error("Failed while send template mail: " + err);
38
+ }
39
+ }
40
+ }
41
+ exports.KMailClient = KMailClient;
42
+ //# sourceMappingURL=KMailClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KMailClient.js","sourceRoot":"","sources":["../../src/kmail/KMailClient.ts"],"names":[],"mappings":";;;;;;AAKA,8CAA8C;AAC9C,iCAAmC;AAEnC,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,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,kBAAU,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;QAC7D,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;AAvCD,kCAuCC"}
@@ -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("@/utils/helpers");
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,6CAA6C;AAE7C,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,C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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,8 @@
1
+ import { IKSMSSendMessage } from "../utils/types";
2
+ export declare class KSMSClient {
3
+ apiKey: string;
4
+ constructor({ apiKey }: {
5
+ apiKey: string;
6
+ });
7
+ sendSMS({ ...data }: IKSMSSendMessage): Promise<any>;
8
+ }
@@ -0,0 +1,33 @@
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 axios_1 = require("axios");
8
+ const helpers_1 = require("../utils/helpers");
9
+ const axios_2 = __importDefault(require("axios"));
10
+ class KSMSClient {
11
+ apiKey;
12
+ constructor({ apiKey }) {
13
+ this.apiKey = apiKey;
14
+ }
15
+ async sendSMS({ ...data }) {
16
+ try {
17
+ const response = await axios_2.default.post(helpers_1.APP_CONFIG.KSMS_URL + "/send", {
18
+ body: data.message,
19
+ to: data.to,
20
+ from: data.from,
21
+ }, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
22
+ return response.data;
23
+ }
24
+ catch (error) {
25
+ if (error instanceof axios_1.AxiosError) {
26
+ throw new Error("Message: " + error.response.data);
27
+ }
28
+ throw new Error("Failed while send sms: ", error);
29
+ }
30
+ }
31
+ }
32
+ exports.KSMSClient = KSMSClient;
33
+ //# sourceMappingURL=KSMSClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KSMSClient.js","sourceRoot":"","sources":["../../src/ksms/KSMSClient.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAmC;AACnC,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,IAAI,KAAK,YAAY,kBAAU,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF;AA3BD,gCA2BC"}
@@ -1,4 +1,4 @@
1
- import { IKSMSSendMessage } from "@/utils/types";
1
+ import { IKSMSSendMessage } from "../utils/types";
2
2
  export declare class KSMSServer {
3
3
  apiKey: string;
4
4
  constructor({ apiKey }: {
@@ -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("@/utils/helpers");
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,6CAA6C;AAE7C,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"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumbify/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Oficial Kumbify SDK to integrate our services in your applications",
5
5
  "homepage": "https://github.com/ricardocastl3/kumbify-sdk#readme",
6
6
  "bugs": {