n8n-nodes-hamkar 3.3.4 → 3.3.11

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.
@@ -16,7 +16,25 @@ class HamkarApi {
16
16
  },
17
17
  default: '',
18
18
  required: true,
19
- description: 'The API key for Hamkar.co. You can find this in your project connection settings.',
19
+ },
20
+ {
21
+ displayName: 'Project ID',
22
+ name: 'projectId',
23
+ type: 'string',
24
+ default: '',
25
+ required: true,
26
+ },
27
+ {
28
+ displayName: 'Allowed HTTP Request Domains',
29
+ name: 'allowedHttpRequestDomains',
30
+ type: 'string',
31
+ default: 'all',
32
+ },
33
+ {
34
+ displayName: 'Allowed Domains',
35
+ name: 'allowedDomains',
36
+ type: 'string',
37
+ default: '',
20
38
  },
21
39
  ];
22
40
  this.authenticate = {
@@ -31,18 +31,6 @@ class HamkarBulkSms {
31
31
  description: 'Field name containing phone number in input data',
32
32
  required: true,
33
33
  },
34
- // {
35
- // displayName: 'Phones (Manual List - Optional)',
36
- // name: 'phones',
37
- // type: 'string',
38
- // required: false,
39
- // default: '',
40
- // description: 'Optional: Manual comma separated list (overrides input data)',
41
- // typeOptions: {
42
- // multipleValues: true,
43
- // multipleValueButtonText: 'Add Phone Number',
44
- // },
45
- // },
46
34
  {
47
35
  displayName: 'Text (Common Message)',
48
36
  name: 'text',
@@ -60,21 +48,10 @@ class HamkarBulkSms {
60
48
  const items = this.getInputData();
61
49
  const returnData = [];
62
50
  const phoneFieldName = this.getNodeParameter('phoneFieldName', 0);
63
- // const manualPhonesParam = this.getNodeParameter('phones', 0) as string | string[];
64
51
  const commonText = this.getNodeParameter('text', 0);
52
+ const credentials = await this.getCredentials('hamkarApi');
53
+ const projectId = credentials.projectId;
65
54
  let phonesList = [];
66
- // if (manualPhonesParam && manualPhonesParam !== '') {
67
- // if (typeof manualPhonesParam === 'string') {
68
- // if (manualPhonesParam.includes(',')) {
69
- // phonesList = manualPhonesParam.split(',').map(p => p.trim());
70
- // } else {
71
- // phonesList = [manualPhonesParam];
72
- // }
73
- // } else if (Array.isArray(manualPhonesParam)) {
74
- // phonesList = manualPhonesParam;
75
- // }
76
- // }
77
- // else
78
55
  if (items && items.length > 0) {
79
56
  for (const item of items) {
80
57
  const jsonData = item.json;
@@ -97,26 +74,22 @@ class HamkarBulkSms {
97
74
  }
98
75
  }
99
76
  }
100
- // phonesList = [...new Set(phonesList)];
101
77
  if (phonesList.length === 0) {
102
78
  throw new Error('No phone numbers found in input data!');
103
79
  }
104
80
  const bulkData = {
105
81
  text: commonText,
106
82
  phones: phonesList,
107
- total_count: phonesList.length
83
+ total_count: phonesList.length,
84
+ project_id: projectId,
108
85
  };
109
- await this.helpers.httpRequestWithAuthentication.call(this, 'hamkarApi', {
86
+ const response = await this.helpers.httpRequestWithAuthentication.call(this, 'hamkarApi', {
110
87
  method: 'POST',
111
- url: 'https://stg-api.hamkar.co/api/send-bulk-sms/',
88
+ url: 'https://stg-api.hamkar.co/api/send-workflow-sms/',
112
89
  body: bulkData,
113
90
  json: true,
114
91
  });
115
- returnData.push({
116
- phones: phonesList,
117
- message: commonText,
118
- count: phonesList.length
119
- });
92
+ returnData.push(response);
120
93
  return [this.helpers.returnJsonArray(returnData)];
121
94
  }
122
95
  }
@@ -45,13 +45,21 @@ class HamkarSendSms {
45
45
  async execute() {
46
46
  const items = this.getInputData();
47
47
  const returnData = [];
48
+ const credentials = await this.getCredentials('hamkarApi');
49
+ const projectId = credentials.projectId;
48
50
  for (let i = 0; i < items.length; i++) {
49
51
  const phone = this.getNodeParameter('phone', i);
50
52
  const text = this.getNodeParameter('text', i);
53
+ const Data = {
54
+ text: text,
55
+ phones: [phone],
56
+ total_count: 1,
57
+ project_id: projectId,
58
+ };
51
59
  const response = await this.helpers.httpRequestWithAuthentication.call(this, 'hamkarApi', {
52
60
  method: 'POST',
53
- url: 'https://stg-api.hamkar.co/api/send-sms/',
54
- body: { phone, text },
61
+ url: 'https://stg-api.hamkar.co/api/send-workflow-sms/',
62
+ body: Data,
55
63
  json: true,
56
64
  });
57
65
  returnData.push(response);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-hamkar",
3
- "version": "3.3.4",
3
+ "version": "3.3.11",
4
4
  "description": "n8n node for Hamkar.co API - Contact and Record management operations",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",