@activepieces/piece-zendesk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-zendesk
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running lint
6
+
7
+ Run `nx lint pieces-zendesk` to execute the lint via [ESLint](https://eslint.org/).
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@activepieces/piece-zendesk",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.26.3",
6
+ "axios": "1.2.4",
7
+ "nanoid": "3.3.4",
8
+ "@activepieces/framework": "0.3.9",
9
+ "@activepieces/shared": "0.3.5",
10
+ "tslib": "2.4.1"
11
+ },
12
+ "main": "./src/index.js",
13
+ "types": "./src/index.d.ts"
14
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const zendesk: import("@activepieces/framework").Piece;
package/src/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zendesk = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ const package_json_1 = tslib_1.__importDefault(require("../package.json"));
7
+ const new_ticket_in_view_1 = require("./lib/trigger/new-ticket-in-view");
8
+ exports.zendesk = (0, framework_1.createPiece)({
9
+ name: 'zendesk',
10
+ displayName: 'Zendesk',
11
+ logoUrl: 'https://cdn.activepieces.com/pieces/zendesk.png',
12
+ version: package_json_1.default.version,
13
+ authors: [
14
+ "abuaboud"
15
+ ],
16
+ actions: [],
17
+ triggers: [
18
+ new_ticket_in_view_1.newTicketInView
19
+ ],
20
+ });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/zendesk/src/index.ts"],"names":[],"mappings":";;;;AACA,uDAAsD;AACtD,2EAA0C;AAC1C,yEAAmE;AAEtD,QAAA,OAAO,GAAG,IAAA,uBAAW,EAAC;IACjC,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,SAAS;IACtB,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,sBAAW,CAAC,OAAO;IAC5B,OAAO,EAAE;QACP,UAAU;KACX;IACD,OAAO,EAAE,EACR;IACD,QAAQ,EAAE;QACR,oCAAe;KAChB;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const newTicketInView: import("@activepieces/framework").Trigger;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newTicketInView = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const shared_1 = require("@activepieces/shared");
6
+ const framework_1 = require("@activepieces/framework");
7
+ const markdownProperty = `
8
+ **Organization**: The organization name can be found in the URL (e.g https://ORGANIZATION_NAME.zendesk.com).
9
+
10
+ **Agent Email**: The email you use to log in to Zendesk.
11
+
12
+ **API Token**: You can find this in the Zendesk Admin Panel under Settings > APIs > Zendesk API.
13
+ `;
14
+ exports.newTicketInView = (0, framework_1.createTrigger)({
15
+ name: 'new_ticket_in_view',
16
+ displayName: 'New ticket in view',
17
+ description: 'Triggers when a new ticket is created in a view',
18
+ type: shared_1.TriggerStrategy.POLLING,
19
+ props: {
20
+ authentication: framework_1.Property.CustomAuth({
21
+ displayName: 'Authentication',
22
+ description: markdownProperty,
23
+ props: {
24
+ email: framework_1.Property.ShortText({
25
+ displayName: 'Agent Email',
26
+ description: 'The email address you use to login to Zendesk',
27
+ required: true,
28
+ }),
29
+ token: framework_1.Property.ShortText({
30
+ displayName: 'Token',
31
+ description: 'The API token you can generate in Zendesk',
32
+ required: true,
33
+ }),
34
+ subdomain: framework_1.Property.ShortText({
35
+ displayName: 'Organization (e.g activepieceshelp)',
36
+ description: 'The subdomain of your Zendesk instance',
37
+ required: true,
38
+ }),
39
+ },
40
+ required: true,
41
+ }),
42
+ view_id: framework_1.Property.Dropdown({
43
+ displayName: 'View',
44
+ description: 'The view to monitor for new tickets',
45
+ refreshers: ['authentication'],
46
+ required: true,
47
+ options: (value) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
48
+ const authentication = value['authentication'];
49
+ if (!(authentication === null || authentication === void 0 ? void 0 : authentication['email']) || !(authentication === null || authentication === void 0 ? void 0 : authentication['subdomain']) || !(authentication === null || authentication === void 0 ? void 0 : authentication['token'])) {
50
+ return {
51
+ placeholder: 'Fill your authentication first',
52
+ disabled: true,
53
+ options: [],
54
+ };
55
+ }
56
+ const response = yield framework_1.httpClient.sendRequest({
57
+ url: `https://${authentication.subdomain}.zendesk.com/api/v2/views.json`,
58
+ method: framework_1.HttpMethod.GET,
59
+ authentication: {
60
+ type: framework_1.AuthenticationType.BASIC,
61
+ username: authentication.email + "/token",
62
+ password: authentication.token,
63
+ }
64
+ });
65
+ return {
66
+ placeholder: 'Select a view',
67
+ options: response.body.views.map((view) => ({
68
+ label: view.title,
69
+ value: view.id,
70
+ }))
71
+ };
72
+ })
73
+ })
74
+ },
75
+ sampleData: {
76
+ "url": "https://activepieceshelp.zendesk.com/api/v2/tickets/5.json",
77
+ "id": 5,
78
+ "external_id": null,
79
+ "via": {
80
+ "channel": "web",
81
+ "source": {
82
+ "from": {},
83
+ "to": {},
84
+ "rel": null
85
+ }
86
+ },
87
+ "created_at": "2023-03-25T02:39:41Z",
88
+ "updated_at": "2023-03-25T02:39:41Z",
89
+ "type": null,
90
+ "subject": "Subject",
91
+ "raw_subject": "Raw Subject",
92
+ "description": "Description",
93
+ "priority": null,
94
+ "status": "open",
95
+ "recipient": null,
96
+ "requester_id": 8193592318236,
97
+ "submitter_id": 8193592318236,
98
+ "assignee_id": 8193592318236,
99
+ "organization_id": 8193599387420,
100
+ "group_id": 8193569448092,
101
+ "collaborator_ids": [],
102
+ "follower_ids": [],
103
+ "email_cc_ids": [],
104
+ "forum_topic_id": null,
105
+ "problem_id": null,
106
+ "has_incidents": false,
107
+ "is_public": true,
108
+ "due_at": null,
109
+ "tags": [],
110
+ "custom_fields": [],
111
+ "satisfaction_rating": null,
112
+ "sharing_agreement_ids": [],
113
+ "custom_status_id": 8193592472348,
114
+ "fields": [],
115
+ "followup_ids": [],
116
+ "ticket_form_id": 8193569410076,
117
+ "brand_id": 8193583542300,
118
+ "allow_channelback": false,
119
+ "allow_attachments": true,
120
+ "from_messaging_channel": false
121
+ },
122
+ onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
123
+ yield framework_1.pollingHelper.onEnable(polling, {
124
+ store: context.store,
125
+ propsValue: context.propsValue,
126
+ });
127
+ }),
128
+ onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
129
+ yield framework_1.pollingHelper.onDisable(polling, {
130
+ store: context.store,
131
+ propsValue: context.propsValue,
132
+ });
133
+ }),
134
+ run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
135
+ return yield framework_1.pollingHelper.poll(polling, {
136
+ store: context.store,
137
+ propsValue: context.propsValue,
138
+ });
139
+ }),
140
+ test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
141
+ return yield framework_1.pollingHelper.poll(polling, {
142
+ store: context.store,
143
+ propsValue: context.propsValue,
144
+ });
145
+ })
146
+ });
147
+ const polling = {
148
+ strategy: framework_1.DedupeStrategy.LAST_ITEM,
149
+ items: ({ propsValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
150
+ const items = yield getTickets(propsValue.authentication, propsValue.view_id);
151
+ return items.map((item) => ({
152
+ id: item.id,
153
+ data: item,
154
+ }));
155
+ })
156
+ };
157
+ function getTickets(authentication, view_id) {
158
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
159
+ const { email, token, subdomain } = authentication;
160
+ const response = yield framework_1.httpClient.sendRequest({
161
+ url: `https://${subdomain}.zendesk.com/api/v2/views/${view_id}/tickets.json?sort_order=desc&sort_by=created_at&per_page=200`,
162
+ method: framework_1.HttpMethod.GET,
163
+ authentication: {
164
+ type: framework_1.AuthenticationType.BASIC,
165
+ username: email + "/token",
166
+ password: token,
167
+ }
168
+ });
169
+ return response.body.tickets;
170
+ });
171
+ }
172
+ //# sourceMappingURL=new-ticket-in-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-ticket-in-view.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/zendesk/src/lib/trigger/new-ticket-in-view.ts"],"names":[],"mappings":";;;;AAAA,iDAAuD;AACvD,uDAAsJ;AAEtJ,MAAM,gBAAgB,GAAG;;;;;;CAMxB,CAAA;AAEY,QAAA,eAAe,GAAG,IAAA,yBAAa,EAAC;IACzC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,iDAAiD;IAC9D,IAAI,EAAE,wBAAe,CAAC,OAAO;IAC7B,KAAK,EAAE;QACH,cAAc,EAAE,oBAAQ,CAAC,UAAU,CAAC;YAChC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,gBAAgB;YAC7B,KAAK,EAAE;gBACH,KAAK,EAAE,oBAAQ,CAAC,SAAS,CAAC;oBACtB,WAAW,EAAE,aAAa;oBAC1B,WAAW,EAAE,+CAA+C;oBAC5D,QAAQ,EAAE,IAAI;iBACjB,CAAC;gBACF,KAAK,EAAE,oBAAQ,CAAC,SAAS,CAAC;oBACtB,WAAW,EAAE,OAAO;oBACpB,WAAW,EAAE,2CAA2C;oBACxD,QAAQ,EAAE,IAAI;iBACjB,CAAC;gBACF,SAAS,EAAE,oBAAQ,CAAC,SAAS,CAAC;oBAC1B,WAAW,EAAE,qCAAqC;oBAClD,WAAW,EAAE,wCAAwC;oBACrD,QAAQ,EAAE,IAAI;iBACjB,CAAC;aACL;YACD,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,OAAO,EAAE,oBAAQ,CAAC,QAAQ,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,qCAA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