n8n-nodes-adapay 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -0
- package/dist/credentials/AdaPayApi.credentials.d.ts +9 -0
- package/dist/credentials/AdaPayApi.credentials.js +54 -0
- package/dist/nodes/AdaPay/AdaPay.node.d.ts +5 -0
- package/dist/nodes/AdaPay/AdaPay.node.js +452 -0
- package/dist/nodes/AdaPay/AdaPayBankIntegration.node.d.ts +5 -0
- package/dist/nodes/AdaPay/AdaPayBankIntegration.node.js +451 -0
- package/dist/nodes/AdaPay/AdaPayCharge.node.d.ts +5 -0
- package/dist/nodes/AdaPay/AdaPayCharge.node.js +416 -0
- package/dist/nodes/AdaPay/AdaPayCustomer.node.d.ts +5 -0
- package/dist/nodes/AdaPay/AdaPayCustomer.node.js +481 -0
- package/dist/nodes/AdaPay/AdaPayTrigger.node.d.ts +12 -0
- package/dist/nodes/AdaPay/AdaPayTrigger.node.js +193 -0
- package/dist/nodes/AdaPay/adapay.svg +10 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# n8n-nodes-adapay
|
|
2
|
+
|
|
3
|
+
This is an n8n community node that provides integration with the AdaPay payment automation API.
|
|
4
|
+
|
|
5
|
+
[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
|
|
6
|
+
|
|
7
|
+
[AdaPay](https://adapay.com) is a payment automation platform that allows you to automate charge creation, customer management, bank integration, and more.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
|
|
12
|
+
|
|
13
|
+
## Operations
|
|
14
|
+
|
|
15
|
+
### AdaPay Trigger (Webhook)
|
|
16
|
+
|
|
17
|
+
Receive real-time events from AdaPay:
|
|
18
|
+
- Charge events (created, paid, cancelled, refunded, expired)
|
|
19
|
+
- Customer events (created, updated, deleted)
|
|
20
|
+
- Bank integration events (connected, disconnected, error)
|
|
21
|
+
|
|
22
|
+
### Automations
|
|
23
|
+
|
|
24
|
+
- **Create** - Create a new automation
|
|
25
|
+
- **Get** - Get an automation by ID
|
|
26
|
+
- **Get All** - Get all automations with pagination
|
|
27
|
+
- **Update** - Update an automation
|
|
28
|
+
- **Toggle Status** - Enable or disable an automation
|
|
29
|
+
- **Delete** - Delete an automation
|
|
30
|
+
|
|
31
|
+
### Charges
|
|
32
|
+
|
|
33
|
+
- **Create** - Create a new charge for a customer
|
|
34
|
+
- **Get** - Get charge details by ID
|
|
35
|
+
- **Get Many** - List charges with filters (customer, status, pagination)
|
|
36
|
+
- **Update** - Update charge information
|
|
37
|
+
- **Cancel** - Cancel a pending charge
|
|
38
|
+
- **Refund** - Refund a paid charge (full or partial)
|
|
39
|
+
|
|
40
|
+
### Customers
|
|
41
|
+
|
|
42
|
+
- **Create** - Create a new customer with contact and address information
|
|
43
|
+
- **Get** - Get customer details by ID
|
|
44
|
+
- **Get Many** - List customers with filters (email, document, pagination)
|
|
45
|
+
- **Update** - Update customer information
|
|
46
|
+
- **Delete** - Delete a customer
|
|
47
|
+
|
|
48
|
+
### Bank Integrations
|
|
49
|
+
|
|
50
|
+
- **Connect** - Connect a new bank account
|
|
51
|
+
- **Get** - Get bank integration details by ID
|
|
52
|
+
- **Get Many** - List bank integrations with filters (bank name, status)
|
|
53
|
+
- **Update** - Update bank integration settings
|
|
54
|
+
- **Disconnect** - Disconnect a bank integration
|
|
55
|
+
- **Sync** - Synchronize transactions from bank
|
|
56
|
+
- **Get Balance** - Get current account balance
|
|
57
|
+
|
|
58
|
+
## Credentials
|
|
59
|
+
|
|
60
|
+
To use this node, you need an AdaPay Access Key. You can generate one in your AdaPay dashboard under Automations.
|
|
61
|
+
|
|
62
|
+
## Usage Examples
|
|
63
|
+
|
|
64
|
+
### Example 1: Automated Payment Workflow
|
|
65
|
+
|
|
66
|
+
1. **AdaPay Trigger** - Listen for `charge.created` events
|
|
67
|
+
2. **AdaPay Customer** - Get customer details
|
|
68
|
+
3. **Email** - Send payment confirmation to customer
|
|
69
|
+
|
|
70
|
+
### Example 2: Customer Onboarding
|
|
71
|
+
|
|
72
|
+
1. **Webhook** - Receive new user registration
|
|
73
|
+
2. **AdaPay Customer** - Create new customer in AdaPay
|
|
74
|
+
3. **AdaPay Charge** - Create initial charge
|
|
75
|
+
4. **AdaPay Trigger** - Wait for payment confirmation
|
|
76
|
+
|
|
77
|
+
### Example 3: Bank Reconciliation
|
|
78
|
+
|
|
79
|
+
1. **Schedule Trigger** - Run daily at midnight
|
|
80
|
+
2. **AdaPay Bank Integration** - Sync transactions
|
|
81
|
+
3. **AdaPay Charge** - Get all charges
|
|
82
|
+
4. **Function** - Match transactions with charges
|
|
83
|
+
5. **Spreadsheet** - Update reconciliation report
|
|
84
|
+
|
|
85
|
+
### Example 4: Refund Management
|
|
86
|
+
|
|
87
|
+
1. **AdaPay Trigger** - Listen for refund requests
|
|
88
|
+
2. **AdaPay Charge** - Get charge details
|
|
89
|
+
3. **IF** - Check if refund is eligible
|
|
90
|
+
4. **AdaPay Charge** - Process refund
|
|
91
|
+
5. **Email** - Send refund confirmation
|
|
92
|
+
|
|
93
|
+
## Compatibility
|
|
94
|
+
|
|
95
|
+
Tested with n8n version 1.0.0+
|
|
96
|
+
|
|
97
|
+
## Resources
|
|
98
|
+
|
|
99
|
+
- [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
|
|
100
|
+
- [AdaPay API Documentation](https://api.adapay.com/docs)
|
|
101
|
+
- [Example Workflows](./examples/) - Check the examples folder for sample workflows
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
### Build the Project
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm run build
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Run in Development Mode
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm run dev
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Format Code
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npm run format
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Lint Code
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm run lint
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
MIT
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class AdaPayApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdaPayApi = void 0;
|
|
4
|
+
class AdaPayApi {
|
|
5
|
+
name = 'adaPayApi';
|
|
6
|
+
displayName = 'AdaPay API';
|
|
7
|
+
documentationUrl = 'https://api.adapay.com/docs';
|
|
8
|
+
properties = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'Access Key',
|
|
11
|
+
name: 'accessKey',
|
|
12
|
+
type: 'string',
|
|
13
|
+
typeOptions: {
|
|
14
|
+
password: true,
|
|
15
|
+
},
|
|
16
|
+
default: '',
|
|
17
|
+
required: true,
|
|
18
|
+
description: 'The AdaPay Access Key for authentication. Generate it in your AdaPay dashboard under Automations.',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
displayName: 'Environment',
|
|
22
|
+
name: 'environment',
|
|
23
|
+
type: 'options',
|
|
24
|
+
options: [
|
|
25
|
+
{
|
|
26
|
+
name: 'Production',
|
|
27
|
+
value: 'production',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Development',
|
|
31
|
+
value: 'development',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
default: 'production',
|
|
35
|
+
description: 'The environment to connect to',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
authenticate = {
|
|
39
|
+
type: 'generic',
|
|
40
|
+
properties: {
|
|
41
|
+
headers: {
|
|
42
|
+
'X-Access-Key': '={{$credentials.accessKey}}',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
test = {
|
|
47
|
+
request: {
|
|
48
|
+
baseURL: '={{$credentials.environment === "production" ? "https://api.adapay.com" : "http://localhost:3002"}}',
|
|
49
|
+
url: '/api/plugin/automations',
|
|
50
|
+
method: 'GET',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.AdaPayApi = AdaPayApi;
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdaPay = void 0;
|
|
4
|
+
class AdaPay {
|
|
5
|
+
description = {
|
|
6
|
+
displayName: 'AdaPay',
|
|
7
|
+
name: 'adaPay',
|
|
8
|
+
icon: 'file:adapay.svg',
|
|
9
|
+
group: ['transform'],
|
|
10
|
+
version: 1,
|
|
11
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
12
|
+
description: 'Interact with AdaPay API',
|
|
13
|
+
defaults: {
|
|
14
|
+
name: 'AdaPay',
|
|
15
|
+
},
|
|
16
|
+
inputs: ['main'],
|
|
17
|
+
outputs: ['main'],
|
|
18
|
+
credentials: [
|
|
19
|
+
{
|
|
20
|
+
name: 'adaPayApi',
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
requestDefaults: {
|
|
25
|
+
baseURL: '={{$credentials.environment === "production" ? "https://api.adapay.com" : "http://localhost:3002"}}',
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: 'application/json',
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
properties: [
|
|
32
|
+
// Resource selection
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Resource',
|
|
35
|
+
name: 'resource',
|
|
36
|
+
type: 'options',
|
|
37
|
+
noDataExpression: true,
|
|
38
|
+
options: [
|
|
39
|
+
{
|
|
40
|
+
name: 'Automation',
|
|
41
|
+
value: 'automation',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
default: 'automation',
|
|
45
|
+
},
|
|
46
|
+
// Automation operations
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Operation',
|
|
49
|
+
name: 'operation',
|
|
50
|
+
type: 'options',
|
|
51
|
+
noDataExpression: true,
|
|
52
|
+
displayOptions: {
|
|
53
|
+
show: {
|
|
54
|
+
resource: ['automation'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
options: [
|
|
58
|
+
{
|
|
59
|
+
name: 'Create',
|
|
60
|
+
value: 'create',
|
|
61
|
+
description: 'Create a new automation',
|
|
62
|
+
action: 'Create an automation',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'Delete',
|
|
66
|
+
value: 'delete',
|
|
67
|
+
description: 'Delete an automation',
|
|
68
|
+
action: 'Delete an automation',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'Get',
|
|
72
|
+
value: 'get',
|
|
73
|
+
description: 'Get an automation by ID',
|
|
74
|
+
action: 'Get an automation',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Get Many',
|
|
78
|
+
value: 'getAll',
|
|
79
|
+
description: 'Get all automations',
|
|
80
|
+
action: 'Get many automations',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'Toggle Status',
|
|
84
|
+
value: 'toggleStatus',
|
|
85
|
+
description: 'Enable or disable an automation',
|
|
86
|
+
action: 'Toggle automation status',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'Update',
|
|
90
|
+
value: 'update',
|
|
91
|
+
description: 'Update an automation',
|
|
92
|
+
action: 'Update an automation',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
default: 'create',
|
|
96
|
+
},
|
|
97
|
+
// Automation: Create
|
|
98
|
+
{
|
|
99
|
+
displayName: 'Name',
|
|
100
|
+
name: 'name',
|
|
101
|
+
type: 'string',
|
|
102
|
+
required: true,
|
|
103
|
+
displayOptions: {
|
|
104
|
+
show: {
|
|
105
|
+
resource: ['automation'],
|
|
106
|
+
operation: ['create'],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
default: '',
|
|
110
|
+
description: 'Name of the automation',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
displayName: 'Description',
|
|
114
|
+
name: 'description',
|
|
115
|
+
type: 'string',
|
|
116
|
+
displayOptions: {
|
|
117
|
+
show: {
|
|
118
|
+
resource: ['automation'],
|
|
119
|
+
operation: ['create'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
default: '',
|
|
123
|
+
description: 'Description of the automation',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
displayName: 'Events',
|
|
127
|
+
name: 'events',
|
|
128
|
+
type: 'multiOptions',
|
|
129
|
+
required: true,
|
|
130
|
+
displayOptions: {
|
|
131
|
+
show: {
|
|
132
|
+
resource: ['automation'],
|
|
133
|
+
operation: ['create'],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
options: [
|
|
137
|
+
{ name: 'Charge Created', value: 'charge.created' },
|
|
138
|
+
{ name: 'Charge Paid', value: 'charge.paid' },
|
|
139
|
+
{ name: 'Charge Cancelled', value: 'charge.cancelled' },
|
|
140
|
+
{ name: 'Customer Created', value: 'customer.created' },
|
|
141
|
+
{ name: 'Customer Updated', value: 'customer.updated' },
|
|
142
|
+
{ name: 'Customer Deleted', value: 'customer.deleted' },
|
|
143
|
+
{ name: 'Bank Integration Connected', value: 'bank_integration.connected' },
|
|
144
|
+
],
|
|
145
|
+
default: [],
|
|
146
|
+
description: 'Events that trigger this automation',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
displayName: 'Actions',
|
|
150
|
+
name: 'actions',
|
|
151
|
+
type: 'multiOptions',
|
|
152
|
+
required: true,
|
|
153
|
+
displayOptions: {
|
|
154
|
+
show: {
|
|
155
|
+
resource: ['automation'],
|
|
156
|
+
operation: ['create'],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
options: [
|
|
160
|
+
{ name: 'Send Email', value: 'email.send' },
|
|
161
|
+
{ name: 'Send SMS', value: 'sms.send' },
|
|
162
|
+
{ name: 'Send Webhook', value: 'webhook.send' },
|
|
163
|
+
{ name: 'Create Charge', value: 'charge.create' },
|
|
164
|
+
{ name: 'Update Customer', value: 'customer.update' },
|
|
165
|
+
{ name: 'Create Tag', value: 'tag.create' },
|
|
166
|
+
{ name: 'Update Charge', value: 'charge.update' },
|
|
167
|
+
{ name: 'Create Customer Note', value: 'customer.note.create' },
|
|
168
|
+
{ name: 'Update Bank Integration', value: 'bank_integration.update' },
|
|
169
|
+
{ name: 'Send Push Notification', value: 'push.send' },
|
|
170
|
+
],
|
|
171
|
+
default: [],
|
|
172
|
+
description: 'Actions to execute when triggered',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
displayName: 'Webhook URL',
|
|
176
|
+
name: 'webhookUrl',
|
|
177
|
+
type: 'string',
|
|
178
|
+
displayOptions: {
|
|
179
|
+
show: {
|
|
180
|
+
resource: ['automation'],
|
|
181
|
+
operation: ['create'],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
default: '',
|
|
185
|
+
description: 'Optional webhook URL to call when this automation is triggered',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
displayName: 'Is Active',
|
|
189
|
+
name: 'isActive',
|
|
190
|
+
type: 'boolean',
|
|
191
|
+
displayOptions: {
|
|
192
|
+
show: {
|
|
193
|
+
resource: ['automation'],
|
|
194
|
+
operation: ['create'],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
default: true,
|
|
198
|
+
description: 'Whether the automation should be active upon creation',
|
|
199
|
+
},
|
|
200
|
+
// Automation: Get
|
|
201
|
+
{
|
|
202
|
+
displayName: 'Automation ID',
|
|
203
|
+
name: 'automationId',
|
|
204
|
+
type: 'string',
|
|
205
|
+
required: true,
|
|
206
|
+
displayOptions: {
|
|
207
|
+
show: {
|
|
208
|
+
resource: ['automation'],
|
|
209
|
+
operation: ['get', 'delete', 'update', 'toggleStatus'],
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
default: '',
|
|
213
|
+
description: 'ID of the automation',
|
|
214
|
+
},
|
|
215
|
+
// Automation: Update
|
|
216
|
+
{
|
|
217
|
+
displayName: 'Update Fields',
|
|
218
|
+
name: 'updateFields',
|
|
219
|
+
type: 'collection',
|
|
220
|
+
placeholder: 'Add Field',
|
|
221
|
+
default: {},
|
|
222
|
+
displayOptions: {
|
|
223
|
+
show: {
|
|
224
|
+
resource: ['automation'],
|
|
225
|
+
operation: ['update'],
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
options: [
|
|
229
|
+
{
|
|
230
|
+
displayName: 'Name',
|
|
231
|
+
name: 'name',
|
|
232
|
+
type: 'string',
|
|
233
|
+
default: '',
|
|
234
|
+
description: 'Name of the automation',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
displayName: 'Description',
|
|
238
|
+
name: 'description',
|
|
239
|
+
type: 'string',
|
|
240
|
+
default: '',
|
|
241
|
+
description: 'Description of the automation',
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
displayName: 'Events',
|
|
245
|
+
name: 'events',
|
|
246
|
+
type: 'multiOptions',
|
|
247
|
+
options: [
|
|
248
|
+
{ name: 'Charge Created', value: 'charge.created' },
|
|
249
|
+
{ name: 'Charge Paid', value: 'charge.paid' },
|
|
250
|
+
{ name: 'Charge Cancelled', value: 'charge.cancelled' },
|
|
251
|
+
{ name: 'Customer Created', value: 'customer.created' },
|
|
252
|
+
{ name: 'Customer Updated', value: 'customer.updated' },
|
|
253
|
+
{ name: 'Customer Deleted', value: 'customer.deleted' },
|
|
254
|
+
{ name: 'Bank Integration Connected', value: 'bank_integration.connected' },
|
|
255
|
+
],
|
|
256
|
+
default: [],
|
|
257
|
+
description: 'Events that trigger this automation',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
displayName: 'Actions',
|
|
261
|
+
name: 'actions',
|
|
262
|
+
type: 'multiOptions',
|
|
263
|
+
options: [
|
|
264
|
+
{ name: 'Send Email', value: 'email.send' },
|
|
265
|
+
{ name: 'Send SMS', value: 'sms.send' },
|
|
266
|
+
{ name: 'Send Webhook', value: 'webhook.send' },
|
|
267
|
+
{ name: 'Create Charge', value: 'charge.create' },
|
|
268
|
+
{ name: 'Update Customer', value: 'customer.update' },
|
|
269
|
+
{ name: 'Create Tag', value: 'tag.create' },
|
|
270
|
+
{ name: 'Update Charge', value: 'charge.update' },
|
|
271
|
+
{ name: 'Create Customer Note', value: 'customer.note.create' },
|
|
272
|
+
{ name: 'Update Bank Integration', value: 'bank_integration.update' },
|
|
273
|
+
{ name: 'Send Push Notification', value: 'push.send' },
|
|
274
|
+
],
|
|
275
|
+
default: [],
|
|
276
|
+
description: 'Actions to execute when triggered',
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
displayName: 'Webhook URL',
|
|
280
|
+
name: 'webhookUrl',
|
|
281
|
+
type: 'string',
|
|
282
|
+
default: '',
|
|
283
|
+
description: 'Webhook URL to call when this automation is triggered',
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
},
|
|
287
|
+
// Automation: Get Many
|
|
288
|
+
{
|
|
289
|
+
displayName: 'Return All',
|
|
290
|
+
name: 'returnAll',
|
|
291
|
+
type: 'boolean',
|
|
292
|
+
displayOptions: {
|
|
293
|
+
show: {
|
|
294
|
+
resource: ['automation'],
|
|
295
|
+
operation: ['getAll'],
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
default: false,
|
|
299
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
displayName: 'Limit',
|
|
303
|
+
name: 'limit',
|
|
304
|
+
type: 'number',
|
|
305
|
+
displayOptions: {
|
|
306
|
+
show: {
|
|
307
|
+
resource: ['automation'],
|
|
308
|
+
operation: ['getAll'],
|
|
309
|
+
returnAll: [false],
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
typeOptions: {
|
|
313
|
+
minValue: 1,
|
|
314
|
+
maxValue: 100,
|
|
315
|
+
},
|
|
316
|
+
default: 50,
|
|
317
|
+
description: 'Max number of results to return',
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
displayName: 'Additional Fields',
|
|
321
|
+
name: 'additionalFields',
|
|
322
|
+
type: 'collection',
|
|
323
|
+
placeholder: 'Add Field',
|
|
324
|
+
default: {},
|
|
325
|
+
displayOptions: {
|
|
326
|
+
show: {
|
|
327
|
+
resource: ['automation'],
|
|
328
|
+
operation: ['getAll'],
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
options: [
|
|
332
|
+
{
|
|
333
|
+
displayName: 'Page',
|
|
334
|
+
name: 'page',
|
|
335
|
+
type: 'number',
|
|
336
|
+
default: 1,
|
|
337
|
+
description: 'Page number to retrieve',
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
};
|
|
343
|
+
async execute() {
|
|
344
|
+
const items = this.getInputData();
|
|
345
|
+
const returnData = [];
|
|
346
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
347
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
348
|
+
for (let i = 0; i < items.length; i++) {
|
|
349
|
+
try {
|
|
350
|
+
if (resource === 'automation') {
|
|
351
|
+
if (operation === 'create') {
|
|
352
|
+
// Create automation
|
|
353
|
+
const name = this.getNodeParameter('name', i);
|
|
354
|
+
const description = this.getNodeParameter('description', i);
|
|
355
|
+
const events = this.getNodeParameter('events', i);
|
|
356
|
+
const actions = this.getNodeParameter('actions', i);
|
|
357
|
+
const webhookUrl = this.getNodeParameter('webhookUrl', i, '');
|
|
358
|
+
const isActive = this.getNodeParameter('isActive', i);
|
|
359
|
+
const body = {
|
|
360
|
+
name,
|
|
361
|
+
description,
|
|
362
|
+
events,
|
|
363
|
+
actions,
|
|
364
|
+
isActive,
|
|
365
|
+
};
|
|
366
|
+
if (webhookUrl) {
|
|
367
|
+
body.webhookUrl = webhookUrl;
|
|
368
|
+
}
|
|
369
|
+
const options = {
|
|
370
|
+
method: 'POST',
|
|
371
|
+
url: '/api/plugin/automations',
|
|
372
|
+
body,
|
|
373
|
+
};
|
|
374
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'adaPayApi', options);
|
|
375
|
+
returnData.push({ json: responseData });
|
|
376
|
+
}
|
|
377
|
+
else if (operation === 'get') {
|
|
378
|
+
// Get automation
|
|
379
|
+
const automationId = this.getNodeParameter('automationId', i);
|
|
380
|
+
const options = {
|
|
381
|
+
method: 'GET',
|
|
382
|
+
url: `/api/plugin/automations/${automationId}`,
|
|
383
|
+
};
|
|
384
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'adaPayApi', options);
|
|
385
|
+
returnData.push({ json: responseData });
|
|
386
|
+
}
|
|
387
|
+
else if (operation === 'getAll') {
|
|
388
|
+
// Get all automations
|
|
389
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
390
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
391
|
+
const qs = {
|
|
392
|
+
page: additionalFields.page || 1,
|
|
393
|
+
};
|
|
394
|
+
if (!returnAll) {
|
|
395
|
+
qs.limit = this.getNodeParameter('limit', i);
|
|
396
|
+
}
|
|
397
|
+
const options = {
|
|
398
|
+
method: 'GET',
|
|
399
|
+
url: '/api/plugin/automations',
|
|
400
|
+
qs,
|
|
401
|
+
};
|
|
402
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'adaPayApi', options);
|
|
403
|
+
const automations = responseData.data;
|
|
404
|
+
returnData.push(...automations.map((automation) => ({ json: automation })));
|
|
405
|
+
}
|
|
406
|
+
else if (operation === 'update') {
|
|
407
|
+
// Update automation
|
|
408
|
+
const automationId = this.getNodeParameter('automationId', i);
|
|
409
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
410
|
+
const options = {
|
|
411
|
+
method: 'PATCH',
|
|
412
|
+
url: `/api/plugin/automations/${automationId}`,
|
|
413
|
+
body: updateFields,
|
|
414
|
+
};
|
|
415
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'adaPayApi', options);
|
|
416
|
+
returnData.push({ json: responseData });
|
|
417
|
+
}
|
|
418
|
+
else if (operation === 'toggleStatus') {
|
|
419
|
+
// Toggle automation status
|
|
420
|
+
const automationId = this.getNodeParameter('automationId', i);
|
|
421
|
+
const options = {
|
|
422
|
+
method: 'PATCH',
|
|
423
|
+
url: `/api/plugin/automations/${automationId}/toggle-status`,
|
|
424
|
+
};
|
|
425
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'adaPayApi', options);
|
|
426
|
+
returnData.push({ json: responseData });
|
|
427
|
+
}
|
|
428
|
+
else if (operation === 'delete') {
|
|
429
|
+
// Delete automation
|
|
430
|
+
const automationId = this.getNodeParameter('automationId', i);
|
|
431
|
+
const options = {
|
|
432
|
+
method: 'DELETE',
|
|
433
|
+
url: `/api/plugin/automations/${automationId}`,
|
|
434
|
+
};
|
|
435
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'adaPayApi', options);
|
|
436
|
+
returnData.push({ json: responseData });
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
catch (error) {
|
|
441
|
+
if (this.continueOnFail()) {
|
|
442
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
443
|
+
returnData.push({ json: { error: errorMessage }, pairedItem: { item: i } });
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
throw error;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return [returnData];
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
exports.AdaPay = AdaPay;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class AdaPayBankIntegration implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|