@divyacon/piece-zoho-crm 0.0.0-stage → 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/LICENSE.MIT-AP +24 -0
- package/README.md +8 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/read-file.d.ts +4 -0
- package/dist/lib/actions/read-file.d.ts.map +1 -0
- package/dist/lib/actions/read-file.js +44 -0
- package/dist/lib/actions/read-file.js.map +1 -0
- package/dist/lib/auth.d.ts +2 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +49 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/triggers/new-contact.d.ts +3 -0
- package/dist/lib/triggers/new-contact.d.ts.map +1 -0
- package/dist/lib/triggers/new-contact.js +197 -0
- package/dist/lib/triggers/new-contact.js.map +1 -0
- package/package.json +44 -3
- package/src/index.ts +38 -0
- package/src/lib/actions/read-file.ts +47 -0
- package/src/lib/auth.ts +44 -0
- package/src/lib/triggers/new-contact.ts +200 -0
package/LICENSE.MIT-AP
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Activepieces AB
|
|
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.
|
|
22
|
+
|
|
23
|
+
Derived helpers in this folder are adapted from Activepieces (MIT) for use
|
|
24
|
+
inside CX without depending on @activepieces/* packages at runtime.
|
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @divyacon/piece-zoho-crm
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DivyaCon connector for workflows and automations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`ash
|
|
8
|
+
npm install @divyacon/piece-zoho-crm
|
|
9
|
+
`
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,OAAO,gJAyBlB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zohoCrm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/zoho-crm/src/index.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const pieces_framework_2 = require("@agnocon/pieces-framework");
|
|
10
|
+
const new_contact_1 = require("./lib/triggers/new-contact");
|
|
11
|
+
const read_file_1 = require("./lib/actions/read-file");
|
|
12
|
+
const auth_1 = require("./lib/auth");
|
|
13
|
+
exports.zohoCrm = (0, pieces_framework_1.createPiece)({
|
|
14
|
+
displayName: 'Zoho CRM',
|
|
15
|
+
description: 'Customer relationship management software',
|
|
16
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/zoho-crm.png',
|
|
17
|
+
minimumSupportedRelease: '0.30.0',
|
|
18
|
+
categories: [pieces_framework_2.PieceCategory.SALES_AND_CRM],
|
|
19
|
+
authors: ["kishanprmr", "MoShizzle", "khaledmashaly", "abuaboud", "ikus060"],
|
|
20
|
+
auth: auth_1.zohoCrmAuth,
|
|
21
|
+
actions: [
|
|
22
|
+
read_file_1.readFile,
|
|
23
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
24
|
+
baseUrl: (auth) => {
|
|
25
|
+
const data = auth.data;
|
|
26
|
+
return data && data['api_domain'] ? `${data['api_domain']}/crm/v3` : '';
|
|
27
|
+
},
|
|
28
|
+
auth: auth_1.zohoCrmAuth,
|
|
29
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
return ({
|
|
31
|
+
Authorization: `Zoho-oauthtoken ${auth.access_token}`,
|
|
32
|
+
});
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
triggers: [new_contact_1.newContact],
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,oFAAoF;AACpF,qEAAqE;AACrE,0DAAmE;AACnE,gEAKmC;AACnC,gEAA0D;AAC1D,4DAAwD;AACxD,uDAAmD;AACnD,qCAAyC;AAE5B,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,2CAA2C;IAExD,OAAO,EAAE,kDAAkD;IAC3D,uBAAuB,EAAE,QAAQ;IACjC,UAAU,EAAE,CAAC,gCAAa,CAAC,aAAa,CAAC;IACzC,OAAO,EAAE,CAAC,YAAY,EAAC,WAAW,EAAC,eAAe,EAAC,UAAU,EAAC,SAAS,CAAC;IACxE,IAAI,EAAE,kBAAW;IACjB,OAAO,EAAE;QACP,oBAAQ;QACR,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAEd,MAAM,IAAI,GAAI,IAA4B,CAAC,IAAI,CAAC;gBAChD,OAAO,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,CAAA,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAA;YACxE,CAAC;YAEH,IAAI,EAAE,kBAAW;YACjB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,mBAAoB,IAA4B,CAAC,YAAY,EAAE;iBAC/E,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,wBAAU,CAAC;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const readFile: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
2
|
+
url: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
}>;
|
|
4
|
+
//# sourceMappingURL=read-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/read-file.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ;;EA0CnB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readFile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/zoho-crm/src/lib/actions/read-file.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
exports.readFile = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.zohoCrmAuth,
|
|
11
|
+
name: 'read-file',
|
|
12
|
+
displayName: 'Read file',
|
|
13
|
+
description: 'Download a file content from Zoho CRM. e.g.: a Backup File',
|
|
14
|
+
audience: 'both',
|
|
15
|
+
aiMetadata: { description: 'Downloads the binary content of a file from Zoho CRM (e.g. a backup or attachment) given its full URL, authenticating with the connected account, and returns it as a stored file. Use when you already hold a Zoho CRM file URL and need its bytes for a later step. Requires the complete URL including the base host; read-only, so repeating the call is safe.', idempotent: true },
|
|
16
|
+
props: {
|
|
17
|
+
url: pieces_framework_1.Property.ShortText({
|
|
18
|
+
displayName: 'URL',
|
|
19
|
+
description: 'The full URL to use, including the base URL',
|
|
20
|
+
required: true,
|
|
21
|
+
defaultValue: '',
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
run: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, files }) {
|
|
25
|
+
var _b;
|
|
26
|
+
const url = propsValue['url'];
|
|
27
|
+
const download = yield fetch(url, {
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
.then((response) => response.ok ? response.blob() : Promise.reject(response))
|
|
33
|
+
.catch((error) => {
|
|
34
|
+
var _a;
|
|
35
|
+
return Promise.reject(new Error(`Error when download file:\n\tDownload file response: ${(_a = error.message) !== null && _a !== void 0 ? _a : error}`));
|
|
36
|
+
});
|
|
37
|
+
const fileName = (_b = url.split('/').pop()) !== null && _b !== void 0 ? _b : url;
|
|
38
|
+
return files.write({
|
|
39
|
+
fileName: fileName,
|
|
40
|
+
data: Buffer.from(yield download.arrayBuffer()),
|
|
41
|
+
});
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=read-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../../src/lib/actions/read-file.ts"],"names":[],"mappings":";;;;AAAA,oGAAoG;AACpG,qEAAqE;AACrE,kCAAsC;AACtC,gEAAmE;AAGtD,QAAA,QAAQ,GAAG,IAAA,+BAAY,EAAC;IACjC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,4DAA4D;IACzE,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,oWAAoW,EAAE,UAAU,EAAE,IAAI,EAAE;IACnZ,KAAK,EAAE;QACH,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACpB,WAAW,EAAE,KAAK;YAClB,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,EAAE;SACnB,CAAC;KACL;IACD,GAAG,EAAE,KAAoC,EAAE,oDAA/B,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;;QACnC,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAE9B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC9B,OAAO,EAAE;gBACL,aAAa,EAAE,UAAU,IAAI,CAAC,YAAY,EAAE;aAC/C;SACJ,CAAC;aACG,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACf,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAC3D;aACA,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;;YACb,OAAA,OAAO,CAAC,MAAM,CACV,IAAI,KAAK,CACL,wDAAwD,MAAC,KAAe,CAAC,OAAO,mCAAI,KACpF,EAAE,CACL,CACJ,CAAA;SAAA,CACJ,CAAC;QAEN,MAAM,QAAQ,GAAG,MAAA,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,mCAAI,GAAG,CAAC;QAE7C,OAAO,KAAK,CAAC,KAAK,CAAC;YACf,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;SAClD,CAAC,CAAC;IACP,CAAC,CAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,qGAyCtB,CAAC"}
|
package/dist/lib/auth.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zohoCrmAuth = void 0;
|
|
4
|
+
// Vendored from Activepieces packages/pieces/community/zoho-crm/src/lib/auth.ts (MIT).
|
|
5
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
6
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
7
|
+
exports.zohoCrmAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
8
|
+
props: {
|
|
9
|
+
location: pieces_framework_1.Property.StaticDropdown({
|
|
10
|
+
displayName: 'Location',
|
|
11
|
+
description: 'The location of your Zoho CRM account',
|
|
12
|
+
required: true,
|
|
13
|
+
options: {
|
|
14
|
+
options: [
|
|
15
|
+
{
|
|
16
|
+
label: 'zoho.eu (Europe)',
|
|
17
|
+
value: 'zoho.eu',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: 'zoho.com (United States)',
|
|
21
|
+
value: 'zoho.com',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: 'zoho.com.au (Australia)',
|
|
25
|
+
value: 'zoho.com.au',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'zoho.jp (Japan)',
|
|
29
|
+
value: 'zoho.jp',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: 'zoho.in (India)',
|
|
33
|
+
value: 'zoho.in',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: 'zohocloud.ca (Canada)',
|
|
37
|
+
value: 'zohocloud.ca',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
description: 'Authentication for Zoho CRM',
|
|
44
|
+
scope: ['ZohoCRM.users.ALL', 'ZohoCRM.org.ALL', 'ZohoCRM.settings.ALL', 'ZohoCRM.modules.ALL', 'ZohoCRM.bulk.ALL', 'ZohoCRM.bulk.backup.ALL', 'ZohoFiles.files.ALL'],
|
|
45
|
+
authUrl: 'https://accounts.{location}/oauth/v2/auth',
|
|
46
|
+
tokenUrl: 'https://accounts.{location}/oauth/v2/token',
|
|
47
|
+
required: true,
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,uFAAuF;AACvF,qEAAqE;AACrE,gEAAgE;AAEnD,QAAA,WAAW,GAAG,4BAAS,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAChC,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,kBAAkB;wBACzB,KAAK,EAAE,SAAS;qBACjB;oBACD;wBACE,KAAK,EAAE,0BAA0B;wBACjC,KAAK,EAAE,UAAU;qBAClB;oBACD;wBACE,KAAK,EAAE,yBAAyB;wBAChC,KAAK,EAAE,aAAa;qBACrB;oBACD;wBACE,KAAK,EAAE,iBAAiB;wBACxB,KAAK,EAAE,SAAS;qBACjB;oBACD;wBACE,KAAK,EAAE,iBAAiB;wBACxB,KAAK,EAAE,SAAS;qBACjB;oBACD;wBACE,KAAK,EAAE,uBAAuB;wBAC9B,KAAK,EAAE,cAAc;qBACtB;iBACF;aACF;SACF,CAAC;KACH;IACD,WAAW,EAAE,6BAA6B;IAC1C,KAAK,EAAE,CAAC,mBAAmB,EAAC,iBAAiB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,CAAC;IACnK,OAAO,EAAE,2CAA2C;IACpD,QAAQ,EAAE,4CAA4C;IACtD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newContact: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {}>;
|
|
3
|
+
//# sourceMappingURL=new-contact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-contact.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-contact.ts"],"names":[],"mappings":"AAUA,OAAO,EAIL,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAInC,eAAO,MAAM,UAAU,ssBA6GrB,CAAC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newContact = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/zoho-crm/src/lib/triggers/new-contact.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
10
|
+
const auth_1 = require("../auth");
|
|
11
|
+
exports.newContact = (0, pieces_framework_1.createTrigger)({
|
|
12
|
+
auth: auth_1.zohoCrmAuth,
|
|
13
|
+
name: 'new_contact',
|
|
14
|
+
displayName: 'New Contact',
|
|
15
|
+
description: 'Triggers when a new contact is created',
|
|
16
|
+
aiMetadata: {
|
|
17
|
+
description: 'Fires when a new contact record is created in the connected Zoho CRM account, emitting that contact. Polls the Contacts module ordered by creation time, so it represents newly added contacts.',
|
|
18
|
+
},
|
|
19
|
+
sampleData: {
|
|
20
|
+
Owner: {
|
|
21
|
+
name: 'Activepieces Apps',
|
|
22
|
+
id: '560094000000343001',
|
|
23
|
+
email: 'apps@activepieces.com',
|
|
24
|
+
},
|
|
25
|
+
Email: 'capla-paprocki@yahoo.com',
|
|
26
|
+
Description: null,
|
|
27
|
+
$currency_symbol: '$',
|
|
28
|
+
Vendor_Name: null,
|
|
29
|
+
Mailing_Zip: '99501',
|
|
30
|
+
$field_states: null,
|
|
31
|
+
Other_Phone: null,
|
|
32
|
+
Mailing_State: 'AK',
|
|
33
|
+
$review_process: {
|
|
34
|
+
approve: false,
|
|
35
|
+
reject: false,
|
|
36
|
+
resubmit: false,
|
|
37
|
+
},
|
|
38
|
+
Twitter: 'lpaprocki_sample',
|
|
39
|
+
Other_Zip: null,
|
|
40
|
+
Mailing_Street: '639 Main St',
|
|
41
|
+
Other_State: null,
|
|
42
|
+
$sharing_permission: 'full_access',
|
|
43
|
+
Salutation: null,
|
|
44
|
+
Other_Country: null,
|
|
45
|
+
Last_Activity_Time: '2023-03-26T00:02:28+01:00',
|
|
46
|
+
First_Name: 'Capla',
|
|
47
|
+
Full_Name: 'Capla Paprocki (Sample)',
|
|
48
|
+
Asst_Phone: null,
|
|
49
|
+
Record_Image: 'd7d6bec0cbbfd9f3b84ebcd2eba41e9fa432f48560f9ed267b2e5b26eb58a07f5451e24ca9042b39f05459c41291c005b0dea6b224d375a6030f4096eb631fa3d4dcabb97393f1dc2470eb1658164f05',
|
|
50
|
+
Department: 'Admin',
|
|
51
|
+
Modified_By: {
|
|
52
|
+
name: 'Activepieces Apps',
|
|
53
|
+
id: '560094000000343001',
|
|
54
|
+
email: 'apps@activepieces.com',
|
|
55
|
+
},
|
|
56
|
+
$review: null,
|
|
57
|
+
$state: 'save',
|
|
58
|
+
Skype_ID: 'lpaprocki',
|
|
59
|
+
Unsubscribed_Mode: null,
|
|
60
|
+
$process_flow: false,
|
|
61
|
+
Assistant: null,
|
|
62
|
+
Phone: '555-555-5555',
|
|
63
|
+
Mailing_Country: 'United States',
|
|
64
|
+
id: '560094000000349199',
|
|
65
|
+
Reporting_To: null,
|
|
66
|
+
$approval: {
|
|
67
|
+
delegate: false,
|
|
68
|
+
approve: false,
|
|
69
|
+
reject: false,
|
|
70
|
+
resubmit: false,
|
|
71
|
+
},
|
|
72
|
+
Enrich_Status__s: null,
|
|
73
|
+
Other_City: null,
|
|
74
|
+
Created_Time: '2023-03-26T00:01:56+01:00',
|
|
75
|
+
$wizard_connection_path: null,
|
|
76
|
+
$editable: true,
|
|
77
|
+
Home_Phone: null,
|
|
78
|
+
Created_By: {
|
|
79
|
+
name: 'Activepieces Apps',
|
|
80
|
+
id: '560094000000343001',
|
|
81
|
+
email: 'apps@activepieces.com',
|
|
82
|
+
},
|
|
83
|
+
$zia_owner_assignment: 'owner_recommendation_unavailable',
|
|
84
|
+
Secondary_Email: null,
|
|
85
|
+
},
|
|
86
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
87
|
+
props: {},
|
|
88
|
+
run(context) {
|
|
89
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
91
|
+
auth: context.auth,
|
|
92
|
+
store: context.store,
|
|
93
|
+
propsValue: context.propsValue,
|
|
94
|
+
files: context.files,
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
test(_a) {
|
|
99
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, store, files }) {
|
|
100
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
101
|
+
auth,
|
|
102
|
+
store: store,
|
|
103
|
+
propsValue: propsValue,
|
|
104
|
+
files: files,
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
onEnable(_a) {
|
|
109
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, store }) {
|
|
110
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
111
|
+
auth,
|
|
112
|
+
store: store,
|
|
113
|
+
propsValue: propsValue,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
onDisable(_a) {
|
|
118
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, store }) {
|
|
119
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
120
|
+
auth,
|
|
121
|
+
store: store,
|
|
122
|
+
propsValue: propsValue,
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
const polling = {
|
|
128
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
129
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
130
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
131
|
+
url: `${auth.data.api_domain}/crm/v4/Contacts`,
|
|
132
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
133
|
+
queryParams: {
|
|
134
|
+
perPage: '200',
|
|
135
|
+
sort_order: 'desc',
|
|
136
|
+
sort_by: 'Created_Time',
|
|
137
|
+
fields: [
|
|
138
|
+
'Owner',
|
|
139
|
+
'Email',
|
|
140
|
+
'$currency_symbol',
|
|
141
|
+
'$field_states',
|
|
142
|
+
'Other_Phone',
|
|
143
|
+
'Mailing_State',
|
|
144
|
+
'Other_State',
|
|
145
|
+
'$sharing_permission',
|
|
146
|
+
'Other_Country',
|
|
147
|
+
'Last_Activity_Time',
|
|
148
|
+
'Department',
|
|
149
|
+
'$state',
|
|
150
|
+
'Unsubscribed_Mode',
|
|
151
|
+
'$process_flow',
|
|
152
|
+
'Assistant',
|
|
153
|
+
'Mailing_Country',
|
|
154
|
+
'id',
|
|
155
|
+
'Reporting_To',
|
|
156
|
+
'$approval',
|
|
157
|
+
'Enrich_Status__s',
|
|
158
|
+
'Other_City',
|
|
159
|
+
'Created_Time',
|
|
160
|
+
'$wizard_connection_path',
|
|
161
|
+
'$editable',
|
|
162
|
+
'Home_Phone',
|
|
163
|
+
'Created_By',
|
|
164
|
+
'$zia_owner_assignment',
|
|
165
|
+
'Secondary_Email',
|
|
166
|
+
'Description',
|
|
167
|
+
'Vendor_Name',
|
|
168
|
+
'Mailing_Zip',
|
|
169
|
+
'$review_process',
|
|
170
|
+
'Twitter',
|
|
171
|
+
'Other_Zip',
|
|
172
|
+
'Mailing_Street',
|
|
173
|
+
'$canvas_id',
|
|
174
|
+
'Salutation',
|
|
175
|
+
'First_Name',
|
|
176
|
+
'Full_Name',
|
|
177
|
+
'Asst_Phone',
|
|
178
|
+
'Record_Image',
|
|
179
|
+
'Modified_By',
|
|
180
|
+
'$review',
|
|
181
|
+
'Skype_ID',
|
|
182
|
+
'Phone',
|
|
183
|
+
'Account_Name',
|
|
184
|
+
].join(','),
|
|
185
|
+
},
|
|
186
|
+
authentication: {
|
|
187
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
188
|
+
token: auth.access_token,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
return response.body.data.map((record) => ({
|
|
192
|
+
epochMilliSeconds: (0, dayjs_1.default)(record.Created_Time).valueOf(),
|
|
193
|
+
data: record,
|
|
194
|
+
}));
|
|
195
|
+
}),
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=new-contact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-contact.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-contact.ts"],"names":[],"mappings":";;;;AAAA,uGAAuG;AACvG,qEAAqE;AACrE,0DAOgC;AAChC,gEAKmC;AACnC,0DAA0B;AAC1B,kCAAsC;AAEzB,QAAA,UAAU,GAAG,IAAA,gCAAa,EAAC;IACtC,IAAI,EAAE,kBAAW;IAEjB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,wCAAwC;IACrD,UAAU,EAAE;QACV,WAAW,EAAE,iMAAiM;KAC/M;IACD,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,mBAAmB;YACzB,EAAE,EAAE,oBAAoB;YACxB,KAAK,EAAE,uBAAuB;SAC/B;QACD,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,IAAI;QACj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E,MAAM;SACb,CAAC,CAAC,CAAC;IACN,CAAC,CAAA;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@divyacon/piece-zoho-crm",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "DivyaCon zoho-crm connector",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src",
|
|
17
|
+
"LICENSE.MIT-AP"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"vendor": "node ../scripts/vendor-ap.mjs piece-zoho-crm"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@agnocon/core-utils": "0.2.0",
|
|
25
|
+
"@agnocon/piece-types": "0.3.1",
|
|
26
|
+
"@agnocon/pieces-common": "0.12.8",
|
|
27
|
+
"@agnocon/pieces-framework": "0.36.0",
|
|
28
|
+
"tslib": "2.6.2",
|
|
29
|
+
"dayjs": "1.11.9"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "20.17.6",
|
|
33
|
+
"typescript": "5.5.4"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"agnocon": {
|
|
37
|
+
"originVersion": "0.2.9"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"tag": "latest"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"agnocon",
|
|
45
|
+
"connector"
|
|
46
|
+
]
|
|
6
47
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createCustomApiCallAction } from '@agnocon/pieces-common';
|
|
2
|
+
import {
|
|
3
|
+
OAuth2PropertyValue,
|
|
4
|
+
PieceAuth,
|
|
5
|
+
Property,
|
|
6
|
+
createPiece,
|
|
7
|
+
} from '@agnocon/pieces-framework';
|
|
8
|
+
import { PieceCategory } from '@agnocon/pieces-framework';
|
|
9
|
+
import { newContact } from './lib/triggers/new-contact';
|
|
10
|
+
import { readFile } from './lib/actions/read-file';
|
|
11
|
+
import { zohoCrmAuth } from './lib/auth';
|
|
12
|
+
|
|
13
|
+
export const zohoCrm = createPiece({
|
|
14
|
+
displayName: 'Zoho CRM',
|
|
15
|
+
description: 'Customer relationship management software',
|
|
16
|
+
|
|
17
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/zoho-crm.png',
|
|
18
|
+
minimumSupportedRelease: '0.30.0',
|
|
19
|
+
categories: [PieceCategory.SALES_AND_CRM],
|
|
20
|
+
authors: ["kishanprmr","MoShizzle","khaledmashaly","abuaboud","ikus060"],
|
|
21
|
+
auth: zohoCrmAuth,
|
|
22
|
+
actions: [
|
|
23
|
+
readFile,
|
|
24
|
+
createCustomApiCallAction({
|
|
25
|
+
baseUrl: (auth) =>
|
|
26
|
+
{
|
|
27
|
+
const data = (auth as OAuth2PropertyValue).data;
|
|
28
|
+
return data && data['api_domain']? `${data['api_domain']}/crm/v3` : ''
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
auth: zohoCrmAuth,
|
|
32
|
+
authMapping: async (auth) => ({
|
|
33
|
+
Authorization: `Zoho-oauthtoken ${(auth as OAuth2PropertyValue).access_token}`,
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
triggers: [newContact],
|
|
38
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { zohoCrmAuth } from '../auth';
|
|
2
|
+
import { Property, createAction } from "@agnocon/pieces-framework";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const readFile = createAction({
|
|
6
|
+
auth: zohoCrmAuth,
|
|
7
|
+
name: 'read-file',
|
|
8
|
+
displayName: 'Read file',
|
|
9
|
+
description: 'Download a file content from Zoho CRM. e.g.: a Backup File',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Downloads the binary content of a file from Zoho CRM (e.g. a backup or attachment) given its full URL, authenticating with the connected account, and returns it as a stored file. Use when you already hold a Zoho CRM file URL and need its bytes for a later step. Requires the complete URL including the base host; read-only, so repeating the call is safe.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
url: Property.ShortText({
|
|
14
|
+
displayName: 'URL',
|
|
15
|
+
description: 'The full URL to use, including the base URL',
|
|
16
|
+
required: true,
|
|
17
|
+
defaultValue: '',
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
run: async ({ auth, propsValue, files }) => {
|
|
21
|
+
const url = propsValue['url'];
|
|
22
|
+
|
|
23
|
+
const download = await fetch(url, {
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
.then((response) =>
|
|
29
|
+
response.ok ? response.blob() : Promise.reject(response)
|
|
30
|
+
)
|
|
31
|
+
.catch((error) =>
|
|
32
|
+
Promise.reject(
|
|
33
|
+
new Error(
|
|
34
|
+
`Error when download file:\n\tDownload file response: ${(error as Error).message ?? error
|
|
35
|
+
}`
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const fileName = url.split('/').pop() ?? url;
|
|
41
|
+
|
|
42
|
+
return files.write({
|
|
43
|
+
fileName: fileName,
|
|
44
|
+
data: Buffer.from(await download.arrayBuffer()),
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
});
|
package/src/lib/auth.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PieceAuth, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
|
|
3
|
+
export const zohoCrmAuth = PieceAuth.OAuth2({
|
|
4
|
+
props: {
|
|
5
|
+
location: Property.StaticDropdown({
|
|
6
|
+
displayName: 'Location',
|
|
7
|
+
description: 'The location of your Zoho CRM account',
|
|
8
|
+
required: true,
|
|
9
|
+
options: {
|
|
10
|
+
options: [
|
|
11
|
+
{
|
|
12
|
+
label: 'zoho.eu (Europe)',
|
|
13
|
+
value: 'zoho.eu',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: 'zoho.com (United States)',
|
|
17
|
+
value: 'zoho.com',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: 'zoho.com.au (Australia)',
|
|
21
|
+
value: 'zoho.com.au',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: 'zoho.jp (Japan)',
|
|
25
|
+
value: 'zoho.jp',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'zoho.in (India)',
|
|
29
|
+
value: 'zoho.in',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: 'zohocloud.ca (Canada)',
|
|
33
|
+
value: 'zohocloud.ca',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
description: 'Authentication for Zoho CRM',
|
|
40
|
+
scope: ['ZohoCRM.users.ALL','ZohoCRM.org.ALL', 'ZohoCRM.settings.ALL', 'ZohoCRM.modules.ALL', 'ZohoCRM.bulk.ALL', 'ZohoCRM.bulk.backup.ALL', 'ZohoFiles.files.ALL'],
|
|
41
|
+
authUrl: 'https://accounts.{location}/oauth/v2/auth',
|
|
42
|
+
tokenUrl: 'https://accounts.{location}/oauth/v2/token',
|
|
43
|
+
required: true,
|
|
44
|
+
});
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticationType,
|
|
3
|
+
DedupeStrategy,
|
|
4
|
+
httpClient,
|
|
5
|
+
HttpMethod,
|
|
6
|
+
Polling,
|
|
7
|
+
pollingHelper,
|
|
8
|
+
} from '@agnocon/pieces-common';
|
|
9
|
+
import {
|
|
10
|
+
AppConnectionValueForAuthProperty,
|
|
11
|
+
createTrigger,
|
|
12
|
+
OAuth2PropertyValue,
|
|
13
|
+
TriggerStrategy,
|
|
14
|
+
} from '@agnocon/pieces-framework';
|
|
15
|
+
import dayjs from 'dayjs';
|
|
16
|
+
import { zohoCrmAuth } from '../auth';
|
|
17
|
+
|
|
18
|
+
export const newContact = createTrigger({
|
|
19
|
+
auth: zohoCrmAuth,
|
|
20
|
+
|
|
21
|
+
name: 'new_contact',
|
|
22
|
+
displayName: 'New Contact',
|
|
23
|
+
description: 'Triggers when a new contact is created',
|
|
24
|
+
aiMetadata: {
|
|
25
|
+
description: 'Fires when a new contact record is created in the connected Zoho CRM account, emitting that contact. Polls the Contacts module ordered by creation time, so it represents newly added contacts.',
|
|
26
|
+
},
|
|
27
|
+
sampleData: {
|
|
28
|
+
Owner: {
|
|
29
|
+
name: 'Activepieces Apps',
|
|
30
|
+
id: '560094000000343001',
|
|
31
|
+
email: 'apps@activepieces.com',
|
|
32
|
+
},
|
|
33
|
+
Email: 'capla-paprocki@yahoo.com',
|
|
34
|
+
Description: null,
|
|
35
|
+
$currency_symbol: '$',
|
|
36
|
+
Vendor_Name: null,
|
|
37
|
+
Mailing_Zip: '99501',
|
|
38
|
+
$field_states: null,
|
|
39
|
+
Other_Phone: null,
|
|
40
|
+
Mailing_State: 'AK',
|
|
41
|
+
$review_process: {
|
|
42
|
+
approve: false,
|
|
43
|
+
reject: false,
|
|
44
|
+
resubmit: false,
|
|
45
|
+
},
|
|
46
|
+
Twitter: 'lpaprocki_sample',
|
|
47
|
+
Other_Zip: null,
|
|
48
|
+
Mailing_Street: '639 Main St',
|
|
49
|
+
Other_State: null,
|
|
50
|
+
$sharing_permission: 'full_access',
|
|
51
|
+
Salutation: null,
|
|
52
|
+
Other_Country: null,
|
|
53
|
+
Last_Activity_Time: '2023-03-26T00:02:28+01:00',
|
|
54
|
+
First_Name: 'Capla',
|
|
55
|
+
Full_Name: 'Capla Paprocki (Sample)',
|
|
56
|
+
Asst_Phone: null,
|
|
57
|
+
Record_Image:
|
|
58
|
+
'd7d6bec0cbbfd9f3b84ebcd2eba41e9fa432f48560f9ed267b2e5b26eb58a07f5451e24ca9042b39f05459c41291c005b0dea6b224d375a6030f4096eb631fa3d4dcabb97393f1dc2470eb1658164f05',
|
|
59
|
+
Department: 'Admin',
|
|
60
|
+
Modified_By: {
|
|
61
|
+
name: 'Activepieces Apps',
|
|
62
|
+
id: '560094000000343001',
|
|
63
|
+
email: 'apps@activepieces.com',
|
|
64
|
+
},
|
|
65
|
+
$review: null,
|
|
66
|
+
$state: 'save',
|
|
67
|
+
Skype_ID: 'lpaprocki',
|
|
68
|
+
Unsubscribed_Mode: null,
|
|
69
|
+
$process_flow: false,
|
|
70
|
+
Assistant: null,
|
|
71
|
+
Phone: '555-555-5555',
|
|
72
|
+
Mailing_Country: 'United States',
|
|
73
|
+
id: '560094000000349199',
|
|
74
|
+
Reporting_To: null,
|
|
75
|
+
$approval: {
|
|
76
|
+
delegate: false,
|
|
77
|
+
approve: false,
|
|
78
|
+
reject: false,
|
|
79
|
+
resubmit: false,
|
|
80
|
+
},
|
|
81
|
+
Enrich_Status__s: null,
|
|
82
|
+
Other_City: null,
|
|
83
|
+
Created_Time: '2023-03-26T00:01:56+01:00',
|
|
84
|
+
$wizard_connection_path: null,
|
|
85
|
+
$editable: true,
|
|
86
|
+
Home_Phone: null,
|
|
87
|
+
Created_By: {
|
|
88
|
+
name: 'Activepieces Apps',
|
|
89
|
+
id: '560094000000343001',
|
|
90
|
+
email: 'apps@activepieces.com',
|
|
91
|
+
},
|
|
92
|
+
$zia_owner_assignment: 'owner_recommendation_unavailable',
|
|
93
|
+
Secondary_Email: null,
|
|
94
|
+
},
|
|
95
|
+
type: TriggerStrategy.POLLING,
|
|
96
|
+
props: {},
|
|
97
|
+
async run(context) {
|
|
98
|
+
return await pollingHelper.poll(polling, {
|
|
99
|
+
auth: context.auth,
|
|
100
|
+
store: context.store,
|
|
101
|
+
propsValue: context.propsValue,
|
|
102
|
+
files: context.files,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
async test({ auth, propsValue, store, files }): Promise<unknown[]> {
|
|
106
|
+
return await pollingHelper.test(polling, {
|
|
107
|
+
auth,
|
|
108
|
+
store: store,
|
|
109
|
+
propsValue: propsValue,
|
|
110
|
+
files: files,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
async onEnable({ auth, propsValue, store }): Promise<void> {
|
|
114
|
+
await pollingHelper.onEnable(polling, {
|
|
115
|
+
auth,
|
|
116
|
+
store: store,
|
|
117
|
+
propsValue: propsValue,
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
async onDisable({ auth, propsValue, store }): Promise<void> {
|
|
121
|
+
await pollingHelper.onDisable(polling, {
|
|
122
|
+
auth,
|
|
123
|
+
store: store,
|
|
124
|
+
propsValue: propsValue,
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const polling: Polling<AppConnectionValueForAuthProperty<typeof zohoCrmAuth>, unknown> = {
|
|
130
|
+
strategy: DedupeStrategy.TIMEBASED,
|
|
131
|
+
items: async ({ auth }) => {
|
|
132
|
+
const response = await httpClient.sendRequest<{
|
|
133
|
+
data: { Created_Time: string }[];
|
|
134
|
+
}>({
|
|
135
|
+
url: `${auth.data.api_domain}/crm/v4/Contacts`,
|
|
136
|
+
method: HttpMethod.GET,
|
|
137
|
+
queryParams: {
|
|
138
|
+
perPage: '200',
|
|
139
|
+
sort_order: 'desc',
|
|
140
|
+
sort_by: 'Created_Time',
|
|
141
|
+
fields: [
|
|
142
|
+
'Owner',
|
|
143
|
+
'Email',
|
|
144
|
+
'$currency_symbol',
|
|
145
|
+
'$field_states',
|
|
146
|
+
'Other_Phone',
|
|
147
|
+
'Mailing_State',
|
|
148
|
+
'Other_State',
|
|
149
|
+
'$sharing_permission',
|
|
150
|
+
'Other_Country',
|
|
151
|
+
'Last_Activity_Time',
|
|
152
|
+
'Department',
|
|
153
|
+
'$state',
|
|
154
|
+
'Unsubscribed_Mode',
|
|
155
|
+
'$process_flow',
|
|
156
|
+
'Assistant',
|
|
157
|
+
'Mailing_Country',
|
|
158
|
+
'id',
|
|
159
|
+
'Reporting_To',
|
|
160
|
+
'$approval',
|
|
161
|
+
'Enrich_Status__s',
|
|
162
|
+
'Other_City',
|
|
163
|
+
'Created_Time',
|
|
164
|
+
'$wizard_connection_path',
|
|
165
|
+
'$editable',
|
|
166
|
+
'Home_Phone',
|
|
167
|
+
'Created_By',
|
|
168
|
+
'$zia_owner_assignment',
|
|
169
|
+
'Secondary_Email',
|
|
170
|
+
'Description',
|
|
171
|
+
'Vendor_Name',
|
|
172
|
+
'Mailing_Zip',
|
|
173
|
+
'$review_process',
|
|
174
|
+
'Twitter',
|
|
175
|
+
'Other_Zip',
|
|
176
|
+
'Mailing_Street',
|
|
177
|
+
'$canvas_id',
|
|
178
|
+
'Salutation',
|
|
179
|
+
'First_Name',
|
|
180
|
+
'Full_Name',
|
|
181
|
+
'Asst_Phone',
|
|
182
|
+
'Record_Image',
|
|
183
|
+
'Modified_By',
|
|
184
|
+
'$review',
|
|
185
|
+
'Skype_ID',
|
|
186
|
+
'Phone',
|
|
187
|
+
'Account_Name',
|
|
188
|
+
].join(','),
|
|
189
|
+
},
|
|
190
|
+
authentication: {
|
|
191
|
+
type: AuthenticationType.BEARER_TOKEN,
|
|
192
|
+
token: auth.access_token,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
return response.body.data.map((record) => ({
|
|
196
|
+
epochMilliSeconds: dayjs(record.Created_Time).valueOf(),
|
|
197
|
+
data: record,
|
|
198
|
+
}));
|
|
199
|
+
},
|
|
200
|
+
};
|