🐛 Fix AWS SQS API version and casing (#1630)

* 🔧 Add API version and adjust casing

* 🔨 Refactor query string params into array

* 🔨 Add API version to resource loader

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Iván Ovejero 2021-04-17 09:59:11 +02:00 committed by GitHub
parent 38ee8f5557
commit db5bf69fd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,4 @@
import {
BINARY_ENCODING,
IExecuteFunctions,
} from 'n8n-core';
@ -23,6 +22,10 @@ import {
awsApiRequestSOAP,
} from '../GenericFunctions';
import {
pascalCase,
} from 'change-case';
export class AwsSqs implements INodeType {
description: INodeTypeDescription = {
displayName: 'AWS SQS',
@ -268,10 +271,15 @@ export class AwsSqs implements INodeType {
loadOptions: {
// Get all the available queues to display them to user so that it can be selected easily
async getQueues(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const params = [
'Version=2012-11-05',
`Action=ListQueues`,
];
let data;
try {
// loads first 1000 queues from SQS
data = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `?Action=ListQueues`);
data = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `?${params.join('&')}`);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
@ -310,7 +318,11 @@ export class AwsSqs implements INodeType {
for (let i = 0; i < items.length; i++) {
const queueUrl = this.getNodeParameter('queue', i) as string;
const queuePath = new URL(queueUrl).pathname;
const params = [];
const params = [
'Version=2012-11-05',
`Action=${pascalCase(operation)}`,
];
const options = this.getNodeParameter('options', i, {}) as IDataObject;
const sendInputData = this.getNodeParameter('sendInputData', i) as boolean;
@ -375,7 +387,7 @@ export class AwsSqs implements INodeType {
let responseData;
try {
responseData = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `${queuePath}/?Action=${operation}&` + params.join('&'));
responseData = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `${queuePath}?${params.join('&')}`);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}