@nimee/inforu 1.0.11 → 1.0.12

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/dist/sendWA.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  export declare function sendWhatsApp(params: {
2
2
  apiKey: string;
3
- message: string;
4
- phone: string;
5
- messageMedia?: string;
6
- customerMessageId?: string;
7
- customerParameter?: string;
3
+ templateParameters: {
4
+ Name: string;
5
+ Type: string;
6
+ Value: string;
7
+ }[];
8
+ templateId: string;
9
+ recipients: {
10
+ FirstName?: string;
11
+ Phone: string;
12
+ Code?: string;
13
+ }[];
8
14
  }): Promise<any>;
package/dist/sendWA.js CHANGED
@@ -16,22 +16,59 @@ exports.sendWhatsApp = void 0;
16
16
  const error_handler_1 = require("@nimee/error-handler");
17
17
  const logger_1 = __importDefault(require("@nimee/logger"));
18
18
  const axios_1 = __importDefault(require("axios"));
19
+ // var axios = require('axios');
20
+ // var data = JSON.stringify({
21
+ // "Data": {
22
+ // "TemplateId": "1216",
23
+ // "TemplateParameters": [
24
+ // {
25
+ // "Name": "[#1#]",
26
+ // "Type": "Contact",
27
+ // "Value": "FirstName"
28
+ // },
29
+ // {
30
+ // "Name": "[#2#]",
31
+ // "Type": "Custom",
32
+ // "Value": "CouponCode"
33
+ // },
34
+ // {
35
+ // "Name": "[#3#]",
36
+ // "Type": "Text",
37
+ // "Value": "alenbi 30"
38
+ // }
39
+ // ],
40
+ // "Recipients": [
41
+ // {
42
+ // "FirstName": "Israel",
43
+ // "LastName": "levi",
44
+ // "Phone": "0529999999",
45
+ // "CouponCode": "1ZG67893"
46
+ // }
47
+ // ]
48
+ // }
49
+ // });
50
+ // var config = {
51
+ // method: 'post',
52
+ // maxBodyLength: Infinity,
53
+ // url: 'https://capi.inforu.co.il/api/v2/WhatsApp/SendWhatsApp',
54
+ // headers: {
55
+ // 'Content-Type': 'application/json',
56
+ // 'Authorization': 'Your Base Credentials'
57
+ // },
58
+ // data : data
59
+ // };
19
60
  function sendWhatsApp(params) {
20
61
  return __awaiter(this, void 0, void 0, function* () {
21
62
  try {
22
- const { apiKey, message, phone, messageMedia, customerMessageId, customerParameter } = params;
63
+ const { apiKey, templateParameters, templateId, recipients } = params;
23
64
  if (!apiKey)
24
65
  throw new error_handler_1.CustomError("Missing_API_KEY_SEND_WHATSAPP", 400, "Missing API key");
25
- const apiUrl = "https://capi.inforu.co.il/api/v2/WhatsApp/SendWhatsAppChat";
66
+ const apiUrl = "https://capi.inforu.co.il/api/v2/WhatsApp/SendWhatsApp";
26
67
  const data = {
27
68
  Data: {
28
- Message: message,
29
- Phone: phone,
30
- MessageMedia: messageMedia,
31
- Settings: {
32
- CustomerMessageId: customerMessageId,
33
- CustomerParameter: customerParameter,
34
- },
69
+ TemplateId: templateId,
70
+ TemplateParameters: templateParameters,
71
+ Recipients: recipients,
35
72
  },
36
73
  };
37
74
  const response = yield axios_1.default.post(apiUrl, data, {
@@ -40,7 +77,7 @@ function sendWhatsApp(params) {
40
77
  Authorization: apiKey,
41
78
  },
42
79
  });
43
- logger_1.default.debug("WhatsApp message sent successfully:", response.data);
80
+ logger_1.default.debug(`WhatsApp message sent successfully: ${response.data}`);
44
81
  return response.data;
45
82
  }
46
83
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"sendWA.js","sourceRoot":"","sources":["../src/sendWA.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAmD;AACnD,2DAAmC;AACnC,kDAA0B;AAE1B,SAAsB,YAAY,CAAC,MAOlC;;QACC,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;YAC9F,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,2BAAW,CAAC,+BAA+B,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;YAE5F,MAAM,MAAM,GAAG,4DAA4D,CAA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"version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "inforu SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "author": "dan goldberg",
package/src/sendWA.ts CHANGED
@@ -1,29 +1,74 @@
1
1
  import { CustomError } from "@nimee/error-handler";
2
2
  import logger from "@nimee/logger";
3
3
  import axios from "axios";
4
+ // var axios = require('axios');
5
+ // var data = JSON.stringify({
6
+ // "Data": {
7
+ // "TemplateId": "1216",
8
+ // "TemplateParameters": [
9
+ // {
10
+ // "Name": "[#1#]",
11
+ // "Type": "Contact",
12
+ // "Value": "FirstName"
13
+ // },
14
+ // {
15
+ // "Name": "[#2#]",
16
+ // "Type": "Custom",
17
+ // "Value": "CouponCode"
18
+ // },
19
+ // {
20
+ // "Name": "[#3#]",
21
+ // "Type": "Text",
22
+ // "Value": "alenbi 30"
23
+ // }
24
+ // ],
25
+ // "Recipients": [
26
+ // {
27
+ // "FirstName": "Israel",
28
+ // "LastName": "levi",
29
+ // "Phone": "0529999999",
30
+ // "CouponCode": "1ZG67893"
31
+ // }
32
+ // ]
33
+ // }
34
+ // });
35
+
36
+ // var config = {
37
+ // method: 'post',
38
+ // maxBodyLength: Infinity,
39
+ // url: 'https://capi.inforu.co.il/api/v2/WhatsApp/SendWhatsApp',
40
+ // headers: {
41
+ // 'Content-Type': 'application/json',
42
+ // 'Authorization': 'Your Base Credentials'
43
+ // },
44
+ // data : data
45
+ // };
4
46
 
5
47
  export async function sendWhatsApp(params: {
6
48
  apiKey: string;
7
- message: string;
8
- phone: string;
9
- messageMedia?: string;
10
- customerMessageId?: string;
11
- customerParameter?: string;
49
+ templateParameters: {
50
+ Name: string;
51
+ Type: string;
52
+ Value: string;
53
+ }[];
54
+ templateId: string;
55
+ recipients: {
56
+ FirstName?: string;
57
+ Phone: string;
58
+ Code?: string;
59
+ }[];
12
60
  }) {
13
61
  try {
14
- const { apiKey, message, phone, messageMedia, customerMessageId, customerParameter } = params;
62
+ const { apiKey, templateParameters, templateId, recipients } = params;
15
63
  if (!apiKey) throw new CustomError("Missing_API_KEY_SEND_WHATSAPP", 400, "Missing API key");
16
64
 
17
- const apiUrl = "https://capi.inforu.co.il/api/v2/WhatsApp/SendWhatsAppChat";
65
+ const apiUrl = "https://capi.inforu.co.il/api/v2/WhatsApp/SendWhatsApp";
66
+
18
67
  const data = {
19
68
  Data: {
20
- Message: message,
21
- Phone: phone,
22
- MessageMedia: messageMedia,
23
- Settings: {
24
- CustomerMessageId: customerMessageId,
25
- CustomerParameter: customerParameter,
26
- },
69
+ TemplateId: templateId,
70
+ TemplateParameters: templateParameters,
71
+ Recipients: recipients,
27
72
  },
28
73
  };
29
74
 
@@ -34,7 +79,7 @@ export async function sendWhatsApp(params: {
34
79
  },
35
80
  });
36
81
 
37
- logger.debug("WhatsApp message sent successfully:", response.data);
82
+ logger.debug(`WhatsApp message sent successfully: ${response.data}`);
38
83
  return response.data;
39
84
  } catch (error) {
40
85
  logger.error(JSON.stringify(error));