2021-09-15 01:07:02 -07:00
|
|
|
import {
|
2022-06-26 15:55:51 -07:00
|
|
|
IAuthenticateGeneric,
|
2022-04-08 03:01:21 -07:00
|
|
|
ICredentialTestRequest,
|
2021-09-15 01:07:02 -07:00
|
|
|
ICredentialType,
|
2021-10-07 14:07:56 -07:00
|
|
|
INodeProperties,
|
2021-09-15 01:07:02 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class Magento2Api implements ICredentialType {
|
|
|
|
name = 'magento2Api';
|
|
|
|
displayName = 'Magento 2 API';
|
2021-09-21 10:42:40 -07:00
|
|
|
documentationUrl = 'magento2';
|
2021-10-07 14:07:56 -07:00
|
|
|
properties: INodeProperties[] = [
|
2021-09-15 01:07:02 -07:00
|
|
|
{
|
|
|
|
displayName: 'Host',
|
|
|
|
name: 'host',
|
2021-10-07 14:07:56 -07:00
|
|
|
type: 'string',
|
2021-09-15 01:07:02 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Access Token',
|
|
|
|
name: 'accessToken',
|
2021-10-07 14:07:56 -07:00
|
|
|
type: 'string',
|
2022-11-01 09:41:45 -07:00
|
|
|
typeOptions: { password: true },
|
2021-09-15 01:07:02 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
];
|
2022-04-08 03:01:21 -07:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: '={{$credentials.host}}',
|
|
|
|
url: '/rest/default/V1/modules',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-06-26 15:55:51 -07:00
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
|
|
|
properties: {
|
|
|
|
headers: {
|
|
|
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2021-09-15 01:07:02 -07:00
|
|
|
}
|