@activepieces/piece-gorgias 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/package.json +16 -0
- package/src/index.d.ts +6 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +44 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-message.d.ts +18 -0
- package/src/lib/actions/create-message.d.ts.map +1 -0
- package/src/lib/actions/create-message.js +108 -0
- package/src/lib/actions/create-message.js.map +1 -0
- package/src/lib/actions/create-ticket.d.ts +13 -0
- package/src/lib/actions/create-ticket.d.ts.map +1 -0
- package/src/lib/actions/create-ticket.js +81 -0
- package/src/lib/actions/create-ticket.js.map +1 -0
- package/src/lib/actions/get-customer.d.ts +9 -0
- package/src/lib/actions/get-customer.d.ts.map +1 -0
- package/src/lib/actions/get-customer.js +47 -0
- package/src/lib/actions/get-customer.js.map +1 -0
- package/src/lib/actions/get-ticket.d.ts +8 -0
- package/src/lib/actions/get-ticket.d.ts.map +1 -0
- package/src/lib/actions/get-ticket.js +30 -0
- package/src/lib/actions/get-ticket.js.map +1 -0
- package/src/lib/actions/list-tickets.d.ts +11 -0
- package/src/lib/actions/list-tickets.d.ts.map +1 -0
- package/src/lib/actions/list-tickets.js +54 -0
- package/src/lib/actions/list-tickets.js.map +1 -0
- package/src/lib/actions/update-ticket.d.ts +17 -0
- package/src/lib/actions/update-ticket.d.ts.map +1 -0
- package/src/lib/actions/update-ticket.js +88 -0
- package/src/lib/actions/update-ticket.js.map +1 -0
- package/src/lib/auth.d.ts +10 -0
- package/src/lib/auth.d.ts.map +1 -0
- package/src/lib/auth.js +73 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +31 -0
- package/src/lib/common/client.d.ts.map +1 -0
- package/src/lib/common/client.js +59 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/constants.d.ts +19 -0
- package/src/lib/common/constants.d.ts.map +1 -0
- package/src/lib/common/constants.js +29 -0
- package/src/lib/common/constants.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-gorgias",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./src/index.js",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@activepieces/pieces-common": "0.12.3",
|
|
8
|
+
"@activepieces/pieces-framework": "0.28.2",
|
|
9
|
+
"@activepieces/shared": "0.78.1",
|
|
10
|
+
"tslib": "2.6.2"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
14
|
+
"lint": "eslint 'src/**/*.ts'"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const gorgias: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
domain: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,OAAO;;;;GA2BlB,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gorgias = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const shared_1 = require("@activepieces/shared");
|
|
8
|
+
const buffer_1 = require("buffer");
|
|
9
|
+
const auth_1 = require("./lib/auth");
|
|
10
|
+
const create_ticket_1 = require("./lib/actions/create-ticket");
|
|
11
|
+
const get_ticket_1 = require("./lib/actions/get-ticket");
|
|
12
|
+
const update_ticket_1 = require("./lib/actions/update-ticket");
|
|
13
|
+
const list_tickets_1 = require("./lib/actions/list-tickets");
|
|
14
|
+
const create_message_1 = require("./lib/actions/create-message");
|
|
15
|
+
const get_customer_1 = require("./lib/actions/get-customer");
|
|
16
|
+
exports.gorgias = (0, pieces_framework_1.createPiece)({
|
|
17
|
+
displayName: 'Gorgias',
|
|
18
|
+
description: 'Helpdesk platform for ecommerce teams to manage tickets, customers, and support conversations.',
|
|
19
|
+
minimumSupportedRelease: '0.36.1',
|
|
20
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/gorgias.png',
|
|
21
|
+
categories: [shared_1.PieceCategory.CUSTOMER_SUPPORT],
|
|
22
|
+
auth: auth_1.gorgiasAuth,
|
|
23
|
+
authors: ['Harmatta'],
|
|
24
|
+
actions: [
|
|
25
|
+
create_ticket_1.createTicketAction,
|
|
26
|
+
get_ticket_1.getTicketAction,
|
|
27
|
+
update_ticket_1.updateTicketAction,
|
|
28
|
+
list_tickets_1.listTicketsAction,
|
|
29
|
+
create_message_1.createMessageAction,
|
|
30
|
+
get_customer_1.getCustomerAction,
|
|
31
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
32
|
+
baseUrl: (auth) => { var _a; return (0, auth_1.getGorgiasBaseUrl)((_a = auth === null || auth === void 0 ? void 0 : auth.props.domain) !== null && _a !== void 0 ? _a : ''); },
|
|
33
|
+
auth: auth_1.gorgiasAuth,
|
|
34
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
const credentials = `${auth.props.email}:${auth.props.api_key}`;
|
|
36
|
+
return {
|
|
37
|
+
Authorization: `Basic ${buffer_1.Buffer.from(credentials).toString('base64')}`,
|
|
38
|
+
};
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
triggers: [],
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAA6D;AAC7D,iDAAqD;AACrD,mCAAgC;AAEhC,qCAA4D;AAC5D,+DAAiE;AACjE,yDAA2D;AAC3D,+DAAiE;AACjE,6DAA+D;AAC/D,iEAAmE;AACnE,6DAA+D;AAElD,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,gGAAgG;IAC7G,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,UAAU,EAAE,CAAC,sBAAa,CAAC,gBAAgB,CAAC;IAC5C,IAAI,EAAE,kBAAW;IACjB,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,OAAO,EAAE;QACP,kCAAkB;QAClB,4BAAe;QACf,kCAAkB;QAClB,gCAAiB;QACjB,oCAAmB;QACnB,gCAAiB;QACjB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,IAAA,wBAAiB,EAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAA,EAAA;YAC9D,IAAI,EAAE,kBAAW;YACjB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,MAAM,WAAW,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBAChE,OAAO;oBACL,aAAa,EAAE,SAAS,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;iBACtE,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const createMessageAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
domain: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
ticketId: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
7
|
+
fromAgent: import("@activepieces/pieces-framework").CheckboxProperty<true>;
|
|
8
|
+
senderId: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
9
|
+
receiverId: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
10
|
+
fromAddress: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
11
|
+
toAddress: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
12
|
+
message: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
13
|
+
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
channel: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
15
|
+
via: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
16
|
+
sentDatetime: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=create-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-message.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/create-message.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;EA4G9B,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMessageAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const constants_1 = require("../common/constants");
|
|
10
|
+
exports.createMessageAction = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.gorgiasAuth,
|
|
12
|
+
name: 'create_gorgias_ticket_message',
|
|
13
|
+
displayName: 'Create Message',
|
|
14
|
+
description: 'Create a reply or message on an existing Gorgias ticket.',
|
|
15
|
+
props: {
|
|
16
|
+
ticketId: pieces_framework_1.Property.Number({
|
|
17
|
+
displayName: 'Ticket ID',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
fromAgent: pieces_framework_1.Property.Checkbox({
|
|
21
|
+
displayName: 'From Agent',
|
|
22
|
+
description: 'True when the sender is an agent/user; false when the sender is a customer.',
|
|
23
|
+
required: true,
|
|
24
|
+
defaultValue: true,
|
|
25
|
+
}),
|
|
26
|
+
senderId: pieces_framework_1.Property.Number({
|
|
27
|
+
displayName: 'Sender ID',
|
|
28
|
+
description: 'User ID when From Agent is true, otherwise Customer ID.',
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
|
+
receiverId: pieces_framework_1.Property.Number({
|
|
32
|
+
displayName: 'Receiver ID',
|
|
33
|
+
description: 'Customer ID when From Agent is true, otherwise User ID.',
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
fromAddress: pieces_framework_1.Property.ShortText({
|
|
37
|
+
displayName: 'From Address',
|
|
38
|
+
description: 'Email or channel address of the sender.',
|
|
39
|
+
required: true,
|
|
40
|
+
}),
|
|
41
|
+
toAddress: pieces_framework_1.Property.ShortText({
|
|
42
|
+
displayName: 'To Address',
|
|
43
|
+
description: 'Email or channel address of the receiver.',
|
|
44
|
+
required: true,
|
|
45
|
+
}),
|
|
46
|
+
message: pieces_framework_1.Property.LongText({
|
|
47
|
+
displayName: 'Message',
|
|
48
|
+
description: 'Message body. HTML is accepted by the API.',
|
|
49
|
+
required: true,
|
|
50
|
+
}),
|
|
51
|
+
subject: pieces_framework_1.Property.ShortText({
|
|
52
|
+
displayName: 'Subject',
|
|
53
|
+
required: false,
|
|
54
|
+
}),
|
|
55
|
+
channel: pieces_framework_1.Property.StaticDropdown({
|
|
56
|
+
displayName: 'Channel',
|
|
57
|
+
required: true,
|
|
58
|
+
options: constants_1.GORGIAS_CHANNEL_OPTIONS,
|
|
59
|
+
defaultValue: 'email',
|
|
60
|
+
}),
|
|
61
|
+
via: pieces_framework_1.Property.StaticDropdown({
|
|
62
|
+
displayName: 'Via',
|
|
63
|
+
required: true,
|
|
64
|
+
options: constants_1.GORGIAS_VIA_OPTIONS,
|
|
65
|
+
defaultValue: 'api',
|
|
66
|
+
}),
|
|
67
|
+
sentDatetime: pieces_framework_1.Property.ShortText({
|
|
68
|
+
displayName: 'Sent Datetime',
|
|
69
|
+
description: 'Optional ISO-8601 timestamp for when the message was sent.',
|
|
70
|
+
required: false,
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
run(context) {
|
|
74
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const { ticketId, fromAgent, senderId, receiverId, fromAddress, toAddress, message, subject, channel, via, sentDatetime, } = context.propsValue;
|
|
76
|
+
return yield (0, client_1.gorgiasApiCall)({
|
|
77
|
+
auth: context.auth,
|
|
78
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
79
|
+
resourceUri: `/tickets/${ticketId}/messages`,
|
|
80
|
+
body: {
|
|
81
|
+
channel,
|
|
82
|
+
body_html: message,
|
|
83
|
+
via,
|
|
84
|
+
subject,
|
|
85
|
+
from_agent: fromAgent,
|
|
86
|
+
sent_datetime: sentDatetime,
|
|
87
|
+
sender: {
|
|
88
|
+
id: senderId,
|
|
89
|
+
},
|
|
90
|
+
receiver: {
|
|
91
|
+
id: receiverId,
|
|
92
|
+
},
|
|
93
|
+
source: {
|
|
94
|
+
from: {
|
|
95
|
+
address: fromAddress,
|
|
96
|
+
},
|
|
97
|
+
to: [
|
|
98
|
+
{
|
|
99
|
+
address: toAddress,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=create-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-message.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-message.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAAsC;AACtC,6CAAkD;AAClD,mDAG6B;AAEhB,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,+BAA+B;IACrC,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,0DAA0D;IACvE,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC3B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;SACnB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC1B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,yDAA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AI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,WAAW,EAAE,YAAY,QAAQ,WAAW;gBAC5C,IAAI,EAAE;oBACJ,OAAO;oBACP,SAAS,EAAE,OAAO;oBAClB,GAAG;oBACH,OAAO;oBACP,UAAU,EAAE,SAAS;oBACrB,aAAa,EAAE,YAAY;oBAC3B,MAAM,EAAE;wBACN,EAAE,EAAE,QAAQ;qBACb;oBACD,QAAQ,EAAE;wBACR,EAAE,EAAE,UAAU;qBACf;oBACD,MAAM,EAAE;wBACN,IAAI,EAAE;4BACJ,OAAO,EAAE,WAAW;yBACrB;wBACD,EAAE,EAAE;4BACF;gCACE,OAAO,EAAE,SAAS;6BACnB;yBACF;qBACF;iBACF;aACF,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const createTicketAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
domain: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
fromAddress: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
toAddress: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
subject: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
message: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
10
|
+
channel: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
11
|
+
via: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=create-ticket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-ticket.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/create-ticket.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB;;;;;;;;;;;EAsE7B,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTicketAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const constants_1 = require("../common/constants");
|
|
10
|
+
exports.createTicketAction = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.gorgiasAuth,
|
|
12
|
+
name: 'create_gorgias_ticket',
|
|
13
|
+
displayName: 'Create Ticket',
|
|
14
|
+
description: 'Create a new Gorgias ticket with an initial message.',
|
|
15
|
+
props: {
|
|
16
|
+
fromAddress: pieces_framework_1.Property.ShortText({
|
|
17
|
+
displayName: 'From Address',
|
|
18
|
+
description: 'The sender address for the initial message, typically the customer email.',
|
|
19
|
+
required: true,
|
|
20
|
+
}),
|
|
21
|
+
toAddress: pieces_framework_1.Property.ShortText({
|
|
22
|
+
displayName: 'To Address',
|
|
23
|
+
description: 'The recipient address for the initial message.',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
subject: pieces_framework_1.Property.ShortText({
|
|
27
|
+
displayName: 'Subject',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
message: pieces_framework_1.Property.LongText({
|
|
31
|
+
displayName: 'Message',
|
|
32
|
+
description: 'Initial ticket message. HTML is accepted by the API.',
|
|
33
|
+
required: true,
|
|
34
|
+
}),
|
|
35
|
+
channel: pieces_framework_1.Property.StaticDropdown({
|
|
36
|
+
displayName: 'Channel',
|
|
37
|
+
required: true,
|
|
38
|
+
options: constants_1.GORGIAS_CHANNEL_OPTIONS,
|
|
39
|
+
defaultValue: 'email',
|
|
40
|
+
}),
|
|
41
|
+
via: pieces_framework_1.Property.StaticDropdown({
|
|
42
|
+
displayName: 'Via',
|
|
43
|
+
description: 'How the message reached Gorgias.',
|
|
44
|
+
required: true,
|
|
45
|
+
options: constants_1.GORGIAS_VIA_OPTIONS,
|
|
46
|
+
defaultValue: 'api',
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
run(context) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { fromAddress, toAddress, subject, message, channel, via } = context.propsValue;
|
|
52
|
+
return yield (0, client_1.gorgiasApiCall)({
|
|
53
|
+
auth: context.auth,
|
|
54
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
55
|
+
resourceUri: '/tickets',
|
|
56
|
+
body: {
|
|
57
|
+
messages: [
|
|
58
|
+
{
|
|
59
|
+
from_agent: false,
|
|
60
|
+
subject,
|
|
61
|
+
body_html: message,
|
|
62
|
+
channel,
|
|
63
|
+
via,
|
|
64
|
+
source: {
|
|
65
|
+
from: {
|
|
66
|
+
address: fromAddress,
|
|
67
|
+
},
|
|
68
|
+
to: [
|
|
69
|
+
{
|
|
70
|
+
address: toAddress,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=create-ticket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-ticket.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-ticket.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAAsC;AACtC,6CAAkD;AAClD,mDAG6B;AAEhB,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,kBA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ACvB,IAAI,EAAE;oBACJ,QAAQ,EAAE;wBACR;4BACE,UAAU,EAAE,KAAK;4BACjB,OAAO;4BACP,SAAS,EAAE,OAAO;4BAClB,OAAO;4BACP,GAAG;4BACH,MAAM,EAAE;gCACN,IAAI,EAAE;oCACJ,OAAO,EAAE,WAAW;iCACrB;gCACD,EAAE,EAAE;oCACF;wCACE,OAAO,EAAE,SAAS;qCACnB;iCACF;6BACF;yBACF;qBACF;iBACF;aACF,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const getCustomerAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
domain: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
customerId: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
7
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=get-customer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-customer.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-customer.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB;;;;;;;EA2C5B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomerAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.getCustomerAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.gorgiasAuth,
|
|
11
|
+
name: 'get_gorgias_customer',
|
|
12
|
+
displayName: 'Get Customer',
|
|
13
|
+
description: 'Retrieve a Gorgias customer by ID or find one by email.',
|
|
14
|
+
props: {
|
|
15
|
+
customerId: pieces_framework_1.Property.Number({
|
|
16
|
+
displayName: 'Customer ID',
|
|
17
|
+
description: 'Use this when you already know the customer ID.',
|
|
18
|
+
required: false,
|
|
19
|
+
}),
|
|
20
|
+
email: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Email',
|
|
22
|
+
description: 'If Customer ID is not provided, search customers by email using Gorgias server-side filtering.',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
run(context) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const { customerId, email } = context.propsValue;
|
|
29
|
+
if (customerId) {
|
|
30
|
+
return yield (0, client_1.gorgiasApiCall)({
|
|
31
|
+
auth: context.auth,
|
|
32
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
33
|
+
resourceUri: `/customers/${customerId}`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (!email) {
|
|
37
|
+
throw new Error('Provide either Customer ID or Email.');
|
|
38
|
+
}
|
|
39
|
+
const customer = yield (0, client_1.findCustomerByEmail)(context.auth, email);
|
|
40
|
+
if (!customer) {
|
|
41
|
+
throw new Error(`No customer found for email: ${email}`);
|
|
42
|
+
}
|
|
43
|
+
return customer;
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=get-customer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-customer.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-customer.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAAsC;AACtC,6CAAuE;AAE1D,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,yDAAyD;IACtE,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC1B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,iDAAiD;YAC9D,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,gGAAgG;YAC7G,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEjD,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,MAAM,IAAA,uBAAc,EAAC;oBAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,WAAW,EAAE,cAAc,UAAU,EAAE;iBACxC,CAAC,CAAC;YACL,CAAC;YAED,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;YAC1D,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAmB,EACxC,OAAO,CAAC,IAAI,EACZ,KAAK,CACN,CAAC;YAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,EAAE,CAAC,CAAC;YAC3D,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const getTicketAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
domain: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
ticketId: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=get-ticket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ticket.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-ticket.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe;;;;;;EAkB1B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTicketAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.getTicketAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.gorgiasAuth,
|
|
11
|
+
name: 'get_gorgias_ticket',
|
|
12
|
+
displayName: 'Get Ticket',
|
|
13
|
+
description: 'Retrieve a Gorgias ticket by ID.',
|
|
14
|
+
props: {
|
|
15
|
+
ticketId: pieces_framework_1.Property.Number({
|
|
16
|
+
displayName: 'Ticket ID',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
run(context) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return yield (0, client_1.gorgiasApiCall)({
|
|
23
|
+
auth: context.auth,
|
|
24
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
25
|
+
resourceUri: `/tickets/${context.propsValue.ticketId}`,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=get-ticket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ticket.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-ticket.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAAsC;AACtC,6CAAkD;AAErC,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,kCAAkC;IAC/C,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,MAAM,IAAA,uBAAc,EAAC;gBAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,YAAY,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE;aACvD,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const listTicketsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
domain: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
customerId: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
7
|
+
cursor: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
limit: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
9
|
+
orderBy: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=list-tickets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-tickets.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-tickets.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB;;;;;;;;;EA0C5B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listTicketsAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.listTicketsAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.gorgiasAuth,
|
|
11
|
+
name: 'list_gorgias_tickets',
|
|
12
|
+
displayName: 'List Tickets',
|
|
13
|
+
description: 'List Gorgias tickets with cursor-based pagination support.',
|
|
14
|
+
props: {
|
|
15
|
+
customerId: pieces_framework_1.Property.Number({
|
|
16
|
+
displayName: 'Customer ID',
|
|
17
|
+
description: 'Optional customer ID to filter tickets for one customer.',
|
|
18
|
+
required: false,
|
|
19
|
+
}),
|
|
20
|
+
cursor: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Cursor',
|
|
22
|
+
description: 'Optional cursor returned by a previous list response.',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
limit: pieces_framework_1.Property.Number({
|
|
26
|
+
displayName: 'Limit',
|
|
27
|
+
description: 'Maximum number of tickets to return in this page. Defaults to 25.',
|
|
28
|
+
required: false,
|
|
29
|
+
defaultValue: 25,
|
|
30
|
+
}),
|
|
31
|
+
orderBy: pieces_framework_1.Property.ShortText({
|
|
32
|
+
displayName: 'Order By',
|
|
33
|
+
description: 'Optional ordering, for example `created_datetime:desc`.',
|
|
34
|
+
required: false,
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
run(context) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const { customerId, cursor, limit, orderBy } = context.propsValue;
|
|
40
|
+
return yield (0, client_1.gorgiasApiCall)({
|
|
41
|
+
auth: context.auth,
|
|
42
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
43
|
+
resourceUri: '/tickets',
|
|
44
|
+
query: {
|
|
45
|
+
customer_id: customerId,
|
|
46
|
+
cursor,
|
|
47
|
+
limit: limit !== null && limit !== void 0 ? limit : 25,
|
|
48
|
+
order_by: orderBy,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=list-tickets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-tickets.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-tickets.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAAsC;AACtC,6CAAuE;AAE1D,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,4DAA4D;IACzE,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC1B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,0DAA0D;YACvE,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,mEAAmE;YAChF,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,EAAE;SACjB,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAClE,OAAO,MAAM,IAAA,uBAAc,EAA+B;gBACxD,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,UAAU;gBACvB,KAAK,EAAE;oBACL,WAAW,EAAE,UAAU;oBACvB,MAAM;oBACN,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE;oBAClB,QAAQ,EAAE,OAAO;iBAClB;aACF,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const updateTicketAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
domain: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
ticketId: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
7
|
+
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
status: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
9
|
+
channel: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
10
|
+
customerId: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
11
|
+
customerEmail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
fromAgent: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
13
|
+
isUnread: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
14
|
+
spam: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
15
|
+
externalId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=update-ticket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-ticket.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/update-ticket.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAuF7B,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateTicketAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const constants_1 = require("../common/constants");
|
|
10
|
+
exports.updateTicketAction = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.gorgiasAuth,
|
|
12
|
+
name: 'update_gorgias_ticket',
|
|
13
|
+
displayName: 'Update Ticket',
|
|
14
|
+
description: 'Update a Gorgias ticket.',
|
|
15
|
+
props: {
|
|
16
|
+
ticketId: pieces_framework_1.Property.Number({
|
|
17
|
+
displayName: 'Ticket ID',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
subject: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Subject',
|
|
22
|
+
required: false,
|
|
23
|
+
}),
|
|
24
|
+
status: pieces_framework_1.Property.StaticDropdown({
|
|
25
|
+
displayName: 'Status',
|
|
26
|
+
required: false,
|
|
27
|
+
options: constants_1.GORGIAS_TICKET_STATUS_OPTIONS,
|
|
28
|
+
}),
|
|
29
|
+
channel: pieces_framework_1.Property.StaticDropdown({
|
|
30
|
+
displayName: 'Channel',
|
|
31
|
+
required: false,
|
|
32
|
+
options: constants_1.GORGIAS_CHANNEL_OPTIONS,
|
|
33
|
+
}),
|
|
34
|
+
customerId: pieces_framework_1.Property.Number({
|
|
35
|
+
displayName: 'Customer ID',
|
|
36
|
+
description: 'Optional customer ID to attach to the ticket.',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
customerEmail: pieces_framework_1.Property.ShortText({
|
|
40
|
+
displayName: 'Customer Email',
|
|
41
|
+
description: 'Optional customer email to attach alongside the customer ID.',
|
|
42
|
+
required: false,
|
|
43
|
+
}),
|
|
44
|
+
fromAgent: pieces_framework_1.Property.Checkbox({
|
|
45
|
+
displayName: 'From Agent',
|
|
46
|
+
description: 'Whether the first message of the ticket was sent by your company.',
|
|
47
|
+
required: false,
|
|
48
|
+
}),
|
|
49
|
+
isUnread: pieces_framework_1.Property.Checkbox({
|
|
50
|
+
displayName: 'Is Unread',
|
|
51
|
+
required: false,
|
|
52
|
+
}),
|
|
53
|
+
spam: pieces_framework_1.Property.Checkbox({
|
|
54
|
+
displayName: 'Spam',
|
|
55
|
+
required: false,
|
|
56
|
+
}),
|
|
57
|
+
externalId: pieces_framework_1.Property.ShortText({
|
|
58
|
+
displayName: 'External ID',
|
|
59
|
+
required: false,
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
run(context) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const { ticketId, subject, status, channel, customerId, customerEmail, fromAgent, isUnread, spam, externalId, } = context.propsValue;
|
|
65
|
+
return yield (0, client_1.gorgiasApiCall)({
|
|
66
|
+
auth: context.auth,
|
|
67
|
+
method: pieces_common_1.HttpMethod.PUT,
|
|
68
|
+
resourceUri: `/tickets/${ticketId}`,
|
|
69
|
+
body: {
|
|
70
|
+
subject,
|
|
71
|
+
status,
|
|
72
|
+
channel,
|
|
73
|
+
external_id: externalId,
|
|
74
|
+
from_agent: fromAgent,
|
|
75
|
+
is_unread: isUnread,
|
|
76
|
+
spam,
|
|
77
|
+
customer: customerId
|
|
78
|
+
? {
|
|
79
|
+
id: customerId,
|
|
80
|
+
email: customerEmail,
|
|
81
|
+
}
|
|
82
|
+
: undefined,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=update-ticket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-ticket.js","sourceRoot":"","sources":["../../../../src/lib/actions/update-ticket.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAAsC;AACtC,6CAAkD;AAClD,mDAG6B;AAEhB,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,0BAA0B;IACvC,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC9B,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,yCAA6B;SACvC,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC/B,WAAW,EAAE,SAAS;YACtB,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ACrB,SAAS,EAAE,QAAQ;oBACnB,IAAI;oBACJ,QAAQ,EAAE,UAAU;wBAClB,CAAC,CAAC;4BACE,EAAE,EAAE,UAAU;4BACd,KAAK,EAAE,aAAa;yBACrB;wBACH,CAAC,CAAC,SAAS;iBACd;aACF,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
|
|
2
|
+
export type GorgiasAuth = AppConnectionValueForAuthProperty<typeof gorgiasAuth>;
|
|
3
|
+
export declare function normalizeGorgiasDomain(input: string): string;
|
|
4
|
+
export declare function getGorgiasBaseUrl(domain: string): string;
|
|
5
|
+
export declare const gorgiasAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
domain: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAuB,MAAM,gCAAgC,CAAC;AAOxG,MAAM,MAAM,WAAW,GAAG,iCAAiC,CAAC,OAAO,WAAW,CAAC,CAAA;AAE/E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,eAAO,MAAM,WAAW;;;;EAkDtB,CAAC"}
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gorgiasAuth = void 0;
|
|
4
|
+
exports.normalizeGorgiasDomain = normalizeGorgiasDomain;
|
|
5
|
+
exports.getGorgiasBaseUrl = getGorgiasBaseUrl;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
function normalizeGorgiasDomain(input) {
|
|
10
|
+
return input
|
|
11
|
+
.trim()
|
|
12
|
+
.replace(/^https?:\/\//, '')
|
|
13
|
+
.replace(/\.gorgias\.com.*$/i, '')
|
|
14
|
+
.replace(/^www\./, '')
|
|
15
|
+
.replace(/\/$/, '');
|
|
16
|
+
}
|
|
17
|
+
function getGorgiasBaseUrl(domain) {
|
|
18
|
+
return `https://${normalizeGorgiasDomain(domain)}.gorgias.com/api`;
|
|
19
|
+
}
|
|
20
|
+
exports.gorgiasAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
21
|
+
displayName: 'Gorgias',
|
|
22
|
+
required: true,
|
|
23
|
+
description: `To connect your Gorgias account:
|
|
24
|
+
|
|
25
|
+
1. Copy your helpdesk subdomain (for example, \`acme\` from \`https://acme.gorgias.com\`).
|
|
26
|
+
2. In Gorgias, create or copy an API key.
|
|
27
|
+
3. Use the email address associated with that API key.
|
|
28
|
+
|
|
29
|
+
Authentication uses HTTP Basic auth with \`email:api_key\`.`,
|
|
30
|
+
props: {
|
|
31
|
+
domain: pieces_framework_1.Property.ShortText({
|
|
32
|
+
displayName: 'Helpdesk Domain',
|
|
33
|
+
description: 'Your Gorgias subdomain only, for example `acme` from https://acme.gorgias.com.',
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
email: pieces_framework_1.Property.ShortText({
|
|
37
|
+
displayName: 'Email Address',
|
|
38
|
+
description: 'The email address associated with your Gorgias API key.',
|
|
39
|
+
required: true,
|
|
40
|
+
}),
|
|
41
|
+
api_key: pieces_framework_1.PieceAuth.SecretText({
|
|
42
|
+
displayName: 'API Key',
|
|
43
|
+
description: 'Your Gorgias API key.',
|
|
44
|
+
required: true,
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
48
|
+
var _b, _c;
|
|
49
|
+
try {
|
|
50
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
51
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
52
|
+
url: `${getGorgiasBaseUrl(auth.domain)}/tickets`,
|
|
53
|
+
authentication: {
|
|
54
|
+
type: pieces_common_1.AuthenticationType.BASIC,
|
|
55
|
+
username: auth.email,
|
|
56
|
+
password: auth.api_key,
|
|
57
|
+
},
|
|
58
|
+
queryParams: {
|
|
59
|
+
limit: '1',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
return { valid: true };
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
const err = error;
|
|
66
|
+
if (((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.status) === 401 || ((_c = err === null || err === void 0 ? void 0 : err.response) === null || _c === void 0 ? void 0 : _c.status) === 403) {
|
|
67
|
+
return { valid: false, error: 'Invalid domain, email, or API key.' };
|
|
68
|
+
}
|
|
69
|
+
return { valid: false, error: 'Could not reach the Gorgias API. Check your domain and network.' };
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AASA,wDAOC;AAED,8CAEC;;AApBD,qEAAwG;AACxG,+DAIqC;AAIrC,SAAgB,sBAAsB,CAAC,KAAa;IAClD,OAAO,KAAK;SACT,IAAI,EAAE;SACN,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,oBAAoB,EAAE,EAAE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EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,KAA2C,CAAC;YACxD,IAAI,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,0CAAE,MAAM,MAAK,GAAG,IAAI,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;gBACnE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC;YACvE,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,iEAAiE,EAAE,CAAC;QACpG,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HttpMessageBody, HttpMethod } from '@activepieces/pieces-common';
|
|
2
|
+
import { GorgiasAuth } from '../auth';
|
|
3
|
+
export type GorgiasPaginationMeta = {
|
|
4
|
+
prev_cursor?: string | null;
|
|
5
|
+
next_cursor?: string | null;
|
|
6
|
+
};
|
|
7
|
+
export type GorgiasListResponse<T> = {
|
|
8
|
+
data: T[];
|
|
9
|
+
object: string;
|
|
10
|
+
uri: string;
|
|
11
|
+
meta: GorgiasPaginationMeta;
|
|
12
|
+
};
|
|
13
|
+
export type GorgiasCustomer = {
|
|
14
|
+
id: number;
|
|
15
|
+
email?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
channels?: Array<{
|
|
18
|
+
address?: string;
|
|
19
|
+
}>;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
export type GorgiasRequestParams = {
|
|
23
|
+
auth: GorgiasAuth;
|
|
24
|
+
method: HttpMethod;
|
|
25
|
+
resourceUri: string;
|
|
26
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
27
|
+
body?: unknown;
|
|
28
|
+
};
|
|
29
|
+
export declare function gorgiasApiCall<T extends HttpMessageBody>({ auth, method, resourceUri, query, body, }: GorgiasRequestParams): Promise<T>;
|
|
30
|
+
export declare function findCustomerByEmail(auth: GorgiasAuth, email: string): Promise<GorgiasCustomer | null>;
|
|
31
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEf,UAAU,EAGX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAqB,MAAM,SAAS,CAAC;AAEzD,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IACnC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,qBAAqB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,wBAAsB,cAAc,CAAC,CAAC,SAAS,eAAe,EAAE,EAC9D,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,EACL,IAAI,GACL,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CA6BnC;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoBjC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gorgiasApiCall = gorgiasApiCall;
|
|
4
|
+
exports.findCustomerByEmail = findCustomerByEmail;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
function gorgiasApiCall(_a) {
|
|
9
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, method, resourceUri, query, body, }) {
|
|
10
|
+
const queryParams = {};
|
|
11
|
+
if (query) {
|
|
12
|
+
for (const [key, value] of Object.entries(query)) {
|
|
13
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
14
|
+
queryParams[key] = String(value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const request = {
|
|
19
|
+
method,
|
|
20
|
+
url: `${(0, auth_1.getGorgiasBaseUrl)(auth.props.domain)}${resourceUri}`,
|
|
21
|
+
authentication: {
|
|
22
|
+
type: pieces_common_1.AuthenticationType.BASIC,
|
|
23
|
+
username: auth.props.email,
|
|
24
|
+
password: auth.props.api_key,
|
|
25
|
+
},
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: 'application/json',
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
},
|
|
30
|
+
queryParams,
|
|
31
|
+
body,
|
|
32
|
+
};
|
|
33
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
34
|
+
return response.body;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function findCustomerByEmail(auth, email) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
var _a;
|
|
40
|
+
const lowerEmail = email.trim().toLowerCase();
|
|
41
|
+
const response = yield gorgiasApiCall({
|
|
42
|
+
auth,
|
|
43
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
44
|
+
resourceUri: '/customers',
|
|
45
|
+
query: {
|
|
46
|
+
email: lowerEmail,
|
|
47
|
+
limit: 100,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
return (_a = response.data.find((customer) => {
|
|
51
|
+
const primaryEmail = typeof customer.email === 'string' ? customer.email.toLowerCase() : undefined;
|
|
52
|
+
const channelMatch = Array.isArray(customer.channels)
|
|
53
|
+
? customer.channels.some((channel) => { var _a; return ((_a = channel.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === lowerEmail; })
|
|
54
|
+
: false;
|
|
55
|
+
return primaryEmail === lowerEmail || channelMatch;
|
|
56
|
+
})) !== null && _a !== void 0 ? _a : null;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":";;AAsCA,wCAmCC;AAED,kDAuBC;;AAlGD,+DAOqC;AACrC,kCAAyD;AA8BzD,SAAsB,cAAc;iEAA4B,EAC9D,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,EACL,IAAI,GACiB;QACrB,MAAM,WAAW,GAAgB,EAAE,CAAC;QAEpC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CA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C,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YACnG,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACnD,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,WAAW,EAAE,MAAK,UAAU,CAAA,EAAA,CAAC;gBACpF,CAAC,CAAC,KAAK,CAAC;YACV,OAAO,YAAY,KAAK,UAAU,IAAI,YAAY,CAAC;QACrD,CAAC,CAAC,mCAAI,IAAI,CAAC;IACb,CAAC;CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const GORGIAS_CHANNEL_OPTIONS: {
|
|
2
|
+
options: {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
|
+
export declare const GORGIAS_VIA_OPTIONS: {
|
|
8
|
+
options: {
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
export declare const GORGIAS_TICKET_STATUS_OPTIONS: {
|
|
14
|
+
options: {
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB;;;;;CAUnC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;CAO/B,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;CAKzC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GORGIAS_TICKET_STATUS_OPTIONS = exports.GORGIAS_VIA_OPTIONS = exports.GORGIAS_CHANNEL_OPTIONS = void 0;
|
|
4
|
+
exports.GORGIAS_CHANNEL_OPTIONS = {
|
|
5
|
+
options: [
|
|
6
|
+
{ label: 'Email', value: 'email' },
|
|
7
|
+
{ label: 'SMS', value: 'sms' },
|
|
8
|
+
{ label: 'Chat', value: 'chat' },
|
|
9
|
+
{ label: 'Facebook', value: 'facebook' },
|
|
10
|
+
{ label: 'Instagram', value: 'instagram' },
|
|
11
|
+
{ label: 'Internal Note', value: 'internal-note' },
|
|
12
|
+
{ label: 'Phone', value: 'phone' },
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
exports.GORGIAS_VIA_OPTIONS = {
|
|
16
|
+
options: [
|
|
17
|
+
{ label: 'Help Center', value: 'help-center' },
|
|
18
|
+
{ label: 'API', value: 'api' },
|
|
19
|
+
{ label: 'Rule', value: 'rule' },
|
|
20
|
+
{ label: 'Manual', value: 'manual' },
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
exports.GORGIAS_TICKET_STATUS_OPTIONS = {
|
|
24
|
+
options: [
|
|
25
|
+
{ label: 'Open', value: 'open' },
|
|
26
|
+
{ label: 'Closed', value: 'closed' },
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/lib/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG;IACrC,OAAO,EAAE;QACP,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;QAClC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;QAC9B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;QAChC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;QACxC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;QAC1C,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,EAAE;QAClD,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;KACnC;CACF,CAAC;AAEW,QAAA,mBAAmB,GAAG;IACjC,OAAO,EAAE;QACP,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;QAC9C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;QAC9B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;QAChC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;KACrC;CACF,CAAC;AAEW,QAAA,6BAA6B,GAAG;IAC3C,OAAO,EAAE;QACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;QAChC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;KACrC;CACF,CAAC"}
|