@arathron/n8n-nodes-zoho-books 1.0.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.
Files changed (40) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +199 -0
  3. package/dist/credentials/ZohoBooksOAuth2.credentials.d.ts +8 -0
  4. package/dist/credentials/ZohoBooksOAuth2.credentials.js +75 -0
  5. package/dist/credentials/ZohoBooksOAuth2.credentials.js.map +1 -0
  6. package/dist/nodes/ZohoBooks.node.d.ts +5 -0
  7. package/dist/nodes/ZohoBooks.node.js +260 -0
  8. package/dist/nodes/ZohoBooks.node.js.map +1 -0
  9. package/dist/nodes/resources/BaseResource.d.ts +16 -0
  10. package/dist/nodes/resources/BaseResource.js +44 -0
  11. package/dist/nodes/resources/BaseResource.js.map +1 -0
  12. package/dist/nodes/resources/CreditNote.resource.d.ts +14 -0
  13. package/dist/nodes/resources/CreditNote.resource.js +291 -0
  14. package/dist/nodes/resources/CreditNote.resource.js.map +1 -0
  15. package/dist/nodes/resources/Invoice.resource.d.ts +14 -0
  16. package/dist/nodes/resources/Invoice.resource.js +251 -0
  17. package/dist/nodes/resources/Invoice.resource.js.map +1 -0
  18. package/dist/nodes/resources/Item.resource.d.ts +14 -0
  19. package/dist/nodes/resources/Item.resource.js +312 -0
  20. package/dist/nodes/resources/Item.resource.js.map +1 -0
  21. package/dist/nodes/resources/Payment.resource.d.ts +14 -0
  22. package/dist/nodes/resources/Payment.resource.js +341 -0
  23. package/dist/nodes/resources/Payment.resource.js.map +1 -0
  24. package/dist/nodes/resources/SalesOrder.resource.d.ts +14 -0
  25. package/dist/nodes/resources/SalesOrder.resource.js +211 -0
  26. package/dist/nodes/resources/SalesOrder.resource.js.map +1 -0
  27. package/dist/nodes/resources/Vendor.resource.d.ts +14 -0
  28. package/dist/nodes/resources/Vendor.resource.js +415 -0
  29. package/dist/nodes/resources/Vendor.resource.js.map +1 -0
  30. package/dist/utils/GenericFunctions.d.ts +6 -0
  31. package/dist/utils/GenericFunctions.js +154 -0
  32. package/dist/utils/GenericFunctions.js.map +1 -0
  33. package/dist/utils/RateLimiter.d.ts +20 -0
  34. package/dist/utils/RateLimiter.js +82 -0
  35. package/dist/utils/RateLimiter.js.map +1 -0
  36. package/dist/utils/Schemas.d.ts +7 -0
  37. package/dist/utils/Schemas.js +207 -0
  38. package/dist/utils/Schemas.js.map +1 -0
  39. package/index.js +4 -0
  40. package/package.json +69 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 n8n Community
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,199 @@
1
+ # n8n-nodes-zoho-books
2
+
3
+ This is an n8n community node that lets you use Zoho Books in your n8n workflows.
4
+
5
+ Zoho Books is a cloud-based accounting software that helps you manage your finances, automate business workflows, and work collaboratively across departments.
6
+
7
+ [n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
8
+
9
+ [Installation](#installation)
10
+ [Operations](#operations)
11
+ [Credentials](#credentials)
12
+ [Compatibility](#compatibility)
13
+ [Usage](#usage)
14
+ [Resources](#resources)
15
+
16
+ ## Installation
17
+
18
+ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
19
+
20
+ ## Operations
21
+
22
+ This node supports the following operations for each resource:
23
+
24
+ ### Sales Orders
25
+
26
+ - **Create**: Create a new sales order
27
+ - **Get**: Get a sales order by ID
28
+ - **Get All**: Get all sales orders with filters
29
+ - **Update**: Update an existing sales order
30
+ - **Void**: Void a sales order
31
+
32
+ ### Invoices
33
+
34
+ - **Create**: Create a new invoice
35
+ - **Get**: Get an invoice by ID
36
+ - **Get All**: Get all invoices with filters
37
+ - **Update**: Update an existing invoice
38
+ - **Void**: Void an invoice
39
+
40
+ ### Items
41
+
42
+ - **Create**: Create a new item
43
+ - **Get**: Get an item by ID
44
+ - **Get All**: Get all items with filters
45
+ - **Update**: Update an existing item
46
+ - **Delete**: Delete an item
47
+
48
+ ### Vendors
49
+
50
+ - **Create**: Create a new vendor
51
+ - **Get**: Get a vendor by ID
52
+ - **Get All**: Get all vendors with filters
53
+ - **Update**: Update an existing vendor
54
+ - **Delete**: Delete a vendor
55
+
56
+ ### Credit Notes
57
+
58
+ - **Create**: Create a new credit note
59
+ - **Get**: Get a credit note by ID
60
+ - **Get All**: Get all credit notes with filters
61
+ - **Update**: Update an existing credit note
62
+ - **Void**: Void a credit note
63
+
64
+ ### Payments
65
+
66
+ - **Create**: Create a new payment
67
+ - **Get**: Get a payment by ID
68
+ - **Get All**: Get all payments with filters
69
+ - **Update**: Update an existing payment
70
+ - **Delete**: Delete a payment
71
+
72
+ ## Credentials
73
+
74
+ To use this node, you need to create OAuth2 credentials for Zoho Books:
75
+
76
+ 1. Go to [Zoho API Console](https://api-console.zoho.com/)
77
+ 2. Create a new client:
78
+ - Choose "Server-based Applications"
79
+ - Add authorized redirect URL from n8n (shown when creating credentials)
80
+ - Note down your Client ID and Client Secret
81
+ 3. In n8n:
82
+ - Create new Zoho Books OAuth2 credentials
83
+ - Select your data center (US, EU, IN, AU, or CN)
84
+ - Enter your Client ID and Client Secret
85
+ - Enter your Organization ID (found in Zoho Books Settings)
86
+ - Click "Connect My Account" and authorize the app
87
+
88
+ ### Required Scopes
89
+
90
+ The node requires the following scope:
91
+
92
+ - `ZohoBooks.fullaccess.all`
93
+
94
+ ## Compatibility
95
+
96
+ - n8n version 1.0.0 or higher
97
+ - Tested with Zoho Books API v3
98
+
99
+ ## Usage
100
+
101
+ ### Example: Create an Invoice
102
+
103
+ 1. Add a Zoho Books node to your workflow
104
+ 2. Select "Invoice" as the resource
105
+ 3. Select "Create" as the operation
106
+ 4. Fill in required fields:
107
+ - Customer ID
108
+ - Line Items (with item ID, quantity, and rate)
109
+ 5. Add optional fields as needed:
110
+ - Due date
111
+ - Discount
112
+ - Notes
113
+ - Custom fields
114
+
115
+ ### Example: Get All Sales Orders with Filters
116
+
117
+ 1. Add a Zoho Books node
118
+ 2. Select "Sales Order" as the resource
119
+ 3. Select "Get All" as the operation
120
+ 4. Configure filters:
121
+ - Status: "confirmed"
122
+ - Date range
123
+ - Sort by date descending
124
+ 5. Choose to return all results or limit to specific number
125
+
126
+ ### Example: Apply Payment to Invoices
127
+
128
+ 1. Add a Zoho Books node
129
+ 2. Select "Payment" as the resource
130
+ 3. Select "Create" as the operation
131
+ 4. Fill in:
132
+ - Customer ID
133
+ - Payment mode (e.g., "Bank Transfer")
134
+ - Amount
135
+ - Date
136
+ 5. In Additional Fields, add invoices to apply the payment to:
137
+ - Invoice ID
138
+ - Amount to apply
139
+
140
+ ## Resources
141
+
142
+ - [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
143
+ - [Zoho Books API documentation](https://www.zoho.com/books/api/v3/)
144
+ - [OAuth2 setup guide for Zoho](https://www.zoho.com/accounts/protocol/oauth-setup.html)
145
+
146
+ ## Development
147
+
148
+ ### Setup
149
+
150
+ ```bash
151
+ # Install dependencies
152
+ npm install
153
+
154
+ # Build the node
155
+ npm run build
156
+
157
+ # Run tests
158
+ npm test
159
+
160
+ # Run in development mode
161
+ npm run dev
162
+ ```
163
+
164
+ ### Testing
165
+
166
+ The node includes comprehensive unit tests and integration tests. To run tests:
167
+
168
+ ```bash
169
+ # Run all tests
170
+ npm test
171
+
172
+ # Run with coverage
173
+ npm run test:coverage
174
+
175
+ # Run only unit tests
176
+ npm run test -- test/unit
177
+
178
+ # Run only integration tests
179
+ npm run test:integration
180
+ ```
181
+
182
+ ### Contributing
183
+
184
+ 1. Fork the repository
185
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
186
+ 3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
187
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
188
+ 5. Open a Pull Request
189
+
190
+ Please ensure:
191
+
192
+ - All tests pass
193
+ - Code coverage remains above 90%
194
+ - Linting passes (`npm run lint`)
195
+ - Commits follow [Conventional Commits](https://www.conventionalcommits.org/)
196
+
197
+ ## License
198
+
199
+ [MIT](LICENSE.md)
@@ -0,0 +1,8 @@
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class ZohoBooksOAuth2 implements ICredentialType {
3
+ name: string;
4
+ extends: string[];
5
+ displayName: string;
6
+ documentationUrl: string;
7
+ properties: INodeProperties[];
8
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZohoBooksOAuth2 = void 0;
4
+ class ZohoBooksOAuth2 {
5
+ constructor() {
6
+ this.name = 'zohoBooksOAuth2';
7
+ this.extends = ['oAuth2Api'];
8
+ this.displayName = 'Zoho Books OAuth2 API';
9
+ this.documentationUrl = 'zohobooks';
10
+ this.properties = [
11
+ {
12
+ displayName: 'Data Centre',
13
+ name: 'dataCentre',
14
+ type: 'options',
15
+ options: [
16
+ { name: 'United States', value: 'US' },
17
+ { name: 'Europe', value: 'EU' },
18
+ { name: 'India', value: 'IN' },
19
+ { name: 'Australia', value: 'AU' },
20
+ { name: 'China', value: 'CN' },
21
+ ],
22
+ default: 'US',
23
+ required: true,
24
+ description: 'The data centre where your Zoho Books account is hosted',
25
+ },
26
+ {
27
+ displayName: 'Organization ID',
28
+ name: 'organizationId',
29
+ type: 'string',
30
+ default: '',
31
+ description: 'Your Zoho Books Organization ID',
32
+ required: true,
33
+ hint: 'Found in Zoho Books > Settings > Organization > Organization ID',
34
+ },
35
+ {
36
+ displayName: 'Grant Type',
37
+ name: 'grantType',
38
+ type: 'hidden',
39
+ default: 'authorizationCode',
40
+ },
41
+ {
42
+ displayName: 'Authorization URL',
43
+ name: 'authUrl',
44
+ type: 'hidden',
45
+ default: '={{$self["dataCentre"] === "CN" ? "https://accounts.zoho.com.cn" : "https://accounts.zoho." + ($self["dataCentre"] === "US" ? "com" : $self["dataCentre"].toLowerCase())}}/oauth/v2/auth',
46
+ },
47
+ {
48
+ displayName: 'Access Token URL',
49
+ name: 'accessTokenUrl',
50
+ type: 'hidden',
51
+ default: '={{$self["dataCentre"] === "CN" ? "https://accounts.zoho.com.cn" : "https://accounts.zoho." + ($self["dataCentre"] === "US" ? "com" : $self["dataCentre"].toLowerCase())}}/oauth/v2/token',
52
+ },
53
+ {
54
+ displayName: 'Scope',
55
+ name: 'scope',
56
+ type: 'hidden',
57
+ default: 'ZohoBooks.fullaccess.all',
58
+ },
59
+ {
60
+ displayName: 'Auth URI Query Parameters',
61
+ name: 'authQueryParameters',
62
+ type: 'hidden',
63
+ default: 'access_type=offline&prompt=consent',
64
+ },
65
+ {
66
+ displayName: 'Authentication',
67
+ name: 'authentication',
68
+ type: 'hidden',
69
+ default: 'header',
70
+ },
71
+ ];
72
+ }
73
+ }
74
+ exports.ZohoBooksOAuth2 = ZohoBooksOAuth2;
75
+ //# sourceMappingURL=ZohoBooksOAuth2.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZohoBooksOAuth2.credentials.js","sourceRoot":"","sources":["../../credentials/ZohoBooksOAuth2.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;IAA5B;QACE,SAAI,GAAG,iBAAiB,CAAC;QACzB,YAAO,GAAG,CAAC,WAAW,CAAC,CAAC;QACxB,gBAAW,GAAG,uBAAuB,CAAC;QACtC,qBAAgB,GAAG,WAAW,CAAC;QAC/B,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE;oBACtC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;oBAC/B,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;oBAC9B,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE;oBAClC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;iBAC/B;gBACD,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,yDAAyD;aACvE;YACD;gBACE,WAAW,EAAE,iBAAiB;gBAC9B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,iCAAiC;gBAC9C,QAAQ,EAAE,IAAI;gBACd,IAAI,EAAE,iEAAiE;aACxE;YACD;gBACE,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;aAC7B;YACD;gBACE,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EACL,0LAA0L;aAC7L;YACD;gBACE,WAAW,EAAE,kBAAkB;gBAC/B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,OAAO,EACL,2LAA2L;aAC9L;YACD;gBACE,WAAW,EAAE,OAAO;gBACpB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,0BAA0B;aACpC;YACD;gBACE,WAAW,EAAE,2BAA2B;gBACxC,IAAI,EAAE,qBAAqB;gBAC3B,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,oCAAoC;aAC9C;YACD;gBACE,WAAW,EAAE,gBAAgB;gBAC7B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,QAAQ;aAClB;SACF,CAAC;IACJ,CAAC;CAAA;AArED,0CAqEC"}
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class ZohoBooks implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZohoBooks = void 0;
4
+ const GenericFunctions_1 = require("../utils/GenericFunctions");
5
+ const Schemas_1 = require("../utils/Schemas");
6
+ const SalesOrder_resource_1 = require("./resources/SalesOrder.resource");
7
+ const Invoice_resource_1 = require("./resources/Invoice.resource");
8
+ const Item_resource_1 = require("./resources/Item.resource");
9
+ const Vendor_resource_1 = require("./resources/Vendor.resource");
10
+ const CreditNote_resource_1 = require("./resources/CreditNote.resource");
11
+ const Payment_resource_1 = require("./resources/Payment.resource");
12
+ class ZohoBooks {
13
+ constructor() {
14
+ this.description = {
15
+ displayName: 'Zoho Books',
16
+ name: 'zohoBooks',
17
+ icon: 'file:zohobooks.svg',
18
+ group: ['transform'],
19
+ version: 1,
20
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
21
+ description: 'Interact with Zoho Books API',
22
+ defaults: {
23
+ name: 'Zoho Books',
24
+ },
25
+ inputs: ["main" /* NodeConnectionType.Main */],
26
+ outputs: ["main" /* NodeConnectionType.Main */],
27
+ credentials: [
28
+ {
29
+ name: 'zohoBooksOAuth2',
30
+ required: true,
31
+ },
32
+ ],
33
+ properties: [
34
+ {
35
+ displayName: 'Resource',
36
+ name: 'resource',
37
+ type: 'options',
38
+ noDataExpression: true,
39
+ options: [
40
+ {
41
+ name: 'Sales Order',
42
+ value: 'salesOrder',
43
+ },
44
+ {
45
+ name: 'Invoice',
46
+ value: 'invoice',
47
+ },
48
+ {
49
+ name: 'Item',
50
+ value: 'item',
51
+ },
52
+ {
53
+ name: 'Vendor',
54
+ value: 'vendor',
55
+ },
56
+ {
57
+ name: 'Credit Note',
58
+ value: 'creditNote',
59
+ },
60
+ {
61
+ name: 'Payment',
62
+ value: 'payment',
63
+ },
64
+ ],
65
+ default: 'salesOrder',
66
+ },
67
+ // Load resource-specific operations and fields dynamically
68
+ ...new SalesOrder_resource_1.SalesOrderResource().getOperations(),
69
+ ...new Invoice_resource_1.InvoiceResource().getOperations(),
70
+ ...new Item_resource_1.ItemResource().getOperations(),
71
+ ...new Vendor_resource_1.VendorResource().getOperations(),
72
+ ...new CreditNote_resource_1.CreditNoteResource().getOperations(),
73
+ ...new Payment_resource_1.PaymentResource().getOperations(),
74
+ ...new SalesOrder_resource_1.SalesOrderResource().getFields(),
75
+ ...new Invoice_resource_1.InvoiceResource().getFields(),
76
+ ...new Item_resource_1.ItemResource().getFields(),
77
+ ...new Vendor_resource_1.VendorResource().getFields(),
78
+ ...new CreditNote_resource_1.CreditNoteResource().getFields(),
79
+ ...new Payment_resource_1.PaymentResource().getFields(),
80
+ ],
81
+ };
82
+ }
83
+ async execute() {
84
+ const items = this.getInputData();
85
+ const returnData = [];
86
+ const length = items.length;
87
+ const qs = {};
88
+ let responseData;
89
+ const resource = this.getNodeParameter('resource', 0);
90
+ const operation = this.getNodeParameter('operation', 0);
91
+ for (let i = 0; i < length; i++) {
92
+ try {
93
+ const endpoint = (0, GenericFunctions_1.getResourceEndpoint)(resource);
94
+ if (operation === 'create') {
95
+ const body = {};
96
+ // Handle common create fields
97
+ if (resource === 'salesOrder' || resource === 'invoice' || resource === 'creditNote') {
98
+ body.customer_id = this.getNodeParameter('customer_id', i);
99
+ const lineItems = this.getNodeParameter('line_items', i);
100
+ body.line_items = lineItems.item || [];
101
+ }
102
+ else if (resource === 'item') {
103
+ body.name = this.getNodeParameter('name', i);
104
+ }
105
+ else if (resource === 'vendor') {
106
+ body.contact_name = this.getNodeParameter('contact_name', i);
107
+ body.contact_type = 'vendor';
108
+ }
109
+ else if (resource === 'payment') {
110
+ body.customer_id = this.getNodeParameter('customer_id', i);
111
+ body.payment_mode = this.getNodeParameter('payment_mode', i);
112
+ body.amount = this.getNodeParameter('amount', i);
113
+ body.date = (0, Schemas_1.formatDateForZoho)(this.getNodeParameter('date', i));
114
+ }
115
+ // Handle additional fields
116
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
117
+ Object.assign(body, additionalFields);
118
+ // Format date fields
119
+ if (body.date)
120
+ body.date = (0, Schemas_1.formatDateForZoho)(body.date);
121
+ if (body.due_date)
122
+ body.due_date = (0, Schemas_1.formatDateForZoho)(body.due_date);
123
+ if (body.shipment_date)
124
+ body.shipment_date = (0, Schemas_1.formatDateForZoho)(body.shipment_date);
125
+ // Handle custom fields
126
+ if (additionalFields.custom_fields) {
127
+ body.custom_fields = additionalFields.custom_fields.customField || [];
128
+ delete additionalFields.custom_fields;
129
+ }
130
+ // Handle invoice application for payments
131
+ if (resource === 'payment' && additionalFields.invoices) {
132
+ body.invoices = additionalFields.invoices.invoice || [];
133
+ delete additionalFields.invoices;
134
+ }
135
+ responseData = await GenericFunctions_1.makeApiRequest.call(this, 'POST', endpoint, body);
136
+ responseData = responseData[resource] || responseData;
137
+ }
138
+ else if (operation === 'get') {
139
+ const id = this.getNodeParameter(`${resource}Id`, i);
140
+ responseData = await GenericFunctions_1.makeApiRequest.call(this, 'GET', `${endpoint}/${id}`);
141
+ responseData = responseData[resource] || responseData;
142
+ }
143
+ else if (operation === 'getAll') {
144
+ const returnAll = this.getNodeParameter('returnAll', i);
145
+ const filters = this.getNodeParameter('filters', i, {});
146
+ // Apply filters
147
+ Object.assign(qs, filters);
148
+ // Format date filters
149
+ if (qs.date_from)
150
+ qs.date_from = (0, Schemas_1.formatDateForZoho)(qs.date_from);
151
+ if (qs.date_to)
152
+ qs.date_to = (0, Schemas_1.formatDateForZoho)(qs.date_to);
153
+ // Add vendor filter
154
+ if (resource === 'vendor') {
155
+ qs.contact_type = 'vendor';
156
+ }
157
+ if (returnAll) {
158
+ responseData = await GenericFunctions_1.makeApiRequestWithPagination.call(this, 'GET', endpoint, {}, qs);
159
+ }
160
+ else {
161
+ const limit = this.getNodeParameter('limit', i);
162
+ qs.per_page = limit;
163
+ const response = await GenericFunctions_1.makeApiRequest.call(this, 'GET', endpoint, {}, qs);
164
+ const dataKey = Object.keys(response).find((key) => key !== 'code' &&
165
+ key !== 'message' &&
166
+ key !== 'page_context' &&
167
+ Array.isArray(response[key]));
168
+ responseData = dataKey ? response[dataKey] : [];
169
+ }
170
+ }
171
+ else if (operation === 'update') {
172
+ const id = this.getNodeParameter(`${resource}Id`, i);
173
+ const body = {};
174
+ // Handle update fields based on resource
175
+ if (resource === 'salesOrder' || resource === 'invoice' || resource === 'creditNote') {
176
+ const lineItems = this.getNodeParameter('line_items', i, null);
177
+ if (lineItems) {
178
+ body.line_items = lineItems.item || [];
179
+ }
180
+ }
181
+ else if (resource === 'item') {
182
+ const name = this.getNodeParameter('name', i, '');
183
+ if (name)
184
+ body.name = name;
185
+ }
186
+ else if (resource === 'vendor') {
187
+ const contactName = this.getNodeParameter('contact_name', i, '');
188
+ if (contactName)
189
+ body.contact_name = contactName;
190
+ body.contact_type = 'vendor';
191
+ }
192
+ else if (resource === 'payment') {
193
+ const amount = this.getNodeParameter('amount', i, null);
194
+ if (amount !== null)
195
+ body.amount = amount;
196
+ const date = this.getNodeParameter('date', i, '');
197
+ if (date)
198
+ body.date = (0, Schemas_1.formatDateForZoho)(date);
199
+ const paymentMode = this.getNodeParameter('payment_mode', i, '');
200
+ if (paymentMode)
201
+ body.payment_mode = paymentMode;
202
+ }
203
+ // Handle additional fields
204
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
205
+ Object.assign(body, additionalFields);
206
+ // Format date fields
207
+ if (body.date)
208
+ body.date = (0, Schemas_1.formatDateForZoho)(body.date);
209
+ if (body.due_date)
210
+ body.due_date = (0, Schemas_1.formatDateForZoho)(body.due_date);
211
+ if (body.shipment_date)
212
+ body.shipment_date = (0, Schemas_1.formatDateForZoho)(body.shipment_date);
213
+ // Handle custom fields
214
+ if (additionalFields.custom_fields) {
215
+ body.custom_fields = additionalFields.custom_fields.customField || [];
216
+ delete additionalFields.custom_fields;
217
+ }
218
+ // Handle invoice application for payments
219
+ if (resource === 'payment' && additionalFields.invoices) {
220
+ body.invoices = additionalFields.invoices.invoice || [];
221
+ delete additionalFields.invoices;
222
+ }
223
+ responseData = await GenericFunctions_1.makeApiRequest.call(this, 'PUT', `${endpoint}/${id}`, body);
224
+ responseData = responseData[resource] || responseData;
225
+ }
226
+ else if (operation === 'delete') {
227
+ const id = this.getNodeParameter(`${resource}Id`, i);
228
+ responseData = await GenericFunctions_1.makeApiRequest.call(this, 'DELETE', `${endpoint}/${id}`);
229
+ }
230
+ else if (operation === 'void') {
231
+ const id = this.getNodeParameter(`${resource}Id`, i);
232
+ responseData = await GenericFunctions_1.makeApiRequest.call(this, 'POST', `${endpoint}/${id}/status/void`, {});
233
+ responseData = responseData[resource] || responseData;
234
+ }
235
+ if (Array.isArray(responseData)) {
236
+ returnData.push(...responseData.map((item) => ({ json: item })));
237
+ }
238
+ else {
239
+ returnData.push({ json: responseData });
240
+ }
241
+ }
242
+ catch (error) {
243
+ if (this.continueOnFail()) {
244
+ returnData.push({
245
+ json: {
246
+ error: error.message,
247
+ details: error.description,
248
+ },
249
+ error,
250
+ });
251
+ continue;
252
+ }
253
+ throw error;
254
+ }
255
+ }
256
+ return [returnData];
257
+ }
258
+ }
259
+ exports.ZohoBooks = ZohoBooks;
260
+ //# sourceMappingURL=ZohoBooks.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZohoBooks.node.js","sourceRoot":"","sources":["../../nodes/ZohoBooks.node.ts"],"names":[],"mappings":";;;AAQA,gEAImC;AACnC,8CAAqD;AACrD,yEAAqE;AACrE,mEAA+D;AAC/D,6DAAyD;AACzD,iEAA6D;AAC7D,yEAAqE;AACrE,mEAA+D;AAE/D,MAAa,SAAS;IAAtB;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,YAAY;YACzB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,8BAA8B;YAC3C,QAAQ,EAAE;gBACR,IAAI,EAAE,YAAY;aACnB;YACD,MAAM,EAAE,sCAAyB;YACjC,OAAO,EAAE,sCAAyB;YAClC,WAAW,EAAE;gBACX;oBACE,IAAI,EAAE,iBAAiB;oBACvB,QAAQ,EAAE,IAAI;iBACf;aACF;YACD,UAAU,EAAE;gBACV;oBACE,WAAW,EAAE,UAAU;oBACvB,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,aAAa;4BACnB,KAAK,EAAE,YAAY;yBACpB;wBACD;4BACE,IAAI,EAAE,SAAS;4BACf,KAAK,EAAE,SAAS;yBACjB;wBACD;4BACE,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,MAAM;yBACd;wBACD;4BACE,IAAI,EAAE,QAAQ;4BACd,KAAK,EAAE,QAAQ;yBAChB;wBACD;4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,CAAC,gBAAgB,CAAC,GAAG,QAAQ,IAAI,EAAE,CAAC,CAAW,CAAC;oBAC/D,YAAY,GAAG,MAAM,iCAAc,CAAC,IAAI,CACtC,IAAI,EACJ,MAAM,EACN,GAAG,QAAQ,IAAI,EAAE,cAAc,EAC/B,EAAE,CACH,CAAC;oBACF,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAC;gBACxD,CAAC;gBAED,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;oBAChC,UAAU,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACnE,CAAC;qBAAM,CAAC;oBACN,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC1B,UAAU,CAAC,IAAI,CAAC;wBACd,IAAI,EAAE;4BACJ,KAAK,EAAE,KAAK,CAAC,OAAO;4BACpB,OAAO,EAAE,KAAK,CAAC,WAAW;yBAC3B;wBACD,KAAK;qBACN,CAAC,CAAC;oBACH,SAAS;gBACX,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;CACF;AAtPD,8BAsPC"}
@@ -0,0 +1,16 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare abstract class BaseResource {
3
+ abstract name: string;
4
+ abstract displayName: string;
5
+ abstract endpoint: string;
6
+ getOperations(): INodeProperties[];
7
+ abstract getOperationOptions(): Array<{
8
+ name: string;
9
+ value: string;
10
+ description: string;
11
+ action: string;
12
+ }>;
13
+ abstract getFields(): INodeProperties[];
14
+ getDefaultOperation(): string;
15
+ getIdField(operation: string, required?: boolean): INodeProperties;
16
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseResource = void 0;
4
+ class BaseResource {
5
+ getOperations() {
6
+ return [
7
+ {
8
+ displayName: 'Operation',
9
+ name: 'operation',
10
+ type: 'options',
11
+ noDataExpression: true,
12
+ displayOptions: {
13
+ show: {
14
+ resource: [this.name],
15
+ },
16
+ },
17
+ options: this.getOperationOptions(),
18
+ default: this.getDefaultOperation(),
19
+ },
20
+ ];
21
+ }
22
+ getDefaultOperation() {
23
+ const options = this.getOperationOptions();
24
+ return options.length > 0 ? options[0].value : 'get';
25
+ }
26
+ getIdField(operation, required = true) {
27
+ return {
28
+ displayName: `${this.displayName} ID`,
29
+ name: `${this.name}Id`,
30
+ type: 'string',
31
+ required,
32
+ displayOptions: {
33
+ show: {
34
+ resource: [this.name],
35
+ operation: [operation],
36
+ },
37
+ },
38
+ default: '',
39
+ description: `The ID of the ${this.displayName.toLowerCase()}`,
40
+ };
41
+ }
42
+ }
43
+ exports.BaseResource = BaseResource;
44
+ //# sourceMappingURL=BaseResource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseResource.js","sourceRoot":"","sources":["../../../nodes/resources/BaseResource.ts"],"names":[],"mappings":";;;AAEA,MAAsB,YAAY;IAKhC,aAAa;QACX,OAAO;YACL;gBACE,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,SAAS;gBACf,gBAAgB,EAAE,IAAI;gBACtB,cAAc,EAAE;oBACd,IAAI,EAAE;wBACJ,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;qBACtB;iBACF;gBACD,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE;gBACnC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE;aACpC;SACF,CAAC;IACJ,CAAC;IAWD,mBAAmB;QACjB,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,CAAC;IAED,UAAU,CAAC,SAAiB,EAAE,QAAQ,GAAG,IAAI;QAC3C,OAAO;YACL,WAAW,EAAE,GAAG,IAAI,CAAC,WAAW,KAAK;YACrC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI;YACtB,IAAI,EAAE,QAAQ;YACd,QAAQ;YACR,cAAc,EAAE;gBACd,IAAI,EAAE;oBACJ,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;oBACrB,SAAS,EAAE,CAAC,SAAS,CAAC;iBACvB;aACF;YACD,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,iBAAiB,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE;SAC/D,CAAC;IACJ,CAAC;CACF;AArDD,oCAqDC"}