feat(http-request): introduce custom request action

This commit is contained in:
Ali BARIN
2023-02-02 22:30:07 +00:00
parent f98c797311
commit 2f64a074c6
5 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
import defineAction from '../../../../helpers/define-action';
type TMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
export default defineAction({
name: 'Custom Request',
key: 'customRequest',
description: 'Makes a custom HTTP request by providing raw details.',
arguments: [
{
label: 'Method',
key: 'method',
type: 'dropdown' as const,
required: true,
description:
`The HTTP method we'll use to perform the request.`,
value: 'GET',
options: [
{ label: 'DELETE', value: 'DELETE' },
{ label: 'GET', value: 'GET' },
{ label: 'PATCH', value: 'PATCH' },
{ label: 'POST', value: 'POST' },
{ label: 'PUT', value: 'PUT' },
]
},
{
label: 'URL',
key: 'url',
type: 'string' as const,
required: true,
description: 'Any URL with a querystring will be re-encoded properly.',
variables: true,
},
{
label: 'Data',
key: 'data',
type: 'string' as const,
required: true,
description: 'Place raw JSON data here.',
variables: true,
},
],
async run($) {
const method = $.step.parameters.method as TMethod;
const data = $.step.parameters.data as string;
const url = $.step.parameters.url as string;
const response = await $.http.request(
{
url,
method,
data,
headers: {
'Content-Type': 'application/json'
}
}
);
$.setActionItem({ raw: response.data });
},
});

View File

@@ -0,0 +1,3 @@
import customRequest from './custom-request';
export default [customRequest];

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="100px" height="100px"><path d="M 37.09375 0.09375 C 36.316406 0.167969 35.652344 0.691406 35.398438 1.429688 C 35.140625 2.171875 35.339844 2.992188 35.90625 3.53125 L 42.375 10 L 2 10 C 1.9375 9.996094 1.875 9.996094 1.8125 10 C 0.707031 10.050781 -0.144531 10.988281 -0.09375 12.09375 C -0.0429688 13.199219 0.894531 14.050781 2 14 L 42.375 14 L 35.90625 20.46875 C 35.382813 20.96875 35.167969 21.710938 35.347656 22.414063 C 35.527344 23.113281 36.070313 23.664063 36.769531 23.851563 C 37.46875 24.039063 38.214844 23.832031 38.71875 23.3125 L 50.03125 12 L 38.71875 0.6875 C 38.296875 0.253906 37.699219 0.0351563 37.09375 0.09375 Z M 12.5 26.09375 C 12.046875 26.152344 11.628906 26.359375 11.3125 26.6875 L 0 38 L 11.3125 49.3125 C 11.816406 49.832031 12.5625 50.039063 13.261719 49.851563 C 13.960938 49.664063 14.503906 49.113281 14.683594 48.414063 C 14.863281 47.710938 14.648438 46.96875 14.125 46.46875 L 7.65625 40 L 48 40 C 48.722656 40.011719 49.390625 39.632813 49.753906 39.007813 C 50.121094 38.386719 50.121094 37.613281 49.753906 36.992188 C 49.390625 36.367188 48.722656 35.988281 48 36 L 7.65625 36 L 14.125 29.53125 C 14.753906 28.9375 14.929688 28.003906 14.558594 27.222656 C 14.1875 26.441406 13.359375 25.984375 12.5 26.09375 Z"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

View File

@@ -0,0 +1,14 @@
import defineApp from '../../helpers/define-app';
import actions from './actions';
export default defineApp({
name: 'HTTP Request',
key: 'http-request',
iconUrl: '{BASE_URL}/apps/http-request/assets/favicon.svg',
authDocUrl: 'https://automatisch.io/docs/apps/http-request/connection',
supportsConnections: false,
baseUrl: '',
apiBaseUrl: '',
primaryColor: '000000',
actions,
});