2020-10-03 05:08:50 -07:00
|
|
|
import {
|
2022-07-20 04:45:25 -07:00
|
|
|
ICredentialDataDecryptedObject,
|
2020-10-03 05:08:50 -07:00
|
|
|
ICredentialType,
|
2022-07-20 04:45:25 -07:00
|
|
|
IHttpRequestOptions,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2020-10-03 05:08:50 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class MindeeReceiptApi implements ICredentialType {
|
|
|
|
name = 'mindeeReceiptApi';
|
|
|
|
displayName = 'Mindee Receipt API';
|
2020-10-06 01:23:58 -07:00
|
|
|
documentationUrl = 'mindee';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2020-10-03 05:08:50 -07:00
|
|
|
{
|
|
|
|
displayName: 'API Key',
|
|
|
|
name: 'apiKey',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-10-03 05:08:50 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
];
|
2022-07-20 04:45:25 -07:00
|
|
|
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
|
|
|
// @ts-ignore
|
|
|
|
const url = requestOptions.url ? requestOptions.url : requestOptions.uri;
|
|
|
|
if(url.includes('https://api.mindee.net/v1/')) {
|
|
|
|
requestOptions.headers!['Authorization'] = `Token ${credentials.apiKey}`;
|
|
|
|
} else {
|
|
|
|
requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`;
|
|
|
|
}
|
|
|
|
return requestOptions;
|
|
|
|
}
|
2020-10-03 05:08:50 -07:00
|
|
|
}
|