andiwagateway 1.0.0 → 1.1.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/PUBLISH_GUIDE.md CHANGED
@@ -78,12 +78,12 @@ npm publish
78
78
  Setelah publish, developer bisa:
79
79
 
80
80
  ```bash
81
- npm install andi-wa-gateway-sdk
81
+ npm install andiwagateway
82
82
  ```
83
83
 
84
84
  Lalu pakai:
85
85
  ```javascript
86
- const sdk = require('andi-wa-gateway-sdk');
86
+ const sdk = require('andiwagateway');
87
87
 
88
88
  const wa = sdk.createClient({
89
89
  apiKey: 'ak_live_xxxx'
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  ## 🎯 Fitur
10
10
 
11
11
  - ✅ **API Key Only** - Tidak perlu setup server, tinggal API Key
12
+ - ✅ **Session Auto-Detect** - Tidak perlu pilih session, otomatis dari API Key
12
13
  - ✅ **Base URL Built-in** - Sudah terkonfigurasi ke `andi-wa-gateway.up.railway.app`
13
14
  - ✅ **OTP Plugin** - Kirim kode verifikasi dengan 1 baris kode
14
15
  - ✅ **Webhook Handler** - Terima pesan masuk dengan mudah
@@ -19,7 +20,7 @@
19
20
  ## 📦 Install
20
21
 
21
22
  ```bash
22
- npm install andi-wa-gateway-sdk
23
+ npm install andiwagateway
23
24
  ```
24
25
 
25
26
  ---
@@ -29,21 +30,24 @@ npm install andi-wa-gateway-sdk
29
30
  ### 1. Kirim Pesan (Basic)
30
31
 
31
32
  ```javascript
32
- const sdk = require('andi-wa-gateway-sdk');
33
+ const sdk = require('andiwagateway');
33
34
 
34
- // Inisialisasi - Cukup API Key!
35
+ // Inisialisasi - Cukup API Key saja! Session auto-detect dari API Key
35
36
  const wa = sdk.createClient({
36
37
  apiKey: 'ak_live_abc123xyz789' // Dari Panel Andi WA Gateway
37
38
  });
38
39
 
39
- // Kirim pesan
40
+ // Kirim pesan - Session auto-detect dari API Key!
40
41
  await wa.sendMessage('628123456789', 'Halo dari SDK!');
42
+
43
+ // Kalau mau pakai session spesifik (opsional)
44
+ await wa.sendMessage('628123456789', 'Halo!', 'session-khusus');
41
45
  ```
42
46
 
43
47
  ### 2. Kirim OTP (Plugin)
44
48
 
45
49
  ```javascript
46
- const sdk = require('andi-wa-gateway-sdk');
50
+ const sdk = require('andiwagateway');
47
51
 
48
52
  const otp = sdk.createOtp({
49
53
  apiKey: 'ak_live_abc123xyz789'
@@ -63,7 +67,7 @@ const isValid = otp.verify(inputUser, result.code);
63
67
  ### 3. Webhook Handler (Terima Pesan)
64
68
 
65
69
  ```javascript
66
- const sdk = require('andi-wa-gateway-sdk');
70
+ const sdk = require('andiwagateway');
67
71
  const webhook = sdk.createWebhook();
68
72
 
69
73
  // Handler pesan masuk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "andiwagateway",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Official SDK for Andi WA Gateway - WhatsApp API integration made simple. Just add API Key and start sending messages.",
5
5
  "main": "src/index.js",
6
6
  "keywords": [
@@ -16,7 +16,7 @@ function createClient(config) {
16
16
  * Kirim pesan teks WhatsApp
17
17
  * @param {string} number - Nomor tujuan (format: 628123456789 atau 08123456789)
18
18
  * @param {string} message - Isi pesan
19
- * @param {string} [sessionId] - Override session ID (opsional)
19
+ * @param {string} [sessionId] - Override session ID (opsional - kalau tidak ada, auto-detect dari API Key)
20
20
  */
21
21
  async sendMessage(number, message, sessionId = null) {
22
22
  const targetSession = sessionId || config.sessionId;
@@ -28,7 +28,7 @@ function createClient(config) {
28
28
  * @param {string} number - Nomor tujuan
29
29
  * @param {string} mediaUrl - URL file/media
30
30
  * @param {string} [caption] - Keterangan media
31
- * @param {string} [sessionId] - Override session ID
31
+ * @param {string} [sessionId] - Override session ID (opsional)
32
32
  */
33
33
  async sendMedia(number, mediaUrl, caption = '', sessionId = null) {
34
34
  const targetSession = sessionId || config.sessionId;
@@ -17,21 +17,30 @@ function createHttpClient(config) {
17
17
 
18
18
  return {
19
19
  async sendMessage(sessionId, number, message) {
20
- const response = await instance.post('/messages/send', {
21
- sessionId,
20
+ const payload = {
22
21
  number: formatNumber(number),
23
22
  message
24
- });
23
+ };
24
+ // Hanya tambah sessionId kalau disediakan
25
+ if (sessionId) {
26
+ payload.sessionId = sessionId;
27
+ }
28
+
29
+ const response = await instance.post('/messages/send', payload);
25
30
  return response.data;
26
31
  },
27
32
 
28
33
  async sendMedia(sessionId, number, mediaUrl, caption = '') {
29
- const response = await instance.post('/messages/send-media', {
30
- sessionId,
34
+ const payload = {
31
35
  number: formatNumber(number),
32
36
  mediaUrl,
33
37
  caption
34
- });
38
+ };
39
+ if (sessionId) {
40
+ payload.sessionId = sessionId;
41
+ }
42
+
43
+ const response = await instance.post('/messages/send-media', payload);
35
44
  return response.data;
36
45
  },
37
46