mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
change icon
This commit is contained in:
commit
8b00dd0b8c
|
@ -0,0 +1,45 @@
|
||||||
|
import {
|
||||||
|
ICredentialType,
|
||||||
|
NodePropertyTypes,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export class PagerDutyOAuth2Api implements ICredentialType {
|
||||||
|
name = 'pagerDutyOAuth2Api';
|
||||||
|
extends = [
|
||||||
|
'oAuth2Api',
|
||||||
|
];
|
||||||
|
displayName = 'PagerDuty OAuth2 API';
|
||||||
|
properties = [
|
||||||
|
{
|
||||||
|
displayName: 'Authorization URL',
|
||||||
|
name: 'authUrl',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: 'https://app.pagerduty.com/oauth/authorize',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Access Token URL',
|
||||||
|
name: 'accessTokenUrl',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: 'https://app.pagerduty.com/oauth/token',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Auth URI Query Parameters',
|
||||||
|
name: 'authQueryParameters',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Scope',
|
||||||
|
name: 'scope',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Authentication',
|
||||||
|
name: 'authentication',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: 'header',
|
||||||
|
description: 'Method of authentication.',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
import {
|
||||||
|
ICredentialType,
|
||||||
|
NodePropertyTypes,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
const scopes = [
|
||||||
|
'webhooks:write',
|
||||||
|
'webhooks:read',
|
||||||
|
'forms:read',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
export class TypeformOAuth2Api implements ICredentialType {
|
||||||
|
name = 'typeformOAuth2Api';
|
||||||
|
extends = [
|
||||||
|
'oAuth2Api',
|
||||||
|
];
|
||||||
|
displayName = 'Typeform OAuth2 API';
|
||||||
|
properties = [
|
||||||
|
{
|
||||||
|
displayName: 'Authorization URL',
|
||||||
|
name: 'authUrl',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: 'https://api.typeform.com/oauth/authorize',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Access Token URL',
|
||||||
|
name: 'accessTokenUrl',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: 'https://api.typeform.com/oauth/token',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Scope',
|
||||||
|
name: 'scope',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: scopes.join(','),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Auth URI Query Parameters',
|
||||||
|
name: 'authQueryParameters',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Authentication',
|
||||||
|
name: 'authentication',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: 'header',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 3.2 KiB |
|
@ -19,16 +19,11 @@ import {
|
||||||
|
|
||||||
export async function pagerDutyApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
export async function pagerDutyApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
const credentials = this.getCredentials('pagerDutyApi');
|
const authenticationMethod = this.getNodeParameter('authentication', 0);
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new Error('No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.pagerduty+json;version=2',
|
Accept: 'application/vnd.pagerduty+json;version=2'
|
||||||
Authorization: `Token token=${credentials.apiToken}`,
|
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
|
@ -39,15 +34,30 @@ export async function pagerDutyApiRequest(this: IExecuteFunctions | IWebhookFunc
|
||||||
arrayFormat: 'brackets',
|
arrayFormat: 'brackets',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!Object.keys(body).length) {
|
if (!Object.keys(body).length) {
|
||||||
delete options.form;
|
delete options.form;
|
||||||
}
|
}
|
||||||
if (!Object.keys(query).length) {
|
if (!Object.keys(query).length) {
|
||||||
delete options.qs;
|
delete options.qs;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.headers = Object.assign({}, options.headers, headers);
|
options.headers = Object.assign({}, options.headers, headers);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (authenticationMethod === 'apiToken') {
|
||||||
|
const credentials = this.getCredentials('pagerDutyApi');
|
||||||
|
|
||||||
|
if (credentials === undefined) {
|
||||||
|
throw new Error('No credentials got returned!');
|
||||||
|
}
|
||||||
|
|
||||||
|
options.headers!['Authorization'] = `Token token=${credentials.apiToken}`;
|
||||||
|
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
|
} else {
|
||||||
|
return await this.helpers.requestOAuth2!.call(this, 'pagerDutyOAuth2Api', options);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.body && error.response.body.error && error.response.body.error.errors) {
|
if (error.response && error.response.body && error.response.body.error && error.response.body.error.errors) {
|
||||||
// Try to return the error prettier
|
// Try to return the error prettier
|
||||||
|
|
|
@ -66,9 +66,43 @@ export class PagerDuty implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'pagerDutyApi',
|
name: 'pagerDutyApi',
|
||||||
required: true,
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
'apiToken',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pagerDutyOAuth2Api',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
'oAuth2',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
|
{
|
||||||
|
displayName: 'Authentication',
|
||||||
|
name: 'authentication',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'API Token',
|
||||||
|
value: 'apiToken',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'OAuth2',
|
||||||
|
value: 'oAuth2',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'apiToken',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Resource',
|
displayName: 'Resource',
|
||||||
name: 'resource',
|
name: 'resource',
|
||||||
|
|
|
@ -45,18 +45,10 @@ export interface ITypeformAnswerField {
|
||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise<any> { // tslint:disable-line:no-any
|
export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = this.getCredentials('typeformApi');
|
const authenticationMethod = this.getNodeParameter('authentication', 0);
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new Error('No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
query = query || {};
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {},
|
||||||
'Authorization': `bearer ${credentials.accessToken}`,
|
|
||||||
},
|
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
qs: query,
|
qs: query,
|
||||||
|
@ -64,8 +56,23 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
query = query || {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (authenticationMethod === 'accessToken') {
|
||||||
|
|
||||||
|
const credentials = this.getCredentials('typeformApi');
|
||||||
|
|
||||||
|
if (credentials === undefined) {
|
||||||
|
throw new Error('No credentials got returned!');
|
||||||
|
}
|
||||||
|
|
||||||
|
options.headers!['Authorization'] = `bearer ${credentials.accessToken}`;
|
||||||
|
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
|
} else {
|
||||||
|
return await this.helpers.requestOAuth2!.call(this, 'typeformOAuth2Api', options);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.statusCode === 401) {
|
if (error.statusCode === 401) {
|
||||||
// Return a clear error
|
// Return a clear error
|
||||||
|
|
|
@ -37,7 +37,25 @@ export class TypeformTrigger implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'typeformApi',
|
name: 'typeformApi',
|
||||||
required: true,
|
required: true,
|
||||||
}
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
'accessToken',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'typeformOAuth2Api',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
'oAuth2',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
webhooks: [
|
webhooks: [
|
||||||
{
|
{
|
||||||
|
@ -48,6 +66,23 @@ export class TypeformTrigger implements INodeType {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
|
{
|
||||||
|
displayName: 'Authentication',
|
||||||
|
name: 'authentication',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Access Token',
|
||||||
|
value: 'accessToken',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'OAuth2',
|
||||||
|
value: 'oAuth2',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'accessToken',
|
||||||
|
description: 'The resource to operate on.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Form',
|
displayName: 'Form',
|
||||||
name: 'formId',
|
name: 'formId',
|
||||||
|
|
|
@ -103,6 +103,7 @@
|
||||||
"dist/credentials/OAuth2Api.credentials.js",
|
"dist/credentials/OAuth2Api.credentials.js",
|
||||||
"dist/credentials/OpenWeatherMapApi.credentials.js",
|
"dist/credentials/OpenWeatherMapApi.credentials.js",
|
||||||
"dist/credentials/PagerDutyApi.credentials.js",
|
"dist/credentials/PagerDutyApi.credentials.js",
|
||||||
|
"dist/credentials/PagerDutyOAuth2Api.credentials.js",
|
||||||
"dist/credentials/PayPalApi.credentials.js",
|
"dist/credentials/PayPalApi.credentials.js",
|
||||||
"dist/credentials/PipedriveApi.credentials.js",
|
"dist/credentials/PipedriveApi.credentials.js",
|
||||||
"dist/credentials/Postgres.credentials.js",
|
"dist/credentials/Postgres.credentials.js",
|
||||||
|
@ -126,6 +127,7 @@
|
||||||
"dist/credentials/TwilioApi.credentials.js",
|
"dist/credentials/TwilioApi.credentials.js",
|
||||||
"dist/credentials/TwitterOAuth1Api.credentials.js",
|
"dist/credentials/TwitterOAuth1Api.credentials.js",
|
||||||
"dist/credentials/TypeformApi.credentials.js",
|
"dist/credentials/TypeformApi.credentials.js",
|
||||||
|
"dist/credentials/TypeformOAuth2Api.credentials.js",
|
||||||
"dist/credentials/TogglApi.credentials.js",
|
"dist/credentials/TogglApi.credentials.js",
|
||||||
"dist/credentials/UpleadApi.credentials.js",
|
"dist/credentials/UpleadApi.credentials.js",
|
||||||
"dist/credentials/VeroApi.credentials.js",
|
"dist/credentials/VeroApi.credentials.js",
|
||||||
|
|
Loading…
Reference in a new issue