mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Small improvements to Msg91-Node
This commit is contained in:
@@ -24,19 +24,15 @@ export async function msg91ApiRequest(this: IHookFunctions | IExecuteFunctions,
|
|||||||
|
|
||||||
if (query === undefined) {
|
if (query === undefined) {
|
||||||
query = {};
|
query = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
query.authkey = credentials.authkey as string;
|
query.authkey = credentials.authkey as string;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method,
|
method,
|
||||||
form: body,
|
form: body,
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: `https://api.msg91.com/api/sendhttp.php`,
|
uri: `https://api.msg91.com/api${endpoint}`,
|
||||||
auth: {
|
|
||||||
user: '',
|
|
||||||
pass: '',
|
|
||||||
},
|
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -61,4 +57,4 @@ export async function msg91ApiRequest(this: IHookFunctions | IExecuteFunctions,
|
|||||||
// If that data does not exist for some reason return the actual error
|
// If that data does not exist for some reason return the actual error
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ export class Msg91 implements INodeType {
|
|||||||
default: 'sms',
|
default: 'sms',
|
||||||
description: 'The resource to operate on.',
|
description: 'The resource to operate on.',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
name: 'operation',
|
name: 'operation',
|
||||||
@@ -69,8 +68,27 @@ export class Msg91 implements INodeType {
|
|||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Sender',
|
displayName: 'From',
|
||||||
name: 'sender',
|
name: 'from',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
placeholder: '4155238886',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'send',
|
||||||
|
],
|
||||||
|
resource: [
|
||||||
|
'sms',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The number from which to send the message.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'To',
|
||||||
|
name: 'to',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
placeholder: '+14155238886',
|
placeholder: '+14155238886',
|
||||||
@@ -85,26 +103,7 @@ export class Msg91 implements INodeType {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The number from which to send the message',
|
description: 'The number, with coutry code, to which to send the message.',
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'To',
|
|
||||||
name: 'mobiles',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
placeholder: 'Mobile Number With Country Code',
|
|
||||||
required: true,
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
operation: [
|
|
||||||
'send',
|
|
||||||
],
|
|
||||||
resource: [
|
|
||||||
'sms',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: 'The number to which to send the message',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Message',
|
displayName: 'Message',
|
||||||
@@ -145,7 +144,6 @@ export class Msg91 implements INodeType {
|
|||||||
let endpoint: string;
|
let endpoint: string;
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
requestMethod = 'GET';
|
|
||||||
endpoint = '';
|
endpoint = '';
|
||||||
body = {};
|
body = {};
|
||||||
qs = {};
|
qs = {};
|
||||||
@@ -160,12 +158,12 @@ export class Msg91 implements INodeType {
|
|||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'GET';
|
requestMethod = 'GET';
|
||||||
endpoint = 'https://api.msg91.com/api/sendhttp.php';
|
endpoint = '/sendhttp.php';
|
||||||
|
|
||||||
qs.route = 4;
|
qs.route = 4;
|
||||||
qs.country = 0;
|
qs.country = 0;
|
||||||
qs.sender = this.getNodeParameter('sender', i) as string;
|
qs.sender = this.getNodeParameter('from', i) as string;
|
||||||
qs.mobiles = this.getNodeParameter('mobiles', i) as string;
|
qs.mobiles = this.getNodeParameter('to', i) as string;
|
||||||
qs.message = this.getNodeParameter('message', i) as string;
|
qs.message = this.getNodeParameter('message', i) as string;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -177,7 +175,7 @@ export class Msg91 implements INodeType {
|
|||||||
|
|
||||||
const responseData = await msg91ApiRequest.call(this, requestMethod, endpoint, body, qs);
|
const responseData = await msg91ApiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||||
|
|
||||||
returnData.push(responseData as IDataObject);
|
returnData.push({ requestId: responseData });
|
||||||
}
|
}
|
||||||
|
|
||||||
return [this.helpers.returnJsonArray(returnData)];
|
return [this.helpers.returnJsonArray(returnData)];
|
||||||
|
|||||||
Reference in New Issue
Block a user