ubill-sms-client 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Smart Pay Chain
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,476 @@
1
+ # ubill-sms-client
2
+
3
+ Node.js client for [uBill.ge](https://ubill.ge) SMS API. Send SMS messages, manage brand names, check delivery status, and monitor your account balance with ease.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/ubill-sms-client.svg)](https://www.npmjs.com/package/ubill-sms-client)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Features
9
+
10
+ ✨ **Full API Coverage** - Complete implementation of all uBill SMS API endpoints
11
+ 🔒 **Type-Safe** - Written in TypeScript with full type definitions
12
+ ⚡ **Modern** - Promise-based API with async/await support
13
+ 📦 **Lightweight** - Minimal dependencies
14
+ 🛡️ **Error Handling** - Comprehensive error handling and validation
15
+ 📖 **Well Documented** - Extensive documentation and examples
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install ubill-sms-client
21
+ ```
22
+
23
+ Or using yarn:
24
+
25
+ ```bash
26
+ yarn add ubill-sms-client
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```typescript
32
+ import { UBillSMSClient } from "ubill-sms-client";
33
+
34
+ // Initialize the client
35
+ const client = new UBillSMSClient({
36
+ apiKey: "your-api-key-here",
37
+ });
38
+
39
+ // Send an SMS
40
+ async function sendMessage() {
41
+ try {
42
+ const response = await client.sendSMS({
43
+ brandID: 1,
44
+ numbers: [995511194242],
45
+ text: "Hello from uBill!",
46
+ });
47
+
48
+ console.log(`SMS sent successfully! ID: ${response.smsID}`);
49
+ } catch (error) {
50
+ console.error("Failed to send SMS:", error);
51
+ }
52
+ }
53
+
54
+ sendMessage();
55
+ ```
56
+
57
+ ## Configuration
58
+
59
+ ### Creating a Client Instance
60
+
61
+ ```typescript
62
+ const client = new UBillSMSClient({
63
+ apiKey: "your-api-key-here", // Required: Your uBill API key
64
+ baseURL: "https://api.ubill.dev/v1", // Optional: Custom API base URL
65
+ timeout: 30000, // Optional: Request timeout in ms (default: 30000)
66
+ });
67
+ ```
68
+
69
+ ## API Reference
70
+
71
+ ### Brand Name Management
72
+
73
+ #### Create a Brand Name
74
+
75
+ Create a new brand name (sender ID) for your SMS messages. Brand names must be 2-11 characters and require approval before use.
76
+
77
+ ```typescript
78
+ const response = await client.createBrandName("MyBrand");
79
+
80
+ if (response.statusID === 0) {
81
+ console.log(`Brand created with ID: ${response.brandID}`);
82
+ } else {
83
+ console.error(`Error: ${response.message}`);
84
+ }
85
+ ```
86
+
87
+ **Error Codes:**
88
+
89
+ - `0` - Brand name created successfully
90
+ - `10` - Brand name field is empty
91
+ - `20` - Brand name must be 2-11 characters
92
+ - `30` - Unauthorized characters used
93
+ - `40` - Brand name already exists
94
+ - `50` - Wait for previous brand name authentication
95
+ - `90` - JSON error
96
+ - `99` - General error
97
+
98
+ #### Get All Brand Names
99
+
100
+ Retrieve all brand names associated with your account.
101
+
102
+ ```typescript
103
+ const response = await client.getBrandNames();
104
+
105
+ if (response.statusID === 0 && response.data) {
106
+ response.data.forEach((brand) => {
107
+ console.log(
108
+ `${brand.name} (ID: ${brand.id}) - Authorized: ${
109
+ brand.authorized === "1" ? "Yes" : "No"
110
+ }`
111
+ );
112
+ });
113
+ }
114
+ ```
115
+
116
+ **Response Fields:**
117
+
118
+ - `id` - Brand ID
119
+ - `name` - Brand name
120
+ - `authorized` - Authorization status ('1' = authorized, '2' = pending)
121
+ - `createdAt` - Creation timestamp
122
+
123
+ ### Sending SMS
124
+
125
+ #### Send SMS (Recommended Method)
126
+
127
+ Send SMS messages using POST request (most reliable method).
128
+
129
+ ```typescript
130
+ // Send to a single number
131
+ const response = await client.sendSMS({
132
+ brandID: 1,
133
+ numbers: [995511194242],
134
+ text: "Your verification code is: 123456",
135
+ });
136
+
137
+ // Send to multiple numbers
138
+ const response = await client.sendSMS({
139
+ brandID: 1,
140
+ numbers: [995511194242, 995511194243, 995511194244],
141
+ text: "Bulk SMS message",
142
+ stopList: false, // Optional: check against stop list (default: false)
143
+ });
144
+
145
+ console.log(`SMS ID: ${response.smsID}`);
146
+ ```
147
+
148
+ **Parameters:**
149
+
150
+ - `brandID` (required) - Your brand ID
151
+ - `numbers` (required) - Array of phone numbers or comma-separated string
152
+ - `text` (required) - SMS message text
153
+ - `stopList` (optional) - Enable/disable stop list checking (default: false)
154
+
155
+ **Error Codes:**
156
+
157
+ - `0` - SMS sent successfully
158
+ - `10` - Brand ID not found
159
+ - `20` - Numbers not found
160
+ - `30` - Empty message text
161
+ - `40` - Insufficient SMS balance
162
+ - `50` - No valid numbers found
163
+ - `90` - JSON error
164
+ - `99` - General error
165
+
166
+ #### Send SMS via GET
167
+
168
+ Alternative method using GET request with URL parameters.
169
+
170
+ ```typescript
171
+ const response = await client.sendSMSGet({
172
+ brandID: 1,
173
+ numbers: "995511194242,995511194243",
174
+ text: "Hello via GET",
175
+ stopList: false,
176
+ });
177
+ ```
178
+
179
+ ### Delivery Reports
180
+
181
+ #### Check SMS Delivery Status
182
+
183
+ Get the delivery status of a sent SMS message.
184
+
185
+ ```typescript
186
+ const report = await client.getDeliveryReport(117345);
187
+
188
+ if (report.statusID === 0 && report.result) {
189
+ report.result.forEach((status) => {
190
+ console.log(
191
+ `Number: ${status.number}, Status: ${getStatusText(status.statusID)}`
192
+ );
193
+ });
194
+ }
195
+
196
+ function getStatusText(statusID: string): string {
197
+ const statuses: Record<string, string> = {
198
+ "0": "Sent",
199
+ "1": "Received",
200
+ "2": "Not delivered",
201
+ "3": "Awaiting status",
202
+ "4": "Error",
203
+ };
204
+ return statuses[statusID] || "Unknown";
205
+ }
206
+ ```
207
+
208
+ **Status Codes:**
209
+
210
+ - `0` - Sent
211
+ - `1` - Received (delivered successfully)
212
+ - `2` - Not delivered
213
+ - `3` - Awaiting status
214
+ - `4` - Error
215
+
216
+ ### Account Balance
217
+
218
+ #### Check SMS Balance
219
+
220
+ Get your current SMS balance.
221
+
222
+ ```typescript
223
+ const balance = await client.getBalance();
224
+
225
+ if (balance.statusID === 0) {
226
+ console.log(`Remaining SMS: ${balance.balance}`);
227
+ }
228
+ ```
229
+
230
+ ## Complete Example
231
+
232
+ Here's a complete example demonstrating all features:
233
+
234
+ ```typescript
235
+ import { UBillSMSClient } from "ubill-sms-client";
236
+
237
+ async function main() {
238
+ // Initialize client
239
+ const client = new UBillSMSClient({
240
+ apiKey: "your-api-key-here",
241
+ });
242
+
243
+ try {
244
+ // 1. Check balance
245
+ const balance = await client.getBalance();
246
+ console.log(`Current balance: ${balance.balance} SMS`);
247
+
248
+ // 2. Get brand names
249
+ const brands = await client.getBrandNames();
250
+ if (brands.data && brands.data.length > 0) {
251
+ const authorizedBrand = brands.data.find((b) => b.authorized === "1");
252
+
253
+ if (authorizedBrand) {
254
+ // 3. Send SMS
255
+ const smsResponse = await client.sendSMS({
256
+ brandID: parseInt(authorizedBrand.id),
257
+ numbers: [995511194242],
258
+ text: "Test message from uBill SMS Client",
259
+ });
260
+
261
+ console.log(`SMS sent! ID: ${smsResponse.smsID}`);
262
+
263
+ // 4. Wait a bit, then check delivery status
264
+ await new Promise((resolve) => setTimeout(resolve, 5000));
265
+
266
+ const report = await client.getDeliveryReport(smsResponse.smsID!);
267
+ console.log("Delivery report:", report);
268
+ } else {
269
+ console.log("No authorized brands found. Creating a new brand...");
270
+
271
+ const newBrand = await client.createBrandName("MyApp");
272
+ console.log(
273
+ `Brand created: ${newBrand.brandID}. Waiting for approval...`
274
+ );
275
+ }
276
+ }
277
+ } catch (error) {
278
+ console.error("Error:", error);
279
+ }
280
+ }
281
+
282
+ main();
283
+ ```
284
+
285
+ ## Error Handling
286
+
287
+ The client throws descriptive errors that you can catch and handle:
288
+
289
+ ```typescript
290
+ import { UBillSMSClient } from "ubill-sms-client";
291
+
292
+ const client = new UBillSMSClient({
293
+ apiKey: "your-api-key",
294
+ });
295
+
296
+ try {
297
+ const response = await client.sendSMS({
298
+ brandID: 1,
299
+ numbers: [995511194242],
300
+ text: "Test message",
301
+ });
302
+
303
+ if (response.statusID !== 0) {
304
+ console.error(`API Error: ${response.message}`);
305
+ }
306
+ } catch (error) {
307
+ if (error instanceof Error) {
308
+ console.error("Failed to send SMS:", error.message);
309
+ }
310
+ }
311
+ ```
312
+
313
+ ## TypeScript Support
314
+
315
+ This package is written in TypeScript and includes full type definitions:
316
+
317
+ ```typescript
318
+ import {
319
+ UBillSMSClient,
320
+ SendSMSOptions,
321
+ SendSMSResponse,
322
+ DeliveryReportResponse,
323
+ BrandName,
324
+ } from "ubill-sms-client";
325
+
326
+ const client: UBillSMSClient = new UBillSMSClient({
327
+ apiKey: "your-api-key",
328
+ });
329
+
330
+ const options: SendSMSOptions = {
331
+ brandID: 1,
332
+ numbers: [995511194242],
333
+ text: "Typed message",
334
+ };
335
+
336
+ const response: SendSMSResponse = await client.sendSMS(options);
337
+ ```
338
+
339
+ ## Phone Number Format
340
+
341
+ uBill works exclusively with **Georgian mobile numbers**. The client automatically validates phone numbers before sending.
342
+
343
+ ### Accepted Formats
344
+
345
+ ✅ **With country code**: `995XXXXXXXXX` (12 digits)
346
+
347
+ ```typescript
348
+ 995511194242; // Valid
349
+ 995555123456; // Valid
350
+ 995591234567; // Valid
351
+ ```
352
+
353
+ ✅ **Without country code**: `XXXXXXXXX` (9 digits starting with 5)
354
+
355
+ ```typescript
356
+ 511194242; // Valid
357
+ 555123456; // Valid
358
+ 591234567; // Valid
359
+ ```
360
+
361
+ ### Requirements
362
+
363
+ - Must start with **5** (Georgian mobile prefix)
364
+ - With country code: exactly **12 digits** (995 + 9 digits)
365
+ - Without country code: exactly **9 digits**
366
+ - Valid mobile prefixes: 5XX (like 511, 555, 558, 568, 571, 574, 577, 591-599)
367
+
368
+ ### Invalid Examples
369
+
370
+ ❌ Wrong country code:
371
+
372
+ ```typescript
373
+ 994511194242; // Not Georgia
374
+ 996511194242; // Not Georgia
375
+ ```
376
+
377
+ ❌ Doesn't start with 5:
378
+
379
+ ```typescript
380
+ 995411194242; // Must start with 5
381
+ 995611194242; // Must start with 5
382
+ ```
383
+
384
+ ❌ Wrong length:
385
+
386
+ ```typescript
387
+ 99551119424; // Too short
388
+ 9955111942422; // Too long
389
+ 51119424; // Too short
390
+ 5111942422; // Too long
391
+ ```
392
+
393
+ ### Validation Error
394
+
395
+ If you provide an invalid number, you'll get a clear error:
396
+
397
+ ```typescript
398
+ try {
399
+ await client.sendSMS({
400
+ brandID: 1,
401
+ numbers: [995411194242], // Invalid: doesn't start with 5
402
+ text: "Test",
403
+ });
404
+ } catch (error) {
405
+ // Error: Invalid Georgian mobile number(s): 995411194242.
406
+ // Expected format: 995XXXXXXXXX (with country code) or XXXXXXXXX (without), starting with 5.
407
+ }
408
+ ```
409
+
410
+ ## Best Practices
411
+
412
+ 1. **Store your API key securely** - Use environment variables, never commit keys to version control
413
+ 2. **Handle errors gracefully** - Always wrap API calls in try-catch blocks
414
+ 3. **Check status codes** - Verify `statusID === 0` for successful responses
415
+ 4. **Use POST method** - Prefer `sendSMS()` over `sendSMSGet()` for better security
416
+ 5. **Monitor your balance** - Regularly check your SMS balance to avoid failed sends
417
+ 6. **Brand name approval** - Wait for brand name approval before sending SMS
418
+ 7. **Rate limiting** - Implement appropriate rate limiting in your application
419
+
420
+ ## Environment Variables
421
+
422
+ Store your API key in environment variables:
423
+
424
+ ```bash
425
+ # .env file
426
+ UBILL_API_KEY=your-api-key-here
427
+ ```
428
+
429
+ ```typescript
430
+ import { UBillSMSClient } from "ubill-sms-client";
431
+
432
+ const client = new UBillSMSClient({
433
+ apiKey: process.env.UBILL_API_KEY!,
434
+ });
435
+ ```
436
+
437
+ ## Requirements
438
+
439
+ - Node.js 14.0.0 or higher
440
+ - A uBill.ge account with API access
441
+ - Valid API key from your uBill dashboard
442
+
443
+ ## API Documentation
444
+
445
+ For more information about the uBill SMS API, visit:
446
+
447
+ - [Official API Documentation](https://documenter.getpostman.com/view/13830965/TVmV6ZWT)
448
+ - [uBill.ge Website](https://ubill.ge)
449
+
450
+ ## Contributing
451
+
452
+ Contributions are welcome! Please feel free to submit a Pull Request.
453
+
454
+ ## License
455
+
456
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
457
+
458
+ ## Support
459
+
460
+ For issues, questions, or contributions:
461
+
462
+ - GitHub Issues: [https://github.com/Smart-Pay-Chain/ubill.ge-sms/issues](https://github.com/Smart-Pay-Chain/ubill.ge-sms/issues)
463
+ - Email: support@ubill.ge
464
+
465
+ ## Changelog
466
+
467
+ ### 1.0.0 (2025-12-25)
468
+
469
+ - Initial release
470
+ - Full API coverage for uBill SMS API
471
+ - TypeScript support
472
+ - Comprehensive documentation
473
+
474
+ ---
475
+
476
+ Made with ❤️ by [Smart Pay Chain](https://github.com/Smart-Pay-Chain)
@@ -0,0 +1,164 @@
1
+ import { UBillSMSConfig, BrandNameCreateResponse, BrandNamesResponse, SendSMSOptions, SendSMSResponse, DeliveryReportResponse, BalanceResponse, SendSMSGetOptions } from "./types";
2
+ /**
3
+ * uBill SMS Client
4
+ *
5
+ * A Node.js client for interacting with the uBill.ge SMS API.
6
+ * Supports sending SMS messages, managing brand names, checking delivery status, and account balance.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { UBillSMSClient } from '@ubillge/sms-client';
11
+ *
12
+ * const client = new UBillSMSClient({
13
+ * apiKey: 'your-api-key-here'
14
+ * });
15
+ *
16
+ * // Send an SMS
17
+ * const response = await client.sendSMS({
18
+ * brandID: 1,
19
+ * numbers: [995511194242],
20
+ * text: 'Hello from uBill!'
21
+ * });
22
+ * ```
23
+ */
24
+ export declare class UBillSMSClient {
25
+ private apiKey;
26
+ private axiosInstance;
27
+ /**
28
+ * Create a new uBill SMS Client instance
29
+ *
30
+ * @param config - Configuration options
31
+ */
32
+ constructor(config: UBillSMSConfig);
33
+ /**
34
+ * Create a new brand name
35
+ *
36
+ * Brand names must be 2-11 characters and approved before use.
37
+ *
38
+ * @param brandName - The brand name to create (2-11 characters)
39
+ * @returns Response containing the created brand ID
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const response = await client.createBrandName('MyBrand');
44
+ * console.log(response.brandID);
45
+ * ```
46
+ */
47
+ createBrandName(brandName: string): Promise<BrandNameCreateResponse>;
48
+ /**
49
+ * Get all brand names for your account
50
+ *
51
+ * @returns List of all brand names
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const response = await client.getBrandNames();
56
+ * response.data?.forEach(brand => {
57
+ * console.log(`${brand.name} - Authorized: ${brand.authorized}`);
58
+ * });
59
+ * ```
60
+ */
61
+ getBrandNames(): Promise<BrandNamesResponse>;
62
+ /**
63
+ * Send SMS via POST request (recommended)
64
+ *
65
+ * Sends SMS messages to one or more phone numbers.
66
+ *
67
+ * @param options - SMS sending options
68
+ * @returns Response containing the SMS ID for tracking
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * // Send to a single number
73
+ * const response = await client.sendSMS({
74
+ * brandID: 1,
75
+ * numbers: [995511194242],
76
+ * text: 'Hello World!'
77
+ * });
78
+ *
79
+ * // Send to multiple numbers
80
+ * const response = await client.sendSMS({
81
+ * brandID: 1,
82
+ * numbers: [995511194242, 995511194243],
83
+ * text: 'Bulk message',
84
+ * stopList: false
85
+ * });
86
+ * ```
87
+ */
88
+ sendSMS(options: SendSMSOptions): Promise<SendSMSResponse>;
89
+ /**
90
+ * Send SMS via GET request
91
+ *
92
+ * Alternative method to send SMS using URL parameters.
93
+ * Use POST method for better security and reliability.
94
+ *
95
+ * @param options - SMS sending options
96
+ * @returns Response containing the SMS ID for tracking
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const response = await client.sendSMSGet({
101
+ * brandID: 1,
102
+ * numbers: '995511194242,995511194243',
103
+ * text: 'Hello via GET'
104
+ * });
105
+ * ```
106
+ */
107
+ sendSMSGet(options: SendSMSGetOptions): Promise<SendSMSResponse>;
108
+ /**
109
+ * Validate Georgian mobile number
110
+ * @private
111
+ * @param number - Phone number to validate
112
+ * @returns true if valid Georgian mobile number
113
+ */
114
+ private isValidGeorgianMobile;
115
+ /**
116
+ * Validate an array of phone numbers
117
+ * @private
118
+ * @param numbers - Array of phone numbers to validate
119
+ * @throws Error if any number is invalid
120
+ */
121
+ private validatePhoneNumbers;
122
+ /**
123
+ * Get delivery report for a sent SMS
124
+ *
125
+ * Check the delivery status of an SMS message.
126
+ *
127
+ * Status codes:
128
+ * - 0: Sent
129
+ * - 1: Received
130
+ * - 2: Not delivered
131
+ * - 3: Awaiting status
132
+ * - 4: Error
133
+ *
134
+ * @param smsID - The SMS ID received from sendSMS
135
+ * @returns Delivery report with status for each number
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const report = await client.getDeliveryReport(117345);
140
+ * report.result?.forEach(status => {
141
+ * console.log(`${status.number}: ${status.statusID}`);
142
+ * });
143
+ * ```
144
+ */
145
+ getDeliveryReport(smsID: number | string): Promise<DeliveryReportResponse>;
146
+ /**
147
+ * Get SMS balance for your account
148
+ *
149
+ * @returns Current SMS balance
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const balance = await client.getBalance();
154
+ * console.log(`Remaining SMS: ${balance.balance}`);
155
+ * ```
156
+ */
157
+ getBalance(): Promise<BalanceResponse>;
158
+ /**
159
+ * Handle API errors
160
+ * @private
161
+ */
162
+ private handleError;
163
+ }
164
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EAElB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAgB;IAErC;;;;OAIG;gBACS,MAAM,EAAE,cAAc;IAiBlC;;;;;;;;;;;;;OAaG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAW1E;;;;;;;;;;;;OAYG;IACG,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;IASlD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAyBhE;;;;;;;;;;;;;;;;;OAiBG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAuBtE;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAkB7B;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,iBAAiB,CACrB,KAAK,EAAE,MAAM,GAAG,MAAM,GACrB,OAAO,CAAC,sBAAsB,CAAC;IASlC;;;;;;;;;;OAUG;IACG,UAAU,IAAI,OAAO,CAAC,eAAe,CAAC;IAW5C;;;OAGG;IACH,OAAO,CAAC,WAAW;CA4BpB"}
package/dist/client.js ADDED
@@ -0,0 +1,293 @@
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.UBillSMSClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ /**
9
+ * uBill SMS Client
10
+ *
11
+ * A Node.js client for interacting with the uBill.ge SMS API.
12
+ * Supports sending SMS messages, managing brand names, checking delivery status, and account balance.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { UBillSMSClient } from '@ubillge/sms-client';
17
+ *
18
+ * const client = new UBillSMSClient({
19
+ * apiKey: 'your-api-key-here'
20
+ * });
21
+ *
22
+ * // Send an SMS
23
+ * const response = await client.sendSMS({
24
+ * brandID: 1,
25
+ * numbers: [995511194242],
26
+ * text: 'Hello from uBill!'
27
+ * });
28
+ * ```
29
+ */
30
+ class UBillSMSClient {
31
+ /**
32
+ * Create a new uBill SMS Client instance
33
+ *
34
+ * @param config - Configuration options
35
+ */
36
+ constructor(config) {
37
+ if (!config.apiKey) {
38
+ throw new Error("API key is required");
39
+ }
40
+ this.apiKey = config.apiKey;
41
+ this.axiosInstance = axios_1.default.create({
42
+ baseURL: config.baseURL || "https://api.ubill.dev/v1",
43
+ timeout: config.timeout || 30000,
44
+ headers: {
45
+ "Content-Type": "application/json",
46
+ key: this.apiKey,
47
+ },
48
+ });
49
+ }
50
+ /**
51
+ * Create a new brand name
52
+ *
53
+ * Brand names must be 2-11 characters and approved before use.
54
+ *
55
+ * @param brandName - The brand name to create (2-11 characters)
56
+ * @returns Response containing the created brand ID
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const response = await client.createBrandName('MyBrand');
61
+ * console.log(response.brandID);
62
+ * ```
63
+ */
64
+ async createBrandName(brandName) {
65
+ try {
66
+ const response = await this.axiosInstance.put("/sms/brandNameCreate", {
67
+ brandName,
68
+ });
69
+ return response.data;
70
+ }
71
+ catch (error) {
72
+ throw this.handleError(error);
73
+ }
74
+ }
75
+ /**
76
+ * Get all brand names for your account
77
+ *
78
+ * @returns List of all brand names
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const response = await client.getBrandNames();
83
+ * response.data?.forEach(brand => {
84
+ * console.log(`${brand.name} - Authorized: ${brand.authorized}`);
85
+ * });
86
+ * ```
87
+ */
88
+ async getBrandNames() {
89
+ try {
90
+ const response = await this.axiosInstance.get("/sms/brandNames");
91
+ return response.data;
92
+ }
93
+ catch (error) {
94
+ throw this.handleError(error);
95
+ }
96
+ }
97
+ /**
98
+ * Send SMS via POST request (recommended)
99
+ *
100
+ * Sends SMS messages to one or more phone numbers.
101
+ *
102
+ * @param options - SMS sending options
103
+ * @returns Response containing the SMS ID for tracking
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * // Send to a single number
108
+ * const response = await client.sendSMS({
109
+ * brandID: 1,
110
+ * numbers: [995511194242],
111
+ * text: 'Hello World!'
112
+ * });
113
+ *
114
+ * // Send to multiple numbers
115
+ * const response = await client.sendSMS({
116
+ * brandID: 1,
117
+ * numbers: [995511194242, 995511194243],
118
+ * text: 'Bulk message',
119
+ * stopList: false
120
+ * });
121
+ * ```
122
+ */
123
+ async sendSMS(options) {
124
+ try {
125
+ const { brandID, numbers, text, stopList = false } = options;
126
+ const numbersArray = Array.isArray(numbers)
127
+ ? numbers
128
+ : numbers.split(",").map((n) => parseInt(n.trim()));
129
+ // Validate phone numbers
130
+ this.validatePhoneNumbers(numbersArray);
131
+ const payload = {
132
+ brandID,
133
+ numbers: numbersArray,
134
+ text,
135
+ stopList,
136
+ };
137
+ const response = await this.axiosInstance.post("/sms/send", payload);
138
+ return response.data;
139
+ }
140
+ catch (error) {
141
+ throw this.handleError(error);
142
+ }
143
+ }
144
+ /**
145
+ * Send SMS via GET request
146
+ *
147
+ * Alternative method to send SMS using URL parameters.
148
+ * Use POST method for better security and reliability.
149
+ *
150
+ * @param options - SMS sending options
151
+ * @returns Response containing the SMS ID for tracking
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const response = await client.sendSMSGet({
156
+ * brandID: 1,
157
+ * numbers: '995511194242,995511194243',
158
+ * text: 'Hello via GET'
159
+ * });
160
+ * ```
161
+ */
162
+ async sendSMSGet(options) {
163
+ try {
164
+ const { brandID, numbers, text, stopList = false } = options;
165
+ // Validate phone numbers from comma-separated string
166
+ const numbersArray = numbers.split(",").map((n) => parseInt(n.trim()));
167
+ this.validatePhoneNumbers(numbersArray);
168
+ const response = await this.axiosInstance.get("/sms/send", {
169
+ params: {
170
+ key: this.apiKey,
171
+ brandID,
172
+ numbers,
173
+ text,
174
+ stopList,
175
+ },
176
+ });
177
+ return response.data;
178
+ }
179
+ catch (error) {
180
+ throw this.handleError(error);
181
+ }
182
+ }
183
+ /**
184
+ * Validate Georgian mobile number
185
+ * @private
186
+ * @param number - Phone number to validate
187
+ * @returns true if valid Georgian mobile number
188
+ */
189
+ isValidGeorgianMobile(number) {
190
+ const numberStr = String(number);
191
+ // Georgian mobile number patterns:
192
+ // Format 1: 995XXXXXXXXX (12 digits with country code)
193
+ // Format 2: XXXXXXXXX (9 digits without country code)
194
+ // Mobile prefixes in Georgia: 5XX (like 511, 555, 558, 568, 571, 574, 577, 591-599)
195
+ // Pattern with country code 995
196
+ const withCountryCode = /^995[5]\d{8}$/;
197
+ // Pattern without country code (starts with 5)
198
+ const withoutCountryCode = /^[5]\d{8}$/;
199
+ return (withCountryCode.test(numberStr) || withoutCountryCode.test(numberStr));
200
+ }
201
+ /**
202
+ * Validate an array of phone numbers
203
+ * @private
204
+ * @param numbers - Array of phone numbers to validate
205
+ * @throws Error if any number is invalid
206
+ */
207
+ validatePhoneNumbers(numbers) {
208
+ const invalidNumbers = numbers.filter((num) => !this.isValidGeorgianMobile(num));
209
+ if (invalidNumbers.length > 0) {
210
+ throw new Error(`Invalid Georgian mobile number(s): ${invalidNumbers.join(", ")}. ` +
211
+ `Expected format: 995XXXXXXXXX (with country code) or XXXXXXXXX (without), starting with 5.`);
212
+ }
213
+ }
214
+ /**
215
+ * Get delivery report for a sent SMS
216
+ *
217
+ * Check the delivery status of an SMS message.
218
+ *
219
+ * Status codes:
220
+ * - 0: Sent
221
+ * - 1: Received
222
+ * - 2: Not delivered
223
+ * - 3: Awaiting status
224
+ * - 4: Error
225
+ *
226
+ * @param smsID - The SMS ID received from sendSMS
227
+ * @returns Delivery report with status for each number
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const report = await client.getDeliveryReport(117345);
232
+ * report.result?.forEach(status => {
233
+ * console.log(`${status.number}: ${status.statusID}`);
234
+ * });
235
+ * ```
236
+ */
237
+ async getDeliveryReport(smsID) {
238
+ try {
239
+ const response = await this.axiosInstance.get(`/sms/report/${smsID}`);
240
+ return response.data;
241
+ }
242
+ catch (error) {
243
+ throw this.handleError(error);
244
+ }
245
+ }
246
+ /**
247
+ * Get SMS balance for your account
248
+ *
249
+ * @returns Current SMS balance
250
+ *
251
+ * @example
252
+ * ```typescript
253
+ * const balance = await client.getBalance();
254
+ * console.log(`Remaining SMS: ${balance.balance}`);
255
+ * ```
256
+ */
257
+ async getBalance() {
258
+ try {
259
+ const response = await this.axiosInstance.get("/sms/balance", {
260
+ params: { key: this.apiKey },
261
+ });
262
+ return response.data;
263
+ }
264
+ catch (error) {
265
+ throw this.handleError(error);
266
+ }
267
+ }
268
+ /**
269
+ * Handle API errors
270
+ * @private
271
+ */
272
+ handleError(error) {
273
+ if (axios_1.default.isAxiosError(error)) {
274
+ const axiosError = error;
275
+ if (axiosError.response?.data) {
276
+ const errorData = axiosError.response.data;
277
+ return new Error(`uBill API Error (${errorData.statusID}): ${errorData.message}`);
278
+ }
279
+ if (axiosError.response) {
280
+ return new Error(`HTTP Error ${axiosError.response.status}: ${axiosError.response.statusText}`);
281
+ }
282
+ if (axiosError.request) {
283
+ return new Error("No response received from uBill API");
284
+ }
285
+ }
286
+ if (error instanceof Error) {
287
+ return error;
288
+ }
289
+ return new Error("Unknown error occurred");
290
+ }
291
+ }
292
+ exports.UBillSMSClient = UBillSMSClient;
293
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyD;AAazD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,cAAc;IAIzB;;;;OAIG;IACH,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAE5B,IAAI,CAAC,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,0BAA0B;YACrD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;YAChC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,EAAE,IAAI,CAAC,MAAM;aACjB;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,eAAe,CAAC,SAAiB;QACrC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,sBAAsB,EAAE;gBACpE,SAAS;aACV,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;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oB,SAAS,CAAC,QAAQ,MAAM,SAAS,CAAC,OAAO,EAAE,CAChE,CAAC;YACJ,CAAC;YAED,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACxB,OAAO,IAAI,KAAK,CACd,cAAc,UAAU,CAAC,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAC9E,CAAC;YACJ,CAAC;YAED,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;gBACvB,OAAO,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC7C,CAAC;CACF;AAxSD,wCAwSC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @ubillge/sms-client
3
+ *
4
+ * Official Node.js client for uBill.ge SMS API
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export { UBillSMSClient } from './client';
9
+ export * from './types';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * @ubillge/sms-client
4
+ *
5
+ * Official Node.js client for uBill.ge SMS API
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.UBillSMSClient = void 0;
25
+ var client_1 = require("./client");
26
+ Object.defineProperty(exports, "UBillSMSClient", { enumerable: true, get: function () { return client_1.UBillSMSClient; } });
27
+ __exportStar(require("./types"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;AAEH,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,0CAAwB"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Configuration options for the uBill SMS Client
3
+ */
4
+ export interface UBillSMSConfig {
5
+ /** Your uBill API key */
6
+ apiKey: string;
7
+ /** Base URL for the API (defaults to https://api.ubill.dev/v1) */
8
+ baseURL?: string;
9
+ /** Request timeout in milliseconds (defaults to 30000) */
10
+ timeout?: number;
11
+ }
12
+ /**
13
+ * Brand name information
14
+ */
15
+ export interface BrandName {
16
+ /** Brand ID */
17
+ id: string;
18
+ /** Brand name (2-11 characters) */
19
+ name: string;
20
+ /** Authorization status (1 = authorized, 2 = not authorized) */
21
+ authorized: '1' | '2';
22
+ /** Creation timestamp */
23
+ createdAt: string;
24
+ }
25
+ /**
26
+ * Response from brand name creation
27
+ */
28
+ export interface BrandNameCreateResponse {
29
+ /** Status ID (0 = success) */
30
+ statusID: number;
31
+ /** Created brand ID */
32
+ brandID?: number;
33
+ /** Response message */
34
+ message: string;
35
+ }
36
+ /**
37
+ * Response from getting all brand names
38
+ */
39
+ export interface BrandNamesResponse {
40
+ /** Status ID (0 = success) */
41
+ statusID: number;
42
+ /** List of brand names */
43
+ data?: BrandName[];
44
+ /** Response message (if error) */
45
+ message?: string;
46
+ }
47
+ /**
48
+ * Options for sending SMS
49
+ */
50
+ export interface SendSMSOptions {
51
+ /** Brand ID to use for sending */
52
+ brandID: number;
53
+ /** Phone number(s) to send to (can be array or comma-separated string) */
54
+ numbers: number[] | string;
55
+ /** SMS message text */
56
+ text: string;
57
+ /** Enable/disable checking numbers in the stop list (defaults to false) */
58
+ stopList?: boolean;
59
+ }
60
+ /**
61
+ * Response from sending SMS
62
+ */
63
+ export interface SendSMSResponse {
64
+ /** Status ID (0 = success) */
65
+ statusID: number;
66
+ /** SMS ID for tracking */
67
+ smsID?: number | string;
68
+ /** Response message */
69
+ message: string;
70
+ }
71
+ /**
72
+ * Delivery status for a single number
73
+ */
74
+ export interface DeliveryStatus {
75
+ /** Phone number */
76
+ number: string;
77
+ /**
78
+ * Status ID:
79
+ * 0 = Sent
80
+ * 1 = Received
81
+ * 2 = Not delivered
82
+ * 3 = Awaiting status
83
+ * 4 = Error
84
+ */
85
+ statusID: '0' | '1' | '2' | '3' | '4';
86
+ }
87
+ /**
88
+ * Response from delivery report
89
+ */
90
+ export interface DeliveryReportResponse {
91
+ /** Status ID (0 = success) */
92
+ statusID: number;
93
+ /** Delivery status for each number */
94
+ result?: DeliveryStatus[];
95
+ /** Response message (if error) */
96
+ message?: string;
97
+ }
98
+ /**
99
+ * Response from SMS balance check
100
+ */
101
+ export interface BalanceResponse {
102
+ /** Status ID (0 = success) */
103
+ statusID: number;
104
+ /** Remaining SMS balance */
105
+ balance?: number;
106
+ /** Response message (if error) */
107
+ message?: string;
108
+ }
109
+ /**
110
+ * Error response from API
111
+ */
112
+ export interface UBillAPIError {
113
+ /** Status ID (non-zero indicates error) */
114
+ statusID: number;
115
+ /** Error message */
116
+ message: string;
117
+ }
118
+ /**
119
+ * Send SMS via GET request options
120
+ */
121
+ export interface SendSMSGetOptions {
122
+ /** Brand ID to use for sending */
123
+ brandID: number;
124
+ /** Comma-separated phone numbers */
125
+ numbers: string;
126
+ /** SMS message text */
127
+ text: string;
128
+ /** Enable/disable checking numbers in the stop list */
129
+ stopList?: boolean;
130
+ }
131
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,eAAe;IACf,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC;IACtB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC3B,uBAAuB;IACvB,IAAI,EAAE,M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 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "ubill-sms-client",
3
+ "version": "1.0.0",
4
+ "description": "Node.js client for uBill.ge SMS API - Send SMS messages, manage brand names, check delivery status and account balance",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "test": "jest",
9
+ "test:watch": "jest --watch",
10
+ "test:coverage": "jest --coverage",
11
+ "build": "npm test && tsc",
12
+ "prepare": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "ubill",
16
+ "sms",
17
+ "georgia",
18
+ "messaging",
19
+ "api-client",
20
+ "notifications",
21
+ "ubill.ge",
22
+ "smart-pay-chain"
23
+ ],
24
+ "author": "Smart Pay Chain",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/Smart-Pay-Chain/ubill.ge-sms.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/Smart-Pay-Chain/ubill.ge-sms/issues"
32
+ },
33
+ "homepage": "https://github.com/Smart-Pay-Chain/ubill.ge-sms#readme",
34
+ "files": [
35
+ "dist",
36
+ "README.md",
37
+ "LICENSE"
38
+ ],
39
+ "engines": {
40
+ "node": ">=14.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/jest": "^29.5.11",
44
+ "@types/node": "^20.10.0",
45
+ "jest": "^29.7.0",
46
+ "ts-jest": "^29.1.1",
47
+ "typescript": "^5.3.0"
48
+ },
49
+ "dependencies": {
50
+ "axios": "^1.6.2"
51
+ }
52
+ }
53
+