pyrus-api 1.0.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.
Files changed (175) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +289 -0
  3. package/build/cjs/index.js +1015 -0
  4. package/build/esm/index.js +1010 -0
  5. package/build/types/index.d.ts +51 -0
  6. package/build/types/src/api/announcementsApi.d.ts +14 -0
  7. package/build/types/src/api/baseApi.d.ts +21 -0
  8. package/build/types/src/api/botApi.d.ts +17 -0
  9. package/build/types/src/api/calendarApi.d.ts +8 -0
  10. package/build/types/src/api/callApi.d.ts +11 -0
  11. package/build/types/src/api/catalogsApi.d.ts +22 -0
  12. package/build/types/src/api/contactsApi.d.ts +8 -0
  13. package/build/types/src/api/filesApi.d.ts +8 -0
  14. package/build/types/src/api/formsApi.d.ts +17 -0
  15. package/build/types/src/api/index.d.ts +1 -0
  16. package/build/types/src/api/listsApi.d.ts +20 -0
  17. package/build/types/src/api/logsApi.d.ts +13 -0
  18. package/build/types/src/api/membersApi.d.ts +21 -0
  19. package/build/types/src/api/profileApi.d.ts +8 -0
  20. package/build/types/src/api/pyrusApiClient.d.ts +57 -0
  21. package/build/types/src/api/roleApi.d.ts +15 -0
  22. package/build/types/src/api/tasksApi.d.ts +18 -0
  23. package/build/types/src/entities/TaskWithComments.d.ts +7 -0
  24. package/build/types/src/entities/announcementComment.d.ts +12 -0
  25. package/build/types/src/entities/announcementWithComments.d.ts +13 -0
  26. package/build/types/src/entities/approval.d.ts +7 -0
  27. package/build/types/src/entities/attachedFile.d.ts +9 -0
  28. package/build/types/src/entities/bot.d.ts +15 -0
  29. package/build/types/src/entities/catalogHeader.d.ts +9 -0
  30. package/build/types/src/entities/catalogInfo.d.ts +19 -0
  31. package/build/types/src/entities/catalogItem.d.ts +12 -0
  32. package/build/types/src/entities/channel.d.ts +8 -0
  33. package/build/types/src/entities/channelUser.d.ts +4 -0
  34. package/build/types/src/entities/columnSettings.d.ts +6 -0
  35. package/build/types/src/entities/commentDescription.d.ts +6 -0
  36. package/build/types/src/entities/department.d.ts +7 -0
  37. package/build/types/src/entities/dueFilter.d.ts +3 -0
  38. package/build/types/src/entities/formFieldInfo.d.ts +21 -0
  39. package/build/types/src/entities/formFields/formField.d.ts +26 -0
  40. package/build/types/src/entities/formFields/formFieldAuthor.d.ts +7 -0
  41. package/build/types/src/entities/formFields/formFieldBase.d.ts +12 -0
  42. package/build/types/src/entities/formFields/formFieldCatalog.d.ts +15 -0
  43. package/build/types/src/entities/formFields/formFieldCheckmark.d.ts +7 -0
  44. package/build/types/src/entities/formFields/formFieldCreateDate.d.ts +6 -0
  45. package/build/types/src/entities/formFields/formFieldDate.d.ts +6 -0
  46. package/build/types/src/entities/formFields/formFieldDueDate.d.ts +6 -0
  47. package/build/types/src/entities/formFields/formFieldDueDateTime.d.ts +6 -0
  48. package/build/types/src/entities/formFields/formFieldEmail.d.ts +6 -0
  49. package/build/types/src/entities/formFields/formFieldFile.d.ts +7 -0
  50. package/build/types/src/entities/formFields/formFieldFlag.d.ts +7 -0
  51. package/build/types/src/entities/formFields/formFieldFormLink.d.ts +7 -0
  52. package/build/types/src/entities/formFields/formFieldMoney.d.ts +6 -0
  53. package/build/types/src/entities/formFields/formFieldMultipleChoice.d.ts +14 -0
  54. package/build/types/src/entities/formFields/formFieldNewFile.d.ts +5 -0
  55. package/build/types/src/entities/formFields/formFieldNote.d.ts +6 -0
  56. package/build/types/src/entities/formFields/formFieldNumber.d.ts +6 -0
  57. package/build/types/src/entities/formFields/formFieldPerson.d.ts +7 -0
  58. package/build/types/src/entities/formFields/formFieldPhone.d.ts +6 -0
  59. package/build/types/src/entities/formFields/formFieldProject.d.ts +15 -0
  60. package/build/types/src/entities/formFields/formFieldStatus.d.ts +7 -0
  61. package/build/types/src/entities/formFields/formFieldStep.d.ts +6 -0
  62. package/build/types/src/entities/formFields/formFieldTable.d.ts +14 -0
  63. package/build/types/src/entities/formFields/formFieldText.d.ts +6 -0
  64. package/build/types/src/entities/formFields/formFieldTime.d.ts +6 -0
  65. package/build/types/src/entities/formFields/formFieldTitle.d.ts +13 -0
  66. package/build/types/src/entities/formLink.d.ts +5 -0
  67. package/build/types/src/entities/formMapping.d.ts +16 -0
  68. package/build/types/src/entities/newFile.d.ts +7 -0
  69. package/build/types/src/entities/organization.d.ts +9 -0
  70. package/build/types/src/entities/person.d.ts +19 -0
  71. package/build/types/src/entities/plainTaskList.d.ts +15 -0
  72. package/build/types/src/entities/printForm.d.ts +4 -0
  73. package/build/types/src/entities/role.d.ts +10 -0
  74. package/build/types/src/entities/sessionLifespan.d.ts +4 -0
  75. package/build/types/src/entities/sessionRestriction.d.ts +9 -0
  76. package/build/types/src/entities/settings.d.ts +5 -0
  77. package/build/types/src/entities/smsInfo.d.ts +8 -0
  78. package/build/types/src/entities/step.d.ts +5 -0
  79. package/build/types/src/entities/subscriber.d.ts +6 -0
  80. package/build/types/src/entities/task.d.ts +26 -0
  81. package/build/types/src/entities/taskComment.d.ts +50 -0
  82. package/build/types/src/entities/taskHeader.d.ts +11 -0
  83. package/build/types/src/entities/taskList.d.ts +4 -0
  84. package/build/types/src/enums/activityAction.d.ts +4 -0
  85. package/build/types/src/enums/approvalChoice.d.ts +7 -0
  86. package/build/types/src/enums/callEventType.d.ts +3 -0
  87. package/build/types/src/enums/callStatus.d.ts +7 -0
  88. package/build/types/src/enums/channelType.d.ts +23 -0
  89. package/build/types/src/enums/checkmark.d.ts +4 -0
  90. package/build/types/src/enums/disconnectParty.d.ts +6 -0
  91. package/build/types/src/enums/errorCodeType.d.ts +123 -0
  92. package/build/types/src/enums/filterMask.d.ts +20 -0
  93. package/build/types/src/enums/flag.d.ts +5 -0
  94. package/build/types/src/enums/formFieldType.d.ts +27 -0
  95. package/build/types/src/enums/listType.d.ts +4 -0
  96. package/build/types/src/enums/operatorId.d.ts +9 -0
  97. package/build/types/src/enums/permissionLevel.d.ts +6 -0
  98. package/build/types/src/enums/personRights.d.ts +24 -0
  99. package/build/types/src/enums/personType.d.ts +5 -0
  100. package/build/types/src/enums/sendSmsError.d.ts +11 -0
  101. package/build/types/src/enums/sendSmsStatus.d.ts +6 -0
  102. package/build/types/src/enums/sourceType.d.ts +4 -0
  103. package/build/types/src/enums/status.d.ts +4 -0
  104. package/build/types/src/helpers/constants.d.ts +8 -0
  105. package/build/types/src/helpers/functions.d.ts +13 -0
  106. package/build/types/src/helpers/types.d.ts +4 -0
  107. package/build/types/src/requests/announcementCommentRequest.d.ts +6 -0
  108. package/build/types/src/requests/announcementRequest.d.ts +6 -0
  109. package/build/types/src/requests/attachCallRecordRequest.d.ts +37 -0
  110. package/build/types/src/requests/authRequest.d.ts +11 -0
  111. package/build/types/src/requests/calendarTasksRequest.d.ts +24 -0
  112. package/build/types/src/requests/callRequest.d.ts +27 -0
  113. package/build/types/src/requests/catalogRequestBase.d.ts +15 -0
  114. package/build/types/src/requests/changePermissionsRequest.d.ts +4 -0
  115. package/build/types/src/requests/contactsRequest.d.ts +3 -0
  116. package/build/types/src/requests/createBotRequest.d.ts +5 -0
  117. package/build/types/src/requests/createCallRequest.d.ts +6 -0
  118. package/build/types/src/requests/createCatalogRequest.d.ts +6 -0
  119. package/build/types/src/requests/createDepartmentRequest.d.ts +6 -0
  120. package/build/types/src/requests/createListRequest.d.ts +12 -0
  121. package/build/types/src/requests/createMemberRequest.d.ts +12 -0
  122. package/build/types/src/requests/createRoleRequest.d.ts +5 -0
  123. package/build/types/src/requests/deleteBotRequest.d.ts +4 -0
  124. package/build/types/src/requests/deleteRoleRequest.d.ts +4 -0
  125. package/build/types/src/requests/formFilter.d.ts +6 -0
  126. package/build/types/src/requests/formRegisterRequest.d.ts +26 -0
  127. package/build/types/src/requests/getAllRequest.d.ts +3 -0
  128. package/build/types/src/requests/getMessageRequest.d.ts +10 -0
  129. package/build/types/src/requests/inboxRequest.d.ts +8 -0
  130. package/build/types/src/requests/personIdentity.d.ts +4 -0
  131. package/build/types/src/requests/profileRequest.d.ts +3 -0
  132. package/build/types/src/requests/setAvatarRequest.d.ts +4 -0
  133. package/build/types/src/requests/syncCatalogRequest.d.ts +6 -0
  134. package/build/types/src/requests/taskCommentRequest.d.ts +39 -0
  135. package/build/types/src/requests/taskListRequest.d.ts +10 -0
  136. package/build/types/src/requests/taskRequest.d.ts +24 -0
  137. package/build/types/src/requests/updateBotRequest.d.ts +13 -0
  138. package/build/types/src/requests/updateDepartmentRequest.d.ts +8 -0
  139. package/build/types/src/requests/updateListRequest.d.ts +14 -0
  140. package/build/types/src/requests/updateMemberRequest.d.ts +15 -0
  141. package/build/types/src/requests/updateRoleRequest.d.ts +8 -0
  142. package/build/types/src/responses/announcementResponse.d.ts +5 -0
  143. package/build/types/src/responses/announcementsResponse.d.ts +5 -0
  144. package/build/types/src/responses/authResponse.d.ts +6 -0
  145. package/build/types/src/responses/botResponse.d.ts +3 -0
  146. package/build/types/src/responses/botsResponse.d.ts +5 -0
  147. package/build/types/src/responses/calendarResponse.d.ts +6 -0
  148. package/build/types/src/responses/callResponse.d.ts +4 -0
  149. package/build/types/src/responses/catalogItemResponse.d.ts +4 -0
  150. package/build/types/src/responses/catalogResponse.d.ts +18 -0
  151. package/build/types/src/responses/contactsResponse.d.ts +5 -0
  152. package/build/types/src/responses/departmentResponse.d.ts +3 -0
  153. package/build/types/src/responses/departmentsResponse.d.ts +5 -0
  154. package/build/types/src/responses/formRegisterResponse.d.ts +5 -0
  155. package/build/types/src/responses/formResponse.d.ts +17 -0
  156. package/build/types/src/responses/formsResponse.d.ts +4 -0
  157. package/build/types/src/responses/listsResponse.d.ts +5 -0
  158. package/build/types/src/responses/memberResponse.d.ts +3 -0
  159. package/build/types/src/responses/membersResponse.d.ts +5 -0
  160. package/build/types/src/responses/permissionsDict.d.ts +4 -0
  161. package/build/types/src/responses/permissionsResponse.d.ts +5 -0
  162. package/build/types/src/responses/plainListResponse.d.ts +3 -0
  163. package/build/types/src/responses/profileIdentityResponse.d.ts +5 -0
  164. package/build/types/src/responses/profileResponse.d.ts +12 -0
  165. package/build/types/src/responses/responseBase.d.ts +6 -0
  166. package/build/types/src/responses/roleResponse.d.ts +3 -0
  167. package/build/types/src/responses/rolesResponse.d.ts +5 -0
  168. package/build/types/src/responses/syncCatalogResponse.d.ts +10 -0
  169. package/build/types/src/responses/taskListResponse.d.ts +6 -0
  170. package/build/types/src/responses/taskResponse.d.ts +5 -0
  171. package/build/types/src/responses/uploadResponse.d.ts +5 -0
  172. package/build/types/src/responses//321/201atalogsResponse.d.ts +5 -0
  173. package/build/types/src/settings/defaults.d.ts +2 -0
  174. package/build/types/src/settings/endpoints.d.ts +32 -0
  175. package/package.json +35 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Pyrus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,289 @@
1
+ # PyrusAPI Client
2
+
3
+ A TypeScript client for the Pyrus API.
4
+ The full documentation for API can be found [here](https://pyrus.com/en/help/api/)
5
+
6
+ ## Getting Started
7
+
8
+ * Install
9
+
10
+ ```
11
+ npm install pyrus-api
12
+ ```
13
+
14
+ * Import client
15
+
16
+ ```typescript
17
+ import {PyrusApiClient} from "pyrus-api";
18
+ ```
19
+
20
+ * Create and authenticate API client
21
+
22
+ ```typescript
23
+ const client = new PyrusApiClient(
24
+ {
25
+ login: "pyrus@login.com",
26
+ security_key: "security_key_from_profile"
27
+ }
28
+ );
29
+ ```
30
+
31
+ ## Forms
32
+
33
+ * Get all form templates
34
+
35
+ ```typescript
36
+ const formsResponse = await client.forms.getAll();
37
+ const forms = formsResponse.forms;
38
+ ```
39
+
40
+ * Get tasks list by form template
41
+
42
+ ```typescript
43
+ import {OperatorId, toDateString} from "pyrus-api";
44
+ ```
45
+
46
+ ```typescript
47
+ const maxDate = new Date("2024-01-12");
48
+ const formId = 19963;
49
+ const formRegisterResponse = await client.forms.getTasks(
50
+ formId,
51
+ {
52
+ filters: [
53
+ {
54
+ operator_id: OperatorId.Equals,
55
+ field_id: 6,
56
+ values: ['555']
57
+ },
58
+ {
59
+ operator_id: OperatorId.LessThan,
60
+ field_id: 4,
61
+ values: [toDateString(maxDate)]
62
+ }
63
+ ],
64
+ include_archived: "y"
65
+ }
66
+ );
67
+ const tasks = formRegisterResponse.tasks;
68
+ ```
69
+
70
+ ## Tasks
71
+
72
+ * Get task with all comments
73
+
74
+ ```typescript
75
+ const taskResponse = await client.tasks.get({id: 2512});
76
+ const task = taskResponse.task;
77
+ ```
78
+
79
+ * Add task comment
80
+
81
+ ```typescript
82
+ import type {FormFieldTable} from "pyrus-api";
83
+ import {ApprovalChoice} from "pyrus-api";
84
+ ```
85
+
86
+ ```typescript
87
+ const taskId = 2512;
88
+ const fieldToAdd: FormFieldTable = {
89
+ type: FormFieldType.Table,
90
+ value: [
91
+ {
92
+ row_id: 15,
93
+ cells: [
94
+ {
95
+ type: FormFieldType.Text,
96
+ name: "Comment",
97
+ value: "That's right"
98
+ }
99
+ ]
100
+ }
101
+ ]
102
+ };
103
+ const taskResponse = await client.tasks.addComment(
104
+ taskId,
105
+ {
106
+ approval_choice: ApprovalChoice.Approved,
107
+ field_updates: [fieldToAdd]
108
+ }
109
+ );
110
+ const task = taskResponse.task;
111
+ ```
112
+
113
+ * Create a task
114
+
115
+ ```typescript
116
+ const taskResponse = await client.tasks.create(
117
+ {
118
+ text: "Help me",
119
+ participants: [
120
+ {id: 1731},
121
+ {email: "Amanda.Smith@gmail.com"}
122
+ ],
123
+ due_date: new Date("2024-11-03")
124
+ }
125
+ );
126
+ const task = taskResponse.task;
127
+ ```
128
+
129
+ ## Files
130
+
131
+ * Upload a file
132
+
133
+ ```typescript
134
+ const file = await fs.openAsBlob("C:\\path\\to\\file");
135
+ const fileResponse = await client.files.upload(file, "filename");
136
+ const fileId = fileResponse.guid;
137
+ ```
138
+
139
+ ## Catalogs
140
+
141
+ * Get catalog with all items
142
+
143
+ ```typescript
144
+ const catalogResponse = await client.catalogs.get({id: 1525});
145
+ const items = catalogResponse.items;
146
+ ```
147
+
148
+ * Create catalog
149
+
150
+ ```typescript
151
+ const catalogResponse = await client.catalogs.create(
152
+ {
153
+ name: "NewCatalog",
154
+ catalog_headers: ["Header1", "Header2"],
155
+ items: [
156
+ {values: ["A1", "A2"]},
157
+ {values: ["B1", "B2"]}
158
+ ]
159
+ }
160
+ );
161
+ const catalogId = catalogResponse.catalog_id;
162
+ ```
163
+
164
+ * Sync catalog (All unspecified catalog items and text columns will be deleted)
165
+
166
+ ```typescript
167
+ const catalogResponse = await client.catalogs.sync(
168
+ {
169
+ id: 1236,
170
+ apply: true,
171
+
172
+ catalog_headers: ["Header1", "Header3"],
173
+ items: [
174
+ {values: ["A1", "A3"]},
175
+ {values: ["C1", "C2"]}
176
+ ]
177
+ }
178
+ );
179
+ ```
180
+
181
+ ## Contacts
182
+
183
+ * Get all available contacts
184
+
185
+ ```typescript
186
+ const contactsResponse = await client.contacts.getAll();
187
+ ```
188
+
189
+ ## Lists
190
+
191
+ * Get all lists
192
+
193
+ ```typescript
194
+ const listsResponse = await client.lists.getAll();
195
+ ```
196
+
197
+ * Get all tasks in list
198
+
199
+ ```typescript
200
+ const listId = 1322;
201
+ const listsResponse = await client.lists.getTasksInList(listId);
202
+ ```
203
+
204
+ ## Roles
205
+
206
+ * Get all organization roles
207
+
208
+ ```typescript
209
+ const rolesResponse = await client.role.getAll();
210
+ ```
211
+
212
+ * Create role
213
+
214
+ ```typescript
215
+ const roleResponse = await client.role.create(
216
+ {
217
+ name: "TechSupport",
218
+ member_add: [1732, 4368]
219
+ }
220
+ );
221
+ ```
222
+
223
+ * Update role
224
+
225
+ ```typescript
226
+ const roleResponse = await client.role.update(
227
+ {
228
+ id: 6476,
229
+ member_add: [2434],
230
+ member_remove: [1732, 4368],
231
+ external_id: "CustomIdentifier"
232
+ }
233
+ );
234
+ ```
235
+
236
+ ## Profile
237
+
238
+ * Get profile
239
+
240
+ ```typescript
241
+ const profileResponse = await client.profile.get();
242
+ ```
243
+
244
+
245
+ ## Inbox
246
+
247
+ * Get inbox
248
+
249
+ ```typescript
250
+ const inboxResponse = await client.lists.getInbox({item_count: 10});
251
+ ```
252
+
253
+ ## Announcements
254
+
255
+ * Get announcement with all comments
256
+
257
+ ```typescript
258
+ const announcementResponse = await client.announcements.get({id: 15353});
259
+ const announcement = announcementResponse.announcement;
260
+ ```
261
+
262
+ * Get announcements with all comments
263
+
264
+ ```typescript
265
+ const announcementsResponse = await client.announcements.getAll();
266
+ const announcements = announcementsResponse.announcements;
267
+ ```
268
+
269
+ * Add announcement comment
270
+
271
+ ```typescript
272
+ const announcementId = 15353;
273
+ const announcementResponse = await client.announcements.addComment(
274
+ announcementId,
275
+ {
276
+ text: "SomeText"
277
+ }
278
+ );
279
+ ```
280
+
281
+ * Create an announcement
282
+
283
+ ```typescript
284
+ const announcementResponse = await client.announcements.create(
285
+ {
286
+ text: "New announcement"
287
+ }
288
+ );
289
+ ```