2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2022-08-24 01:26:48 -07:00
|
|
|
ICredentialDataDecryptedObject,
|
|
|
|
ICredentialTestRequest,
|
|
|
|
ICredentialType,
|
|
|
|
IHttpRequestOptions,
|
|
|
|
INodeProperties,
|
|
|
|
} from 'n8n-workflow';
|
2020-12-19 09:22:41 -08:00
|
|
|
|
|
|
|
export class UProcApi implements ICredentialType {
|
|
|
|
name = 'uprocApi';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2020-12-19 09:22:41 -08:00
|
|
|
displayName = 'uProc API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-06-18 14:46:21 -07:00
|
|
|
documentationUrl = 'uProc';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2020-12-19 09:22:41 -08:00
|
|
|
{
|
|
|
|
displayName: 'Email',
|
|
|
|
name: 'email',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2022-06-20 07:54:01 -07:00
|
|
|
placeholder: 'name@email.com',
|
2020-12-19 09:22:41 -08:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'API Key',
|
|
|
|
name: 'apiKey',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2022-11-01 09:41:45 -07:00
|
|
|
typeOptions: { password: true },
|
2020-12-19 09:22:41 -08:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
];
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-08-24 01:26:48 -07:00
|
|
|
async authenticate(
|
|
|
|
credentials: ICredentialDataDecryptedObject,
|
|
|
|
requestOptions: IHttpRequestOptions,
|
|
|
|
): Promise<IHttpRequestOptions> {
|
|
|
|
const token = Buffer.from(`${credentials.email}:${credentials.apiKey}`).toString('base64');
|
|
|
|
requestOptions.headers = {
|
|
|
|
...requestOptions.headers,
|
|
|
|
Authorization: `Basic ${token}`,
|
|
|
|
};
|
|
|
|
return requestOptions;
|
|
|
|
}
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-08-24 01:26:48 -07:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: 'https://api.uproc.io/api/v2',
|
|
|
|
url: '/profile',
|
|
|
|
method: 'GET',
|
|
|
|
},
|
|
|
|
};
|
2020-12-19 09:22:41 -08:00
|
|
|
}
|