n8n-nodes-didar-crm 0.0.2 → 0.0.4
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/LICENSE +18 -2
- package/README.md +43 -24
- package/dist/lib/http.d.ts +7 -0
- package/dist/lib/http.js +39 -0
- package/dist/lib/loadOptions.d.ts +4 -0
- package/dist/lib/loadOptions.js +76 -0
- package/dist/nodes/DidarCrm.node.d.ts +8 -1
- package/dist/nodes/DidarCrm.node.js +306 -72
- package/dist/nodes/deal/create.operation.d.ts +2 -0
- package/dist/nodes/deal/create.operation.js +89 -0
- package/dist/nodes/deal/get.operation.d.ts +2 -0
- package/dist/nodes/deal/get.operation.js +16 -0
- package/dist/nodes/deal/index.d.ts +3 -0
- package/dist/nodes/deal/index.js +9 -0
- package/dist/nodes/deal/update.operation.d.ts +2 -0
- package/dist/nodes/deal/update.operation.js +28 -0
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
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
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
# n8n-nodes-didar-crm
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
Community node for [n8n](https://n8n.io) to integrate with [Didar CRM](https://app.didar.me).
|
|
4
|
+
|
|
5
|
+
This node allows you to:
|
|
6
|
+
- **Trigger workflows** from Didar CRM webhooks
|
|
7
|
+
- **Create Deals** with all required fields (Title, Owner, Pipeline, Stage, Person, Company, Status)
|
|
8
|
+
- Use **Additional Fields** like description, source, lost reason, price, currency, custom fields, etc.
|
|
9
|
+
- Select Owner, Pipeline, and Stage from dropdowns (or manually enter IDs).
|
|
10
|
+
|
|
11
|
+
More operations (update deal, get deal, person/company operations) will be added soon.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## ⚙️ Installation
|
|
16
|
+
|
|
17
|
+
In your n8n instance, go to:
|
|
18
|
+
|
|
19
|
+
`Settings > Community Nodes > Install`
|
|
20
|
+
|
|
21
|
+
and enter: n8n-nodes-didar-crm
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 🔑 Authentication
|
|
27
|
+
|
|
28
|
+
Currently the node uses an **API Key** (query param `?apikey=...`) for authentication.
|
|
29
|
+
You need to generate and provide your API key from your Didar CRM account.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🧪 Development
|
|
34
|
+
|
|
35
|
+
Clone repo and build:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install
|
|
39
|
+
npm run build
|
|
40
|
+
|
|
41
|
+
For local testing in n8n:
|
|
42
|
+
|
|
43
|
+
# inside n8n custom folder
|
|
44
|
+
cd ~/.n8n/custom
|
|
45
|
+
npm install /path/to/n8n-nodes-didar-crm
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
|
2
|
+
export declare function didarRequest(that: IExecuteFunctions, i: number, opts: {
|
|
3
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
4
|
+
path: string;
|
|
5
|
+
body?: IDataObject;
|
|
6
|
+
qs?: IDataObject;
|
|
7
|
+
}): Promise<IDataObject>;
|
package/dist/lib/http.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.didarRequest = didarRequest;
|
|
4
|
+
async function didarRequest(that, i, opts) {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6
|
+
const creds = await that.getCredentials('didarApi');
|
|
7
|
+
const baseUrl = creds.baseUrl;
|
|
8
|
+
const apiKey = creds.apiKey;
|
|
9
|
+
const useCookie = creds.useCookie;
|
|
10
|
+
const cookie = creds.cookie;
|
|
11
|
+
const urlBase = (baseUrl || '').replace(/\/+$/, '');
|
|
12
|
+
let url = `${urlBase}/${opts.path.replace(/^\/+/, '')}?apikey=${encodeURIComponent(apiKey)}`;
|
|
13
|
+
if (opts.qs && Object.keys(opts.qs).length) {
|
|
14
|
+
const usp = new URLSearchParams(opts.qs);
|
|
15
|
+
url += `&${usp.toString()}`;
|
|
16
|
+
}
|
|
17
|
+
const options = {
|
|
18
|
+
method: opts.method,
|
|
19
|
+
url,
|
|
20
|
+
json: true,
|
|
21
|
+
headers: { 'Content-Type': 'application/json' },
|
|
22
|
+
};
|
|
23
|
+
if (opts.body && ['POST', 'PUT', 'PATCH'].includes(opts.method)) {
|
|
24
|
+
options.body = opts.body;
|
|
25
|
+
}
|
|
26
|
+
if (useCookie && cookie)
|
|
27
|
+
options.headers.Cookie = cookie;
|
|
28
|
+
try {
|
|
29
|
+
return (await that.helpers.httpRequest(options));
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
// تلاش برای استخراج پیام سرور
|
|
33
|
+
const status = (_b = (_a = err === null || err === void 0 ? void 0 : err.statusCode) !== null && _a !== void 0 ? _a : err === null || err === void 0 ? void 0 : err.code) !== null && _b !== void 0 ? _b : 'ERR';
|
|
34
|
+
const msg = (_c = err === null || err === void 0 ? void 0 : err.message) !== null && _c !== void 0 ? _c : 'Request failed';
|
|
35
|
+
const data = (_h = (_g = (_e = (_d = err === null || err === void 0 ? void 0 : err.response) === null || _d === void 0 ? void 0 : _d.body) !== null && _e !== void 0 ? _e : (_f = err === null || err === void 0 ? void 0 : err.response) === null || _f === void 0 ? void 0 : _f.data) !== null && _g !== void 0 ? _g : err === null || err === void 0 ? void 0 : err.error) !== null && _h !== void 0 ? _h : '';
|
|
36
|
+
const details = typeof data === 'string' ? data : JSON.stringify(data);
|
|
37
|
+
throw new Error(`[Didar] ${opts.method} ${opts.path} → ${status}: ${msg}\nServer says: ${details}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
2
|
+
export declare function getPipelines(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
3
|
+
export declare function getStagesForPipeline(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
4
|
+
export declare function getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPipelines = getPipelines;
|
|
4
|
+
exports.getStagesForPipeline = getStagesForPipeline;
|
|
5
|
+
exports.getUsers = getUsers;
|
|
6
|
+
async function getPipelines() {
|
|
7
|
+
var _a;
|
|
8
|
+
const creds = await this.getCredentials('didarApi');
|
|
9
|
+
const baseUrl = creds.baseUrl;
|
|
10
|
+
const apiKey = creds.apiKey;
|
|
11
|
+
const useCookie = creds.useCookie;
|
|
12
|
+
const cookie = creds.cookie;
|
|
13
|
+
const urlBase = (baseUrl || '').replace(/\/+$/, '');
|
|
14
|
+
const url = `${urlBase}/api/pipeline/list/0?apikey=${encodeURIComponent(apiKey)}`;
|
|
15
|
+
const options = {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
url,
|
|
18
|
+
json: true,
|
|
19
|
+
headers: { 'Content-Type': 'application/json' },
|
|
20
|
+
};
|
|
21
|
+
if (useCookie && cookie)
|
|
22
|
+
options.headers.Cookie = cookie;
|
|
23
|
+
const resp = await this.helpers.httpRequest(options);
|
|
24
|
+
const arr = ((_a = resp.Response) !== null && _a !== void 0 ? _a : []);
|
|
25
|
+
return arr.map((p) => ({ name: p.Title || p.Id, value: p.Id }));
|
|
26
|
+
}
|
|
27
|
+
async function getStagesForPipeline() {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
const pipelineId = String(this.getNodeParameter('PipelineIdSelect', '') || '');
|
|
30
|
+
if (!pipelineId)
|
|
31
|
+
return [];
|
|
32
|
+
const creds = await this.getCredentials('didarApi');
|
|
33
|
+
const baseUrl = creds.baseUrl;
|
|
34
|
+
const apiKey = creds.apiKey;
|
|
35
|
+
const useCookie = creds.useCookie;
|
|
36
|
+
const cookie = creds.cookie;
|
|
37
|
+
const urlBase = (baseUrl || '').replace(/\/+$/, '');
|
|
38
|
+
const url = `${urlBase}/api/pipeline/list/0?apikey=${encodeURIComponent(apiKey)}`;
|
|
39
|
+
const options = {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
url,
|
|
42
|
+
json: true,
|
|
43
|
+
headers: { 'Content-Type': 'application/json' },
|
|
44
|
+
};
|
|
45
|
+
if (useCookie && cookie)
|
|
46
|
+
options.headers.Cookie = cookie;
|
|
47
|
+
const resp = await this.helpers.httpRequest(options);
|
|
48
|
+
const pipelines = ((_a = resp.Response) !== null && _a !== void 0 ? _a : []);
|
|
49
|
+
const found = pipelines.find((p) => p.Id === pipelineId);
|
|
50
|
+
const stages = ((_b = found === null || found === void 0 ? void 0 : found.Stages) !== null && _b !== void 0 ? _b : []);
|
|
51
|
+
return stages.map((s) => ({ name: s.Title || s.Id, value: s.Id }));
|
|
52
|
+
}
|
|
53
|
+
async function getUsers() {
|
|
54
|
+
var _a;
|
|
55
|
+
const creds = await this.getCredentials('didarApi');
|
|
56
|
+
const baseUrl = creds.baseUrl;
|
|
57
|
+
const apiKey = creds.apiKey;
|
|
58
|
+
const useCookie = creds.useCookie;
|
|
59
|
+
const cookie = creds.cookie;
|
|
60
|
+
const urlBase = (baseUrl || '').replace(/\/+$/, '');
|
|
61
|
+
const url = `${urlBase}/api/User/List?apikey=${encodeURIComponent(apiKey)}`;
|
|
62
|
+
const options = {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
url,
|
|
65
|
+
json: true,
|
|
66
|
+
headers: { 'Content-Type': 'application/json' },
|
|
67
|
+
};
|
|
68
|
+
if (useCookie && cookie)
|
|
69
|
+
options.headers.Cookie = cookie;
|
|
70
|
+
const resp = await this.helpers.httpRequest(options);
|
|
71
|
+
const arr = ((_a = resp.Response) !== null && _a !== void 0 ? _a : []);
|
|
72
|
+
return arr.map((u) => ({
|
|
73
|
+
name: u.DisplayName || u.UserName || u.Id,
|
|
74
|
+
value: u.UserId, // اگر OwnerId باید از UserId بیاد، این را به u.UserId تغییر بده
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
1
|
+
import { IExecuteFunctions, ILoadOptionsFunctions, INodePropertyOptions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
export declare class DidarCrm implements INodeType {
|
|
3
|
+
methods: {
|
|
4
|
+
loadOptions: {
|
|
5
|
+
getPipelines: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
6
|
+
getStagesForPipeline: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
7
|
+
getUsers: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
3
10
|
description: INodeTypeDescription;
|
|
4
11
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
12
|
}
|
|
@@ -1,8 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.DidarCrm = void 0;
|
|
37
|
+
const DealOps = __importStar(require("./deal"));
|
|
38
|
+
const Load = __importStar(require("../lib/loadOptions"));
|
|
4
39
|
class DidarCrm {
|
|
5
40
|
constructor() {
|
|
41
|
+
this.methods = {
|
|
42
|
+
loadOptions: {
|
|
43
|
+
getPipelines: Load.getPipelines,
|
|
44
|
+
getStagesForPipeline: Load.getStagesForPipeline,
|
|
45
|
+
getUsers: Load.getUsers,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
6
48
|
this.description = {
|
|
7
49
|
displayName: 'Didar CRM',
|
|
8
50
|
name: 'didarCrm',
|
|
@@ -15,49 +57,275 @@ class DidarCrm {
|
|
|
15
57
|
outputs: ["main" /* NodeConnectionType.Main */],
|
|
16
58
|
credentials: [{ name: 'didarApi', required: true }],
|
|
17
59
|
properties: [
|
|
60
|
+
// Resource & Operation
|
|
18
61
|
{
|
|
19
62
|
displayName: 'Resource',
|
|
20
63
|
name: 'resource',
|
|
21
64
|
type: 'options',
|
|
22
65
|
options: [{ name: 'Deal', value: 'deal' }],
|
|
23
66
|
default: 'deal',
|
|
67
|
+
description: 'Choose the entity to act on.',
|
|
24
68
|
},
|
|
25
69
|
{
|
|
26
70
|
displayName: 'Operation',
|
|
27
71
|
name: 'operation',
|
|
28
72
|
type: 'options',
|
|
29
73
|
displayOptions: { show: { resource: ['deal'] } },
|
|
30
|
-
options: [
|
|
74
|
+
options: [
|
|
75
|
+
{ name: 'Create', value: 'create', action: 'Create a deal' },
|
|
76
|
+
{ name: 'Update', value: 'update', action: 'Update a deal by Id' },
|
|
77
|
+
{ name: 'Get', value: 'get', action: 'Get a deal by Id' },
|
|
78
|
+
],
|
|
31
79
|
default: 'create',
|
|
80
|
+
description: 'Select the action to perform on the selected resource.',
|
|
81
|
+
},
|
|
82
|
+
// ========================= Deal → Create (MAIN FIELDS) =========================
|
|
83
|
+
// 1) Title
|
|
84
|
+
{
|
|
85
|
+
displayName: 'Title',
|
|
86
|
+
name: 'Title',
|
|
87
|
+
type: 'string',
|
|
88
|
+
default: '',
|
|
89
|
+
displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
|
|
90
|
+
description: 'Deal title (required).',
|
|
91
|
+
},
|
|
92
|
+
// 2) Owner (select/manual)
|
|
93
|
+
{
|
|
94
|
+
displayName: 'Owner Input Mode',
|
|
95
|
+
name: 'OwnerMode',
|
|
96
|
+
type: 'options',
|
|
97
|
+
options: [
|
|
98
|
+
{ name: 'Select from list', value: 'select' },
|
|
99
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
100
|
+
],
|
|
101
|
+
default: 'select',
|
|
102
|
+
displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
|
|
103
|
+
description: 'Choose how to set the owner.',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
displayName: 'Owner',
|
|
107
|
+
name: 'OwnerIdSelect',
|
|
108
|
+
type: 'options',
|
|
109
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
110
|
+
default: '',
|
|
111
|
+
displayOptions: {
|
|
112
|
+
show: { resource: ['deal'], operation: ['create'], OwnerMode: ['select'] },
|
|
113
|
+
},
|
|
114
|
+
description: 'Select the deal owner (required if select mode).',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Owner ID',
|
|
118
|
+
name: 'OwnerIdManual',
|
|
119
|
+
type: 'string',
|
|
120
|
+
default: '',
|
|
121
|
+
displayOptions: {
|
|
122
|
+
show: { resource: ['deal'], operation: ['create'], OwnerMode: ['manual'] },
|
|
123
|
+
},
|
|
124
|
+
description: 'Enter owner ID manually (required if manual mode).',
|
|
125
|
+
},
|
|
126
|
+
// 3) Pipeline (select/manual)
|
|
127
|
+
{
|
|
128
|
+
displayName: 'Pipeline Input Mode',
|
|
129
|
+
name: 'PipelineMode',
|
|
130
|
+
type: 'options',
|
|
131
|
+
options: [
|
|
132
|
+
{ name: 'Select from list', value: 'select' },
|
|
133
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
134
|
+
],
|
|
135
|
+
default: 'select',
|
|
136
|
+
displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
|
|
137
|
+
description: 'Choose how to set the pipeline.',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
displayName: 'Pipeline',
|
|
141
|
+
name: 'PipelineIdSelect',
|
|
142
|
+
type: 'options',
|
|
143
|
+
typeOptions: { loadOptionsMethod: 'getPipelines' },
|
|
144
|
+
default: '',
|
|
145
|
+
displayOptions: {
|
|
146
|
+
show: { resource: ['deal'], operation: ['create'], PipelineMode: ['select'] },
|
|
147
|
+
},
|
|
148
|
+
description: 'Pick a pipeline (required if select mode).',
|
|
32
149
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
{ displayName: 'Person ID', name: 'PersonId', type: 'string', default: '00000000-0000-0000-0000-000000000000', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
38
|
-
{ displayName: 'Company ID', name: 'CompanyId', type: 'string', default: '00000000-0000-0000-0000-000000000000', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
39
|
-
{ displayName: 'Source ID', name: 'SourceId', type: 'string', default: '00000000-0000-0000-0000-000000000000', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
40
|
-
{ displayName: 'Pipeline ID', name: 'PipelineId', type: 'string', required: true, default: '', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
41
|
-
{ displayName: 'Pipeline Stage ID', name: 'PipelineStageId', type: 'string', required: true, default: '', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
42
|
-
{ displayName: 'Lost Reason ID', name: 'LostReasonId', type: 'string', default: '00000000-0000-0000-0000-000000000000', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
43
|
-
{ displayName: 'Creator ID', name: 'CreatorId', type: 'string', default: '00000000-0000-0000-0000-000000000000', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
44
|
-
{ displayName: 'Price', name: 'Price', type: 'string', default: '0', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
45
|
-
{ displayName: 'Currency ID', name: 'CurrencyId', type: 'string', required: true, default: '', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
46
|
-
{ displayName: 'Visibility Type', name: 'VisibilityType', type: 'string', default: '1', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
47
|
-
{ displayName: 'Status', name: 'Status', type: 'string', default: 'Pending', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
48
|
-
{ displayName: 'Source Other', name: 'SourceOther', type: 'string', default: '', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
49
|
-
{ displayName: 'Lost Reason Note', name: 'LostReasonNote', type: 'string', default: '', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
50
|
-
{ displayName: 'Lost Reason Other', name: 'LostReasonOther', type: 'string', default: '', displayOptions: { show: { resource: ['deal'], operation: ['create'] } } },
|
|
51
|
-
{
|
|
52
|
-
displayName: 'Custom Fields (JSON)',
|
|
53
|
-
name: 'Fields',
|
|
54
|
-
type: 'json',
|
|
150
|
+
{
|
|
151
|
+
displayName: 'Pipeline ID',
|
|
152
|
+
name: 'PipelineId',
|
|
153
|
+
type: 'string',
|
|
55
154
|
default: '',
|
|
56
|
-
|
|
57
|
-
|
|
155
|
+
displayOptions: {
|
|
156
|
+
show: { resource: ['deal'], operation: ['create'], PipelineMode: ['manual'] },
|
|
157
|
+
},
|
|
158
|
+
description: 'Enter pipeline ID (required if manual mode).',
|
|
159
|
+
},
|
|
160
|
+
// 4) Stage (select/manual)
|
|
161
|
+
{
|
|
162
|
+
displayName: 'Stage Input Mode',
|
|
163
|
+
name: 'StageMode',
|
|
164
|
+
type: 'options',
|
|
165
|
+
options: [
|
|
166
|
+
{ name: 'Select from list', value: 'select' },
|
|
167
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
168
|
+
],
|
|
169
|
+
default: 'select',
|
|
170
|
+
displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
|
|
171
|
+
description: 'Choose how to set the stage.',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
displayName: 'Pipeline Stage',
|
|
175
|
+
name: 'PipelineStageIdSelect',
|
|
176
|
+
type: 'options',
|
|
177
|
+
typeOptions: {
|
|
178
|
+
loadOptionsMethod: 'getStagesForPipeline',
|
|
179
|
+
loadOptionsDependsOn: ['PipelineIdSelect'],
|
|
180
|
+
},
|
|
181
|
+
default: '',
|
|
182
|
+
displayOptions: {
|
|
183
|
+
show: {
|
|
184
|
+
resource: ['deal'],
|
|
185
|
+
operation: ['create'],
|
|
186
|
+
StageMode: ['select'],
|
|
187
|
+
PipelineMode: ['select'],
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
description: 'Pick a stage (required if select mode).',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
displayName: 'Pipeline Stage ID',
|
|
194
|
+
name: 'PipelineStageId',
|
|
195
|
+
type: 'string',
|
|
196
|
+
default: '',
|
|
197
|
+
displayOptions: {
|
|
198
|
+
show: { resource: ['deal'], operation: ['create'], StageMode: ['manual'] },
|
|
199
|
+
},
|
|
200
|
+
description: 'Enter stage ID (required if manual mode).',
|
|
201
|
+
},
|
|
202
|
+
// 5) Person (default zero-guid)
|
|
203
|
+
{
|
|
204
|
+
displayName: 'Person ID',
|
|
205
|
+
name: 'PersonId',
|
|
206
|
+
type: 'string',
|
|
207
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
208
|
+
displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
|
|
209
|
+
description: 'Person ID related to the deal (required).',
|
|
210
|
+
},
|
|
211
|
+
// 6) Company (default zero-guid)
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Company ID',
|
|
214
|
+
name: 'CompanyId',
|
|
215
|
+
type: 'string',
|
|
216
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
58
217
|
displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
|
|
218
|
+
description: 'Company ID related to the deal (required).',
|
|
59
219
|
},
|
|
60
|
-
|
|
220
|
+
// Status dropdown (required)
|
|
221
|
+
{
|
|
222
|
+
displayName: 'Status',
|
|
223
|
+
name: 'Status',
|
|
224
|
+
type: 'options',
|
|
225
|
+
options: [
|
|
226
|
+
{ name: 'Pending', value: 'Pending' },
|
|
227
|
+
{ name: 'Won', value: 'Won' },
|
|
228
|
+
{ name: 'Lost', value: 'Lost' },
|
|
229
|
+
],
|
|
230
|
+
default: 'Pending',
|
|
231
|
+
displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
|
|
232
|
+
description: 'Deal status (required).',
|
|
233
|
+
},
|
|
234
|
+
// ========================= Additional Fields (OPTIONAL) =========================
|
|
235
|
+
{
|
|
236
|
+
displayName: 'Additional Fields',
|
|
237
|
+
name: 'additionalFields',
|
|
238
|
+
type: 'collection',
|
|
239
|
+
placeholder: 'Add field',
|
|
240
|
+
default: {},
|
|
241
|
+
displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
|
|
242
|
+
options: [
|
|
243
|
+
// طبق خواسته: SourceOther بلافاصله بعد از SourceId
|
|
244
|
+
{
|
|
245
|
+
displayName: 'Source ID',
|
|
246
|
+
name: 'SourceId',
|
|
247
|
+
type: 'string',
|
|
248
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
249
|
+
description: 'Source identifier (optional).',
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
displayName: 'Source Other',
|
|
253
|
+
name: 'SourceOther',
|
|
254
|
+
type: 'string',
|
|
255
|
+
default: '',
|
|
256
|
+
description: 'Custom text for other/unlisted sources.',
|
|
257
|
+
},
|
|
258
|
+
// LostReason سهتایی کنار هم (در UI n8n همه در همین Collection خواهند بود)
|
|
259
|
+
{
|
|
260
|
+
displayName: 'Lost Reason ID',
|
|
261
|
+
name: 'LostReasonId',
|
|
262
|
+
type: 'string',
|
|
263
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
264
|
+
description: 'Lost reason identifier.',
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
displayName: 'Lost Reason Note',
|
|
268
|
+
name: 'LostReasonNote',
|
|
269
|
+
type: 'string',
|
|
270
|
+
default: '',
|
|
271
|
+
description: 'Additional notes for lost reason.',
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
displayName: 'Lost Reason Other',
|
|
275
|
+
name: 'LostReasonOther',
|
|
276
|
+
type: 'string',
|
|
277
|
+
default: '',
|
|
278
|
+
description: 'Custom lost reason text.',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
displayName: 'Description',
|
|
282
|
+
name: 'Description',
|
|
283
|
+
type: 'string',
|
|
284
|
+
default: '',
|
|
285
|
+
description: 'Optional description for the deal.',
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
displayName: 'Creator ID',
|
|
289
|
+
name: 'CreatorId',
|
|
290
|
+
type: 'string',
|
|
291
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
292
|
+
description: 'Creator user ID (defaults to owner if empty).',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
displayName: 'Price',
|
|
296
|
+
name: 'Price',
|
|
297
|
+
type: 'string',
|
|
298
|
+
default: '0',
|
|
299
|
+
description: 'Deal price/amount.',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
displayName: 'Visibility Type',
|
|
303
|
+
name: 'VisibilityType',
|
|
304
|
+
type: 'options',
|
|
305
|
+
options: [
|
|
306
|
+
{ name: 'Owner', value: '0' },
|
|
307
|
+
{ name: 'Owner Group', value: '1' },
|
|
308
|
+
{ name: 'Owner SubGroup', value: '2' },
|
|
309
|
+
{ name: 'All', value: '3' },
|
|
310
|
+
],
|
|
311
|
+
default: 'Owner',
|
|
312
|
+
description: 'Visibility setting: restricts who can see this deal.',
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
displayName: 'Custom Fields (JSON)',
|
|
316
|
+
name: 'Fields',
|
|
317
|
+
type: 'json',
|
|
318
|
+
default: '',
|
|
319
|
+
placeholder: '{ "Field_8783_12_4": 12 }',
|
|
320
|
+
description: 'JSON object of custom fields.',
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
// ========================= Deal → Update / Get (بدون تغییر) =========================
|
|
325
|
+
{ displayName: 'Deal Id', name: 'dealId', type: 'string', default: '', displayOptions: { show: { resource: ['deal'], operation: ['update'] } }, description: 'Target deal Id (required).' },
|
|
326
|
+
{ displayName: 'Update Body (JSON)', name: 'updateBody', type: 'json', default: '', displayOptions: { show: { resource: ['deal'], operation: ['update'] } }, description: 'JSON fields to update; merged into Deal with Id.' },
|
|
327
|
+
{ displayName: 'Deal Id', name: 'dealId', type: 'string', default: '', displayOptions: { show: { resource: ['deal'], operation: ['get'] } }, description: 'Deal Id to fetch (required).' },
|
|
328
|
+
]
|
|
61
329
|
};
|
|
62
330
|
}
|
|
63
331
|
async execute() {
|
|
@@ -66,53 +334,19 @@ class DidarCrm {
|
|
|
66
334
|
for (let i = 0; i < items.length; i++) {
|
|
67
335
|
const resource = this.getNodeParameter('resource', i);
|
|
68
336
|
const operation = this.getNodeParameter('operation', i);
|
|
69
|
-
if (resource === 'deal'
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
SourceOther: this.getNodeParameter('SourceOther', i),
|
|
82
|
-
LostReasonNote: this.getNodeParameter('LostReasonNote', i),
|
|
83
|
-
LostReasonOther: this.getNodeParameter('LostReasonOther', i),
|
|
84
|
-
Price: this.getNodeParameter('Price', i),
|
|
85
|
-
CurrencyId: this.getNodeParameter('CurrencyId', i),
|
|
86
|
-
VisibilityType: this.getNodeParameter('VisibilityType', i),
|
|
87
|
-
Status: this.getNodeParameter('Status', i),
|
|
88
|
-
};
|
|
89
|
-
const fieldsJson = this.getNodeParameter('Fields', i, '');
|
|
90
|
-
if (fieldsJson) {
|
|
91
|
-
try {
|
|
92
|
-
bodyDeal['Fields'] = typeof fieldsJson === 'string' ? JSON.parse(fieldsJson) : fieldsJson;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
throw new Error('Invalid JSON in "Custom Fields (JSON)".');
|
|
96
|
-
}
|
|
337
|
+
if (resource === 'deal') {
|
|
338
|
+
if (operation === 'create') {
|
|
339
|
+
await DealOps.dealCreate.call(this, i, returnData);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (operation === 'update') {
|
|
343
|
+
await DealOps.dealUpdate.call(this, i, returnData);
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (operation === 'get') {
|
|
347
|
+
await DealOps.dealGet.call(this, i, returnData);
|
|
348
|
+
continue;
|
|
97
349
|
}
|
|
98
|
-
const creds = await this.getCredentials('didarApi');
|
|
99
|
-
const baseUrl = creds.baseUrl;
|
|
100
|
-
const apiKey = creds.apiKey;
|
|
101
|
-
const useCookie = creds.useCookie;
|
|
102
|
-
const cookie = creds.cookie;
|
|
103
|
-
const urlBase = (baseUrl || '').replace(/\/+$/, '');
|
|
104
|
-
const url = `${urlBase}/api/deal/save?apikey=${encodeURIComponent(apiKey)}`;
|
|
105
|
-
const options = {
|
|
106
|
-
method: 'POST',
|
|
107
|
-
url,
|
|
108
|
-
body: { Deal: bodyDeal },
|
|
109
|
-
json: true,
|
|
110
|
-
headers: { 'Content-Type': 'application/json' },
|
|
111
|
-
};
|
|
112
|
-
if (useCookie && cookie)
|
|
113
|
-
options.headers.Cookie = cookie;
|
|
114
|
-
const resp = await this.helpers.httpRequest(options);
|
|
115
|
-
returnData.push({ json: resp });
|
|
116
350
|
}
|
|
117
351
|
}
|
|
118
352
|
return [returnData];
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealCreate = dealCreate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function dealCreate(i, returnData) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7
|
+
// --- Required composed: Owner / Pipeline / Stage ---
|
|
8
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i);
|
|
9
|
+
const ownerId = ownerMode === 'select'
|
|
10
|
+
? this.getNodeParameter('OwnerIdSelect', i, '')
|
|
11
|
+
: this.getNodeParameter('OwnerIdManual', i, '');
|
|
12
|
+
if (!ownerId)
|
|
13
|
+
throw new Error('OwnerId is required (select from list or enter manually).');
|
|
14
|
+
const pipelineMode = this.getNodeParameter('PipelineMode', i);
|
|
15
|
+
const pipelineId = pipelineMode === 'select'
|
|
16
|
+
? this.getNodeParameter('PipelineIdSelect', i, '')
|
|
17
|
+
: this.getNodeParameter('PipelineId', i, '');
|
|
18
|
+
if (!pipelineId)
|
|
19
|
+
throw new Error('PipelineId is required (select from list or enter manually).');
|
|
20
|
+
const stageMode = this.getNodeParameter('StageMode', i);
|
|
21
|
+
const pipelineStageId = stageMode === 'select'
|
|
22
|
+
? this.getNodeParameter('PipelineStageIdSelect', i, '')
|
|
23
|
+
: this.getNodeParameter('PipelineStageId', i, '');
|
|
24
|
+
if (!pipelineStageId)
|
|
25
|
+
throw new Error('PipelineStageId is required (select from list or enter manually).');
|
|
26
|
+
// --- Required simple ---
|
|
27
|
+
const title = this.getNodeParameter('Title', i, '');
|
|
28
|
+
if (!title)
|
|
29
|
+
throw new Error('Title is required.');
|
|
30
|
+
const personId = this.getNodeParameter('PersonId', i, '');
|
|
31
|
+
if (!personId)
|
|
32
|
+
throw new Error('PersonId is required.');
|
|
33
|
+
const companyId = this.getNodeParameter('CompanyId', i, '');
|
|
34
|
+
if (!companyId)
|
|
35
|
+
throw new Error('CompanyId is required.');
|
|
36
|
+
const status = this.getNodeParameter('Status', i, '');
|
|
37
|
+
if (!status)
|
|
38
|
+
throw new Error('Status is required.');
|
|
39
|
+
// --- Additional Fields (collection) ---
|
|
40
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
41
|
+
const description = (_a = add.Description) !== null && _a !== void 0 ? _a : '';
|
|
42
|
+
const sourceId = (_b = add.SourceId) !== null && _b !== void 0 ? _b : '00000000-0000-0000-0000-000000000000';
|
|
43
|
+
const sourceOther = (_c = add.SourceOther) !== null && _c !== void 0 ? _c : '';
|
|
44
|
+
const lostReasonId = (_d = add.LostReasonId) !== null && _d !== void 0 ? _d : '00000000-0000-0000-0000-000000000000';
|
|
45
|
+
const lostReasonNote = (_e = add.LostReasonNote) !== null && _e !== void 0 ? _e : '';
|
|
46
|
+
const lostReasonOther = (_f = add.LostReasonOther) !== null && _f !== void 0 ? _f : '';
|
|
47
|
+
const creatorId = (_g = add.CreatorId) !== null && _g !== void 0 ? _g : ownerId;
|
|
48
|
+
const price = (_h = add.Price) !== null && _h !== void 0 ? _h : '0';
|
|
49
|
+
const visibilityType = (_j = add.VisibilityType) !== null && _j !== void 0 ? _j : '1';
|
|
50
|
+
// Custom fields
|
|
51
|
+
let fields;
|
|
52
|
+
if (typeof add.Fields === 'string' && add.Fields.trim()) {
|
|
53
|
+
try {
|
|
54
|
+
fields = JSON.parse(add.Fields);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
throw new Error('Invalid JSON in "Custom Fields (JSON)".');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (typeof add.Fields === 'object' && add.Fields) {
|
|
61
|
+
fields = add.Fields;
|
|
62
|
+
}
|
|
63
|
+
const bodyDeal = {
|
|
64
|
+
OwnerId: ownerId,
|
|
65
|
+
PersonId: personId,
|
|
66
|
+
CompanyId: companyId,
|
|
67
|
+
SourceId: sourceId,
|
|
68
|
+
PipelineId: pipelineId,
|
|
69
|
+
PipelineStageId: pipelineStageId,
|
|
70
|
+
LostReasonId: lostReasonId,
|
|
71
|
+
CreatorId: creatorId,
|
|
72
|
+
Title: title,
|
|
73
|
+
Description: description,
|
|
74
|
+
SourceOther: sourceOther,
|
|
75
|
+
LostReasonNote: lostReasonNote,
|
|
76
|
+
LostReasonOther: lostReasonOther,
|
|
77
|
+
Price: price,
|
|
78
|
+
VisibilityType: visibilityType,
|
|
79
|
+
Status: status,
|
|
80
|
+
};
|
|
81
|
+
if (fields)
|
|
82
|
+
bodyDeal['Fields'] = fields;
|
|
83
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
path: '/api/deal/save',
|
|
86
|
+
body: { Deal: bodyDeal },
|
|
87
|
+
});
|
|
88
|
+
returnData.push({ json: resp });
|
|
89
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealGet = dealGet;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function dealGet(i, returnData) {
|
|
6
|
+
const dealId = this.getNodeParameter('dealId', i, '');
|
|
7
|
+
if (!dealId)
|
|
8
|
+
throw new Error('Deal Id is required.');
|
|
9
|
+
// اگر endpoint دقیق get چیز دیگری است، اینجا عوض کن
|
|
10
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
path: '/api/deal/get',
|
|
13
|
+
qs: { dealId },
|
|
14
|
+
});
|
|
15
|
+
returnData.push({ json: resp });
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealGet = exports.dealUpdate = exports.dealCreate = void 0;
|
|
4
|
+
var create_operation_1 = require("./create.operation");
|
|
5
|
+
Object.defineProperty(exports, "dealCreate", { enumerable: true, get: function () { return create_operation_1.dealCreate; } });
|
|
6
|
+
var update_operation_1 = require("./update.operation");
|
|
7
|
+
Object.defineProperty(exports, "dealUpdate", { enumerable: true, get: function () { return update_operation_1.dealUpdate; } });
|
|
8
|
+
var get_operation_1 = require("./get.operation");
|
|
9
|
+
Object.defineProperty(exports, "dealGet", { enumerable: true, get: function () { return get_operation_1.dealGet; } });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealUpdate = dealUpdate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function dealUpdate(i, returnData) {
|
|
6
|
+
const dealId = this.getNodeParameter('dealId', i, '');
|
|
7
|
+
if (!dealId)
|
|
8
|
+
throw new Error('Deal Id is required.');
|
|
9
|
+
const updateBodyParam = this.getNodeParameter('updateBody', i, '');
|
|
10
|
+
let updateFields = {};
|
|
11
|
+
if (typeof updateBodyParam === 'string' && updateBodyParam.trim()) {
|
|
12
|
+
try {
|
|
13
|
+
updateFields = JSON.parse(updateBodyParam);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
throw new Error('Invalid JSON in "Update Body (JSON)".');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (typeof updateBodyParam === 'object' && updateBodyParam) {
|
|
20
|
+
updateFields = updateBodyParam;
|
|
21
|
+
}
|
|
22
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
path: '/api/deal/save',
|
|
25
|
+
body: { Deal: { Id: dealId, ...updateFields } },
|
|
26
|
+
});
|
|
27
|
+
returnData.push({ json: resp });
|
|
28
|
+
}
|