2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
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';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-09-15 01:07:02 -07:00
|
|
|
displayName = 'Magento 2 API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-09-21 10:42:40 -07:00
|
|
|
documentationUrl = 'magento2';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
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-12-02 12:54:28 -08:00
|
|
|
|
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
|
|
|
}
|