n8n-nodes-getcourse 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.md +38 -0
- package/README.md +359 -0
- package/dist/credentials/GetCourseApi.credentials.d.ts +10 -0
- package/dist/credentials/GetCourseApi.credentials.js +58 -0
- package/dist/credentials/GetCourseApi.credentials.js.map +1 -0
- package/dist/credentials/GetCourseTechApi.credentials.d.ts +11 -0
- package/dist/credentials/GetCourseTechApi.credentials.js +63 -0
- package/dist/credentials/GetCourseTechApi.credentials.js.map +1 -0
- package/dist/credentials/accountAddress.d.ts +11 -0
- package/dist/credentials/accountAddress.js +116 -0
- package/dist/credentials/accountAddress.js.map +1 -0
- package/dist/icons/getcourse.dark.svg +15 -0
- package/dist/icons/getcourse.svg +11 -0
- package/dist/nodes/GetCourse/GetCourse.node.d.ts +9 -0
- package/dist/nodes/GetCourse/GetCourse.node.js +48 -0
- package/dist/nodes/GetCourse/GetCourse.node.js.map +1 -0
- package/dist/nodes/GetCourse/GetCourse.node.json +40 -0
- package/dist/nodes/GetCourse/v1/actions/call/index.d.ts +3 -0
- package/dist/nodes/GetCourse/v1/actions/call/index.js +98 -0
- package/dist/nodes/GetCourse/v1/actions/call/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/deal/description.d.ts +2 -0
- package/dist/nodes/GetCourse/v1/actions/deal/description.js +261 -0
- package/dist/nodes/GetCourse/v1/actions/deal/description.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/deal/execute.d.ts +2 -0
- package/dist/nodes/GetCourse/v1/actions/deal/execute.js +181 -0
- package/dist/nodes/GetCourse/v1/actions/deal/execute.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/deal/index.d.ts +2 -0
- package/dist/nodes/GetCourse/v1/actions/deal/index.js +8 -0
- package/dist/nodes/GetCourse/v1/actions/deal/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/dialog/index.d.ts +3 -0
- package/dist/nodes/GetCourse/v1/actions/dialog/index.js +262 -0
- package/dist/nodes/GetCourse/v1/actions/dialog/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/helpdesk/index.d.ts +3 -0
- package/dist/nodes/GetCourse/v1/actions/helpdesk/index.js +305 -0
- package/dist/nodes/GetCourse/v1/actions/helpdesk/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/index.d.ts +5 -0
- package/dist/nodes/GetCourse/v1/actions/index.js +119 -0
- package/dist/nodes/GetCourse/v1/actions/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/lesson/index.d.ts +3 -0
- package/dist/nodes/GetCourse/v1/actions/lesson/index.js +180 -0
- package/dist/nodes/GetCourse/v1/actions/lesson/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/offer/index.d.ts +3 -0
- package/dist/nodes/GetCourse/v1/actions/offer/index.js +98 -0
- package/dist/nodes/GetCourse/v1/actions/offer/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/school/index.d.ts +3 -0
- package/dist/nodes/GetCourse/v1/actions/school/index.js +139 -0
- package/dist/nodes/GetCourse/v1/actions/school/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/user/description.d.ts +2 -0
- package/dist/nodes/GetCourse/v1/actions/user/description.js +499 -0
- package/dist/nodes/GetCourse/v1/actions/user/description.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/user/execute.d.ts +2 -0
- package/dist/nodes/GetCourse/v1/actions/user/execute.js +270 -0
- package/dist/nodes/GetCourse/v1/actions/user/execute.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/user/index.d.ts +2 -0
- package/dist/nodes/GetCourse/v1/actions/user/index.js +8 -0
- package/dist/nodes/GetCourse/v1/actions/user/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/webhook/index.d.ts +4 -0
- package/dist/nodes/GetCourse/v1/actions/webhook/index.js +179 -0
- package/dist/nodes/GetCourse/v1/actions/webhook/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/actions/webinar/index.d.ts +3 -0
- package/dist/nodes/GetCourse/v1/actions/webinar/index.js +376 -0
- package/dist/nodes/GetCourse/v1/actions/webinar/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/descriptions/common.d.ts +7 -0
- package/dist/nodes/GetCourse/v1/descriptions/common.js +142 -0
- package/dist/nodes/GetCourse/v1/descriptions/common.js.map +1 -0
- package/dist/nodes/GetCourse/v1/helpers/errors.d.ts +11 -0
- package/dist/nodes/GetCourse/v1/helpers/errors.js +90 -0
- package/dist/nodes/GetCourse/v1/helpers/errors.js.map +1 -0
- package/dist/nodes/GetCourse/v1/helpers/request.d.ts +7 -0
- package/dist/nodes/GetCourse/v1/helpers/request.js +79 -0
- package/dist/nodes/GetCourse/v1/helpers/request.js.map +1 -0
- package/dist/nodes/GetCourse/v1/methods/index.d.ts +2 -0
- package/dist/nodes/GetCourse/v1/methods/index.js +39 -0
- package/dist/nodes/GetCourse/v1/methods/index.js.map +1 -0
- package/dist/nodes/GetCourse/v1/methods/loadOptions.d.ts +7 -0
- package/dist/nodes/GetCourse/v1/methods/loadOptions.js +76 -0
- package/dist/nodes/GetCourse/v1/methods/loadOptions.js.map +1 -0
- package/dist/nodes/GetCourse/v1/transport/index.d.ts +18 -0
- package/dist/nodes/GetCourse/v1/transport/index.js +165 -0
- package/dist/nodes/GetCourse/v1/transport/index.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/GetCourseLegacy.node.d.ts +9 -0
- package/dist/nodes/GetCourseLegacy/GetCourseLegacy.node.js +48 -0
- package/dist/nodes/GetCourseLegacy/GetCourseLegacy.node.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/GetCourseLegacy.node.json +35 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/description.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/description.js +287 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/description.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/execute.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/execute.js +150 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/execute.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/index.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/index.js +8 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/deal/index.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/description.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/description.js +487 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/description.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/execute.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/execute.js +252 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/execute.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/index.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/index.js +8 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/export/index.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/field/index.d.ts +3 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/field/index.js +61 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/field/index.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/group/index.d.ts +3 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/group/index.js +42 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/group/index.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/index.d.ts +5 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/index.js +84 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/index.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/description.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/description.js +87 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/description.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/execute.d.ts +5 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/execute.js +129 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/execute.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/index.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/index.js +8 -0
- package/dist/nodes/GetCourseLegacy/v1/actions/user/index.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/descriptions/common.d.ts +14 -0
- package/dist/nodes/GetCourseLegacy/v1/descriptions/common.js +198 -0
- package/dist/nodes/GetCourseLegacy/v1/descriptions/common.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/descriptions/constants.d.ts +7 -0
- package/dist/nodes/GetCourseLegacy/v1/descriptions/constants.js +116 -0
- package/dist/nodes/GetCourseLegacy/v1/descriptions/constants.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/helpers/errors.d.ts +18 -0
- package/dist/nodes/GetCourseLegacy/v1/helpers/errors.js +141 -0
- package/dist/nodes/GetCourseLegacy/v1/helpers/errors.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/helpers/exportRows.d.ts +8 -0
- package/dist/nodes/GetCourseLegacy/v1/helpers/exportRows.js +100 -0
- package/dist/nodes/GetCourseLegacy/v1/helpers/exportRows.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/methods/index.d.ts +2 -0
- package/dist/nodes/GetCourseLegacy/v1/methods/index.js +39 -0
- package/dist/nodes/GetCourseLegacy/v1/methods/index.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/methods/loadOptions.d.ts +5 -0
- package/dist/nodes/GetCourseLegacy/v1/methods/loadOptions.js +92 -0
- package/dist/nodes/GetCourseLegacy/v1/methods/loadOptions.js.map +1 -0
- package/dist/nodes/GetCourseLegacy/v1/transport/index.d.ts +13 -0
- package/dist/nodes/GetCourseLegacy/v1/transport/index.js +204 -0
- package/dist/nodes/GetCourseLegacy/v1/transport/index.js.map +1 -0
- package/dist/nodes/GetCourseTrigger/GetCourseTrigger.node.d.ts +12 -0
- package/dist/nodes/GetCourseTrigger/GetCourseTrigger.node.js +339 -0
- package/dist/nodes/GetCourseTrigger/GetCourseTrigger.node.js.map +1 -0
- package/dist/nodes/GetCourseTrigger/GetCourseTrigger.node.json +32 -0
- package/dist/nodes/GetCourseTrigger/payload.d.ts +14 -0
- package/dist/nodes/GetCourseTrigger/payload.js +66 -0
- package/dist/nodes/GetCourseTrigger/payload.js.map +1 -0
- package/dist/utils/cache.d.ts +2 -0
- package/dist/utils/cache.js +27 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/dates.d.ts +3 -0
- package/dist/utils/dates.js +70 -0
- package/dist/utils/dates.js.map +1 -0
- package/dist/utils/events.d.ts +14 -0
- package/dist/utils/events.js +92 -0
- package/dist/utils/events.js.map +1 -0
- package/dist/utils/httpError.d.ts +4 -0
- package/dist/utils/httpError.js +46 -0
- package/dist/utils/httpError.js.map +1 -0
- package/dist/utils/query.d.ts +4 -0
- package/dist/utils/query.js +42 -0
- package/dist/utils/query.js.map +1 -0
- package/dist/utils/rateLimiter.d.ts +3 -0
- package/dist/utils/rateLimiter.js +44 -0
- package/dist/utils/rateLimiter.js.map +1 -0
- package/dist/utils/router.d.ts +8 -0
- package/dist/utils/router.js +40 -0
- package/dist/utils/router.js.map +1 -0
- package/index.js +0 -0
- package/package.json +68 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.description = void 0;
|
|
4
|
+
exports.execute = execute;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const request_1 = require("../../helpers/request");
|
|
7
|
+
const router_1 = require("../../../../../utils/router");
|
|
8
|
+
const transport_1 = require("../../transport");
|
|
9
|
+
const showFor = (operations) => ({
|
|
10
|
+
show: { resource: ['helpdesk'], operation: operations },
|
|
11
|
+
});
|
|
12
|
+
const showForAddress = (mode) => ({
|
|
13
|
+
show: { resource: ['helpdesk'], operation: ['addComment'], ticketAddressBy: [mode] },
|
|
14
|
+
});
|
|
15
|
+
const MAX_HISTORY = 1000;
|
|
16
|
+
const MAX_CLOSING_COMMENT = 255;
|
|
17
|
+
const ticketIdProperty = (displayOptions) => ({
|
|
18
|
+
displayName: 'Ticket ID',
|
|
19
|
+
name: 'ticketId',
|
|
20
|
+
type: 'string',
|
|
21
|
+
default: '',
|
|
22
|
+
required: true,
|
|
23
|
+
displayOptions,
|
|
24
|
+
description: 'ID тикета HelpDesk. The webhook field is called dialog_id here too (event_object_id 9), and otherwise only /user/get-helpdesk-dialogs lists tickets — an «Входящие» dialog ID is a separate ID space and must not be used here.',
|
|
25
|
+
});
|
|
26
|
+
const TRANSPORTS = [
|
|
27
|
+
{ name: 'Chatium', value: 6 },
|
|
28
|
+
{ name: 'Email', value: 1 },
|
|
29
|
+
{ name: 'Facebook', value: 4 },
|
|
30
|
+
{ name: 'Feedback Form (Форма обратной связи)', value: 11 },
|
|
31
|
+
{ name: 'GC Form (Форма GC)', value: 12 },
|
|
32
|
+
{ name: 'Instagram', value: 14 },
|
|
33
|
+
{ name: 'MAX', value: 13 },
|
|
34
|
+
{ name: 'Site (Сайт)', value: 0 },
|
|
35
|
+
{ name: 'SMS', value: 2 },
|
|
36
|
+
{ name: 'Telegram', value: 3 },
|
|
37
|
+
{ name: 'Viber', value: 8 },
|
|
38
|
+
{ name: 'VK', value: 5 },
|
|
39
|
+
{ name: 'WhatsApp', value: 7 },
|
|
40
|
+
];
|
|
41
|
+
exports.description = [
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Operation',
|
|
44
|
+
name: 'operation',
|
|
45
|
+
type: 'options',
|
|
46
|
+
noDataExpression: true,
|
|
47
|
+
default: 'addComment',
|
|
48
|
+
displayOptions: { show: { resource: ['helpdesk'] } },
|
|
49
|
+
options: [
|
|
50
|
+
{
|
|
51
|
+
name: 'Add Comment',
|
|
52
|
+
value: 'addComment',
|
|
53
|
+
action: 'Add a comment to a ticket',
|
|
54
|
+
description: 'Ответ клиенту в тикете HelpDesk от имени сотрудника. Sends the text over every channel selected and opens a ticket when only a client is named; attachments would need multipart/form-data, which this node does not cover.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'Add Note',
|
|
58
|
+
value: 'addNote',
|
|
59
|
+
action: 'Add an internal note to a ticket',
|
|
60
|
+
description: 'Внутренняя заметка к тикету, видимая только сотрудникам. Unlike the note on an «Входящие» dialog this one names its author and answers with the new note_id.',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'Change Department',
|
|
64
|
+
value: 'changeDepartment',
|
|
65
|
+
action: 'Change the department of a ticket',
|
|
66
|
+
description: 'Перевести тикет в другой отдел. Отделы are shared with «Входящие» — one list of queues serves both systems.',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'Close',
|
|
70
|
+
value: 'close',
|
|
71
|
+
action: 'Close a ticket',
|
|
72
|
+
description: 'Закрыть тикет с указанием причины. The reason is required and is what the HelpDesk reports are built from, so «без причины» is a real answer rather than a way to skip the field.',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'Get History',
|
|
76
|
+
value: 'getHistory',
|
|
77
|
+
action: 'Get the message history of a ticket',
|
|
78
|
+
description: 'Переписка тикета, в обратном хронологическом порядке. The endpoint has a message count but no offset, so only the newest messages are reachable and a long ticket cannot be walked back through.',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Address By',
|
|
84
|
+
name: 'ticketAddressBy',
|
|
85
|
+
type: 'options',
|
|
86
|
+
default: 'ticket',
|
|
87
|
+
displayOptions: showFor(['addComment']),
|
|
88
|
+
options: [
|
|
89
|
+
{
|
|
90
|
+
name: 'Client',
|
|
91
|
+
value: 'client',
|
|
92
|
+
description: 'Ответить клиенту. An open ticket is reused; where there is none the platform creates one and returns its ID.',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'Ticket ID',
|
|
96
|
+
value: 'ticket',
|
|
97
|
+
description: 'Ответить в конкретный тикет, which must already exist',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
description: 'Как адресовать сообщение. The API needs exactly one of the two but marks neither as required, so the node makes the choice rather than leaving it to the server.',
|
|
101
|
+
},
|
|
102
|
+
ticketIdProperty(showForAddress('ticket')),
|
|
103
|
+
{
|
|
104
|
+
displayName: 'Client ID',
|
|
105
|
+
name: 'recipientId',
|
|
106
|
+
type: 'string',
|
|
107
|
+
default: '',
|
|
108
|
+
required: true,
|
|
109
|
+
displayOptions: showForAddress('client'),
|
|
110
|
+
description: 'ID ученика — получателя сообщения. With no open ticket one is created, and the response echoes ticket_id, which is the only way to learn the ID of that new ticket.',
|
|
111
|
+
},
|
|
112
|
+
ticketIdProperty(showFor(['addNote', 'changeDepartment', 'close', 'getHistory'])),
|
|
113
|
+
{
|
|
114
|
+
displayName: 'Comment Text',
|
|
115
|
+
name: 'commentText',
|
|
116
|
+
type: 'string',
|
|
117
|
+
typeOptions: { rows: 4 },
|
|
118
|
+
default: '',
|
|
119
|
+
required: true,
|
|
120
|
+
displayOptions: showFor(['addComment']),
|
|
121
|
+
description: 'Текст ответа, который увидит клиент',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
displayName: 'Note Text',
|
|
125
|
+
name: 'text',
|
|
126
|
+
type: 'string',
|
|
127
|
+
typeOptions: { rows: 4 },
|
|
128
|
+
default: '',
|
|
129
|
+
required: true,
|
|
130
|
+
displayOptions: showFor(['addNote']),
|
|
131
|
+
description: 'Текст заметки — виден в аккаунте и никуда не отправляется',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Transports',
|
|
135
|
+
name: 'transport',
|
|
136
|
+
type: 'multiOptions',
|
|
137
|
+
default: [],
|
|
138
|
+
required: true,
|
|
139
|
+
displayOptions: showFor(['addComment']),
|
|
140
|
+
options: TRANSPORTS,
|
|
141
|
+
description: 'Каналы доставки ответа. Every channel chosen delivers the same text, so picking three sends the client three copies; the API validates nothing here beyond what the account actually has connected.',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
displayName: 'Author Name or ID',
|
|
145
|
+
name: 'authorId',
|
|
146
|
+
type: 'options',
|
|
147
|
+
typeOptions: { loadOptionsMethod: 'getManagers' },
|
|
148
|
+
default: '',
|
|
149
|
+
required: true,
|
|
150
|
+
displayOptions: showFor(['addComment', 'addNote']),
|
|
151
|
+
description: 'Сотрудник, от имени которого публикуется ответ или заметка. The list holds the account\'s personal managers, the only staff listing the API publishes — another employee ID may well be accepted, so a typed ID is worth trying when someone is missing from it. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
displayName: 'New Department Name or ID',
|
|
155
|
+
name: 'newDepartmentId',
|
|
156
|
+
type: 'options',
|
|
157
|
+
typeOptions: { loadOptionsMethod: 'getDepartments' },
|
|
158
|
+
default: '',
|
|
159
|
+
required: true,
|
|
160
|
+
displayOptions: showFor(['changeDepartment']),
|
|
161
|
+
description: 'Отдел, в который переводится тикет. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
displayName: 'Closing Reason',
|
|
165
|
+
name: 'closedReason',
|
|
166
|
+
type: 'options',
|
|
167
|
+
default: 4,
|
|
168
|
+
required: true,
|
|
169
|
+
displayOptions: showFor(['close']),
|
|
170
|
+
options: [
|
|
171
|
+
{ name: 'Client Dissatisfied (Клиент недоволен)', value: 3 },
|
|
172
|
+
{ name: 'Client Satisfied (Клиент доволен)', value: 2 },
|
|
173
|
+
{ name: 'Deadline Reached (По сроку)', value: 1 },
|
|
174
|
+
{ name: 'No Client Reply (Нет ответа клиента)', value: 5 },
|
|
175
|
+
{ name: 'No Reason (Без причины)', value: 4 },
|
|
176
|
+
],
|
|
177
|
+
description: 'Причина закрытия тикета, которую требует API',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
displayName: 'Closing Comment',
|
|
181
|
+
name: 'closedComment',
|
|
182
|
+
type: 'string',
|
|
183
|
+
default: '',
|
|
184
|
+
displayOptions: showFor(['close']),
|
|
185
|
+
description: 'Комментарий к закрытию, не длиннее 255 символов',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
displayName: 'Message Count',
|
|
189
|
+
name: 'messageCount',
|
|
190
|
+
type: 'number',
|
|
191
|
+
typeOptions: { minValue: 1, maxValue: MAX_HISTORY },
|
|
192
|
+
default: 100,
|
|
193
|
+
displayOptions: showFor(['getHistory']),
|
|
194
|
+
description: 'Сколько последних сообщений вернуть. GetCourse caps this at 1000 and offers no offset, so a longer ticket can only ever be read from its newest end. Messages arrive newest first.',
|
|
195
|
+
},
|
|
196
|
+
];
|
|
197
|
+
function numericId(name, label, itemIndex) {
|
|
198
|
+
var _a;
|
|
199
|
+
const raw = String((_a = this.getNodeParameter(name, itemIndex, '')) !== null && _a !== void 0 ? _a : '').trim();
|
|
200
|
+
const value = Number(raw);
|
|
201
|
+
if (raw === '' || !Number.isFinite(value)) {
|
|
202
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No valid ${label} given`, {
|
|
203
|
+
description: `Give the numeric ${label}.`,
|
|
204
|
+
itemIndex,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return value;
|
|
208
|
+
}
|
|
209
|
+
function requiredText(name, label, itemIndex) {
|
|
210
|
+
var _a;
|
|
211
|
+
const value = String((_a = this.getNodeParameter(name, itemIndex, '')) !== null && _a !== void 0 ? _a : '').trim();
|
|
212
|
+
if (value === '') {
|
|
213
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No ${label} given`, {
|
|
214
|
+
description: `Fill in the ${label} — GetCourse rejects an empty one.`,
|
|
215
|
+
itemIndex,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return value;
|
|
219
|
+
}
|
|
220
|
+
async function addComment(itemIndex) {
|
|
221
|
+
const transport = this.getNodeParameter('transport', itemIndex, []);
|
|
222
|
+
if (transport.length === 0) {
|
|
223
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No transport chosen', {
|
|
224
|
+
description: 'Pick at least one channel for the reply. GetCourse requires the field and answers an empty one with «Не заполнено поле», which does not say which field it means.',
|
|
225
|
+
itemIndex,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
const body = {
|
|
229
|
+
commentText: requiredText.call(this, 'commentText', 'comment text', itemIndex),
|
|
230
|
+
transport: transport.map(Number),
|
|
231
|
+
userId: numericId.call(this, 'authorId', 'staff member ID', itemIndex),
|
|
232
|
+
};
|
|
233
|
+
if (String(this.getNodeParameter('ticketAddressBy', itemIndex, 'ticket')) === 'ticket') {
|
|
234
|
+
body.ticketId = numericId.call(this, 'ticketId', 'ticket ID', itemIndex);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
body.recipientId = numericId.call(this, 'recipientId', 'client ID', itemIndex);
|
|
238
|
+
}
|
|
239
|
+
const data = await transport_1.techApiRequest.call(this, 'POST', '/helpdesk/add-comment', body);
|
|
240
|
+
return (0, request_1.toItems)(data, { result: true }).map((json) => ({ json }));
|
|
241
|
+
}
|
|
242
|
+
async function addNote(itemIndex) {
|
|
243
|
+
const ticketId = numericId.call(this, 'ticketId', 'ticket ID', itemIndex);
|
|
244
|
+
const data = await transport_1.techApiRequest.call(this, 'POST', '/helpdesk/add-note', {
|
|
245
|
+
ticketId,
|
|
246
|
+
text: requiredText.call(this, 'text', 'note text', itemIndex),
|
|
247
|
+
userId: numericId.call(this, 'authorId', 'staff member ID', itemIndex),
|
|
248
|
+
});
|
|
249
|
+
return (0, request_1.toItems)(data, { result: true, ticket_id: ticketId }).map((json) => ({ json }));
|
|
250
|
+
}
|
|
251
|
+
async function changeDepartment(itemIndex) {
|
|
252
|
+
const data = await transport_1.techApiRequest.call(this, 'POST', '/helpdesk/change-department', {
|
|
253
|
+
ticketId: numericId.call(this, 'ticketId', 'ticket ID', itemIndex),
|
|
254
|
+
newDepartmentId: numericId.call(this, 'newDepartmentId', 'department ID', itemIndex),
|
|
255
|
+
});
|
|
256
|
+
return (0, request_1.toItems)(data, { result: true }).map((json) => ({ json }));
|
|
257
|
+
}
|
|
258
|
+
async function closeTicket(itemIndex) {
|
|
259
|
+
var _a;
|
|
260
|
+
const ticketId = numericId.call(this, 'ticketId', 'ticket ID', itemIndex);
|
|
261
|
+
const comment = String((_a = this.getNodeParameter('closedComment', itemIndex, '')) !== null && _a !== void 0 ? _a : '').trim();
|
|
262
|
+
if (comment.length > MAX_CLOSING_COMMENT) {
|
|
263
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The closing comment is too long', {
|
|
264
|
+
description: `GetCourse accepts at most ${MAX_CLOSING_COMMENT} characters here, and this one is ${comment.length}.`,
|
|
265
|
+
itemIndex,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const body = {
|
|
269
|
+
ticketId,
|
|
270
|
+
closedReason: Number(this.getNodeParameter('closedReason', itemIndex, 4)),
|
|
271
|
+
};
|
|
272
|
+
if (comment !== '')
|
|
273
|
+
body.closedComment = comment;
|
|
274
|
+
const data = await transport_1.techApiRequest.call(this, 'POST', '/helpdesk/close', body);
|
|
275
|
+
return (0, request_1.toItems)(data, { result: true, ticket_id: ticketId }).map((json) => ({ json }));
|
|
276
|
+
}
|
|
277
|
+
async function getHistory(itemIndex) {
|
|
278
|
+
const ticketId = numericId.call(this, 'ticketId', 'ticket ID', itemIndex);
|
|
279
|
+
const wanted = Number(this.getNodeParameter('messageCount', itemIndex, 100)) || 100;
|
|
280
|
+
const data = await transport_1.techApiRequest.call(this, 'GET', '/helpdesk/get-history', undefined, {
|
|
281
|
+
ticketId,
|
|
282
|
+
limit: Math.min(Math.max(1, Math.trunc(wanted)), MAX_HISTORY),
|
|
283
|
+
});
|
|
284
|
+
if (data === null || data === undefined)
|
|
285
|
+
return [];
|
|
286
|
+
const rows = Array.isArray(data) ? data : (0, request_1.toItems)(data);
|
|
287
|
+
return rows.map((json) => ({ json }));
|
|
288
|
+
}
|
|
289
|
+
async function execute(operation, itemIndex) {
|
|
290
|
+
switch (operation) {
|
|
291
|
+
case 'addComment':
|
|
292
|
+
return await addComment.call(this, itemIndex);
|
|
293
|
+
case 'addNote':
|
|
294
|
+
return await addNote.call(this, itemIndex);
|
|
295
|
+
case 'changeDepartment':
|
|
296
|
+
return await changeDepartment.call(this, itemIndex);
|
|
297
|
+
case 'close':
|
|
298
|
+
return await closeTicket.call(this, itemIndex);
|
|
299
|
+
case 'getHistory':
|
|
300
|
+
return await getHistory.call(this, itemIndex);
|
|
301
|
+
default:
|
|
302
|
+
throw router_1.unknownOperation.call(this, 'helpdesk', operation, itemIndex);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../nodes/GetCourse/v1/actions/helpdesk/index.ts"],"names":[],"mappings":";;;AAiaA,0BAmBC;AA9aD,+CAAkD;AAElD,mDAAgD;AAChD,wDAA+D;AAC/D,+CAAiD;AAEjD,MAAM,OAAO,GAAG,CAAC,UAAoB,EAAqC,EAAE,CAAC,CAAC;IAC7E,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE;CACvD,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,IAAY,EAAqC,EAAE,CAAC,CAAC;IAC5E,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC,IAAI,CAAC,EAAE;CACpF,CAAC,CAAC;AA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CAAC;IACtE,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import type { ResourceModule } from '../../../../utils/router';
|
|
3
|
+
export declare const resources: Record<string, ResourceModule>;
|
|
4
|
+
export declare const resourceProperty: INodeProperties;
|
|
5
|
+
export declare const resourceProperties: INodeProperties[];
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resourceProperties = exports.resourceProperty = exports.resources = void 0;
|
|
37
|
+
const call = __importStar(require("./call"));
|
|
38
|
+
const deal = __importStar(require("./deal"));
|
|
39
|
+
const dialog = __importStar(require("./dialog"));
|
|
40
|
+
const helpdesk = __importStar(require("./helpdesk"));
|
|
41
|
+
const lesson = __importStar(require("./lesson"));
|
|
42
|
+
const offer = __importStar(require("./offer"));
|
|
43
|
+
const school = __importStar(require("./school"));
|
|
44
|
+
const user = __importStar(require("./user"));
|
|
45
|
+
const webhook = __importStar(require("./webhook"));
|
|
46
|
+
const webinar = __importStar(require("./webinar"));
|
|
47
|
+
exports.resources = {
|
|
48
|
+
call,
|
|
49
|
+
deal,
|
|
50
|
+
dialog,
|
|
51
|
+
helpdesk,
|
|
52
|
+
lesson,
|
|
53
|
+
offer,
|
|
54
|
+
school,
|
|
55
|
+
user,
|
|
56
|
+
webhook,
|
|
57
|
+
webinar,
|
|
58
|
+
};
|
|
59
|
+
exports.resourceProperty = {
|
|
60
|
+
displayName: 'Resource',
|
|
61
|
+
name: 'resource',
|
|
62
|
+
type: 'options',
|
|
63
|
+
noDataExpression: true,
|
|
64
|
+
default: 'user',
|
|
65
|
+
options: [
|
|
66
|
+
{
|
|
67
|
+
name: 'Call',
|
|
68
|
+
value: 'call',
|
|
69
|
+
description: 'Звонок: комментарий и транскрибация. Both overwrite what is already there.',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Dialog',
|
|
73
|
+
value: 'dialog',
|
|
74
|
+
description: 'Диалог во «Входящие»: ответить, перевести в отдел, закрыть, прочитать переписку',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'HelpDesk Ticket',
|
|
78
|
+
value: 'helpdesk',
|
|
79
|
+
description: 'Тикет HelpDesk — отдельная от «Входящих» система с собственным пространством ID',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'Lesson',
|
|
83
|
+
value: 'lesson',
|
|
84
|
+
description: 'Ответы на урок: прочитать, прокомментировать, сменить статус',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'Offer',
|
|
88
|
+
value: 'offer',
|
|
89
|
+
description: 'Предложение: карточка, список и теги',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'Order',
|
|
93
|
+
value: 'deal',
|
|
94
|
+
description: 'Заказ: поля, позиции, комментарии, звонки и дополнительные поля',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'School',
|
|
98
|
+
value: 'school',
|
|
99
|
+
description: 'Справочники аккаунта: группы, отделы, тренинги, менеджеры, ответы на анкеты',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'User',
|
|
103
|
+
value: 'user',
|
|
104
|
+
description: 'Пользователь: профиль, группы, покупки, баланс, дипломы, диалоги',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'Webhook',
|
|
108
|
+
value: 'webhook',
|
|
109
|
+
description: 'Подписка на события через set-uri. The GetCourse Trigger node does this for itself; this resource is for a URL outside n8n.',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'Webinar',
|
|
113
|
+
value: 'webinar',
|
|
114
|
+
description: 'Вебинар: список, комментарии в чате и модерация',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
exports.resourceProperties = Object.values(exports.resources).flatMap((module) => module.description);
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/GetCourse/v1/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,iDAAiD;SAC9D;KACD;CACD,CAAC;AAEW,QAAA,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC,iBAAS,CAAC,CAAC,OAAO,CACpF,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAC9B,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.description = void 0;
|
|
4
|
+
exports.execute = execute;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const common_1 = require("../../descriptions/common");
|
|
7
|
+
const request_1 = require("../../helpers/request");
|
|
8
|
+
const router_1 = require("../../../../../utils/router");
|
|
9
|
+
const transport_1 = require("../../transport");
|
|
10
|
+
const showFor = (operations) => ({
|
|
11
|
+
show: { resource: ['lesson'], operation: operations },
|
|
12
|
+
});
|
|
13
|
+
exports.description = [
|
|
14
|
+
{
|
|
15
|
+
displayName: 'Operation',
|
|
16
|
+
name: 'operation',
|
|
17
|
+
type: 'options',
|
|
18
|
+
noDataExpression: true,
|
|
19
|
+
default: 'getAnswers',
|
|
20
|
+
displayOptions: { show: { resource: ['lesson'] } },
|
|
21
|
+
options: [
|
|
22
|
+
{
|
|
23
|
+
name: 'Add Comment to Answer',
|
|
24
|
+
value: 'addComment',
|
|
25
|
+
action: 'Add a comment to a lesson answer',
|
|
26
|
+
description: "Комментарий к ответу на урок, written on behalf of a named user. GetCourse attributes it to that person rather than to the API key, so it reads exactly like a curator's reply typed in the browser.",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Get Many Answers',
|
|
30
|
+
value: 'getAnswers',
|
|
31
|
+
action: 'Get many answers to a lesson',
|
|
32
|
+
description: 'Ответы и комментарии к уроку, each with its own comments and additional fields. The endpoint takes no offset and returns the whole list at once, so Limit is applied after the response arrives.',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'Set Answer Status',
|
|
36
|
+
value: 'setStatus',
|
|
37
|
+
action: 'Set the status of a lesson answer',
|
|
38
|
+
description: 'Статус ответа: принят, отклонён, просмотрен или новый. Which of the four is legal depends on whether the row is a задание or a комментарий.',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Lesson ID',
|
|
44
|
+
name: 'lessonId',
|
|
45
|
+
type: 'string',
|
|
46
|
+
default: '',
|
|
47
|
+
required: true,
|
|
48
|
+
displayOptions: showFor(['getAnswers']),
|
|
49
|
+
description: "ID урока. No method in the Tech API lists lessons — Get Many Trainings on the School resource stops at the training — so this is the number GetCourse shows in the lesson's own address in the account.",
|
|
50
|
+
},
|
|
51
|
+
...(0, common_1.returnAllProperties)(showFor(['getAnswers'])),
|
|
52
|
+
{
|
|
53
|
+
displayName: 'Answer ID',
|
|
54
|
+
name: 'lessonAnswerId',
|
|
55
|
+
type: 'string',
|
|
56
|
+
default: '',
|
|
57
|
+
required: true,
|
|
58
|
+
displayOptions: showFor(['addComment', 'setStatus']),
|
|
59
|
+
description: 'ID ответа на урок — the ID field of a row from Get Many Answers, not the ID of the lesson itself',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
displayName: 'Comment Text',
|
|
63
|
+
name: 'text',
|
|
64
|
+
type: 'string',
|
|
65
|
+
typeOptions: { rows: 3 },
|
|
66
|
+
default: '',
|
|
67
|
+
required: true,
|
|
68
|
+
displayOptions: showFor(['addComment']),
|
|
69
|
+
description: 'Текст комментария',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
displayName: 'Author User ID',
|
|
73
|
+
name: 'authorUserId',
|
|
74
|
+
type: 'string',
|
|
75
|
+
default: '',
|
|
76
|
+
required: true,
|
|
77
|
+
displayOptions: showFor(['addComment']),
|
|
78
|
+
description: 'ID пользователя, от имени которого пишется комментарий. A curator or a teacher belongs here rather than the student. It stays a plain field rather than the staff dropdown the other comment operations use, because Get Many Personal Managers lists users with manager rights and a teacher need not have any — that operation is still where the ID usually comes from.',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
displayName: 'Status',
|
|
82
|
+
name: 'status',
|
|
83
|
+
type: 'options',
|
|
84
|
+
default: 'accepted',
|
|
85
|
+
displayOptions: showFor(['setStatus']),
|
|
86
|
+
options: [
|
|
87
|
+
{
|
|
88
|
+
name: 'Accepted (Принят)',
|
|
89
|
+
value: 'accepted',
|
|
90
|
+
description: 'Принят. The one value a задание and a комментарий both take.',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Declined (Отклонён)',
|
|
94
|
+
value: 'declined',
|
|
95
|
+
description: 'Отклонён — задание only, and refused on a free comment',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'New (Новый)',
|
|
99
|
+
value: 'new',
|
|
100
|
+
description: 'Новый — back to unreviewed, which is what undoes any of the others',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'Viewed (Просмотрен)',
|
|
104
|
+
value: 'viewed',
|
|
105
|
+
description: 'Просмотрен — комментарий only, and refused on a homework answer',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
description: 'Новый статус ответа. The four values are the union of two disjoint sets: для задания — new, accepted, declined; для комментария — new, accepted, viewed. GetCourse answers the wrong pairing with a 400, and the type field of a row from Get Many Answers is what says which of the two it is.',
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
function numericId(name, itemIndex, message, description) {
|
|
112
|
+
var _a;
|
|
113
|
+
const raw = String((_a = this.getNodeParameter(name, itemIndex, '')) !== null && _a !== void 0 ? _a : '').trim();
|
|
114
|
+
if (raw === '') {
|
|
115
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), message, { description, itemIndex });
|
|
116
|
+
}
|
|
117
|
+
return Number(raw);
|
|
118
|
+
}
|
|
119
|
+
async function getAnswers(itemIndex) {
|
|
120
|
+
const lessonId = numericId.call(this, 'lessonId', itemIndex, 'No lesson named', "Give the numeric lesson ID — the number in the lesson's address in the account.");
|
|
121
|
+
const returnAll = this.getNodeParameter('returnAll', itemIndex, false);
|
|
122
|
+
const limit = this.getNodeParameter('limit', itemIndex, 50);
|
|
123
|
+
const data = await transport_1.techApiRequest.call(this, 'GET', '/lesson/get-answers', undefined, {
|
|
124
|
+
lessonId,
|
|
125
|
+
});
|
|
126
|
+
const rows = Array.isArray(data) ? data : (0, request_1.toItems)(data, {});
|
|
127
|
+
return (0, request_1.applyLimit)(rows, returnAll, limit).map((row) => ({ json: row }));
|
|
128
|
+
}
|
|
129
|
+
async function addComment(itemIndex) {
|
|
130
|
+
var _a;
|
|
131
|
+
const lessonAnswerId = numericId.call(this, 'lessonAnswerId', itemIndex, 'No answer named', 'Give the numeric answer ID from Get Many Answers.');
|
|
132
|
+
const userId = numericId.call(this, 'authorUserId', itemIndex, 'No comment author named', "GetCourse writes the comment on behalf of a user, so it needs that user's numeric ID.");
|
|
133
|
+
const text = String((_a = this.getNodeParameter('text', itemIndex, '')) !== null && _a !== void 0 ? _a : '');
|
|
134
|
+
if (text.trim() === '') {
|
|
135
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The comment has no text', {
|
|
136
|
+
description: 'Fill in Comment Text — GetCourse rejects an empty comment.',
|
|
137
|
+
itemIndex,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const data = await transport_1.techApiRequest.call(this, 'POST', '/lesson/add-comment-to-lesson-answer', {
|
|
141
|
+
lessonAnswerId,
|
|
142
|
+
text,
|
|
143
|
+
userId,
|
|
144
|
+
});
|
|
145
|
+
return (0, request_1.toItems)(data, {
|
|
146
|
+
lesson_answer_id: lessonAnswerId,
|
|
147
|
+
user_id: userId,
|
|
148
|
+
comment_text: text,
|
|
149
|
+
}).map((row) => ({ json: row }));
|
|
150
|
+
}
|
|
151
|
+
function answerRows(data, fallback) {
|
|
152
|
+
if (data !== null && typeof data === 'object' && !Array.isArray(data)) {
|
|
153
|
+
const wrapped = data.items;
|
|
154
|
+
if (wrapped !== undefined)
|
|
155
|
+
return (0, request_1.toItems)(wrapped, fallback);
|
|
156
|
+
}
|
|
157
|
+
return (0, request_1.toItems)(data, fallback);
|
|
158
|
+
}
|
|
159
|
+
async function setStatus(itemIndex) {
|
|
160
|
+
const lessonAnswerId = numericId.call(this, 'lessonAnswerId', itemIndex, 'No answer named', 'Give the numeric answer ID from Get Many Answers.');
|
|
161
|
+
const status = String(this.getNodeParameter('status', itemIndex, 'accepted'));
|
|
162
|
+
const data = await transport_1.techApiRequest.call(this, 'POST', '/lesson/change-status-answers', {
|
|
163
|
+
lessonAnswerId,
|
|
164
|
+
status,
|
|
165
|
+
});
|
|
166
|
+
return answerRows(data, { id: lessonAnswerId, status }).map((row) => ({ json: row }));
|
|
167
|
+
}
|
|
168
|
+
async function execute(operation, itemIndex) {
|
|
169
|
+
switch (operation) {
|
|
170
|
+
case 'addComment':
|
|
171
|
+
return await addComment.call(this, itemIndex);
|
|
172
|
+
case 'getAnswers':
|
|
173
|
+
return await getAnswers.call(this, itemIndex);
|
|
174
|
+
case 'setStatus':
|
|
175
|
+
return await setStatus.call(this, itemIndex);
|
|
176
|
+
default:
|
|
177
|
+
throw router_1.unknownOperation.call(this, 'lesson', operation, itemIndex);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../nodes/GetCourse/v1/actions/lesson/index.ts"],"names":[],"mappings":";;;AA2RA,0BAeC;AApSD,+CAAkD;AAElD,sDAAgE;AAChE,mDAA4D;AAC5D,wDAA+D;AAC/D,+CAAiD;AAEjD,MAAM,OAAO,GAAG,CAAC,UAAoB,EAAqC,EAAE,CAAC,CAAC;IAC7E,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,SAA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