connectwise-rest 0.25.1 → 1.0.2

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 (282) hide show
  1. package/.eslintrc +17 -52
  2. package/.gitattributes +1 -0
  3. package/.mocharc.json +5 -0
  4. package/.prettierrc +7 -0
  5. package/README.md +293 -230
  6. package/api-extractor.json +364 -0
  7. package/dist/Automate/AVTemplatePoliciesAPI.d.ts +36 -0
  8. package/dist/Automate/AVTemplatePoliciesAPI.d.ts.map +1 -0
  9. package/dist/Automate/AVTemplatePoliciesAPI.js +92 -0
  10. package/dist/Automate/AVTemplatePoliciesAPI.js.map +1 -0
  11. package/dist/Automate/ClientsAPI.d.ts +44 -0
  12. package/dist/Automate/ClientsAPI.d.ts.map +1 -0
  13. package/dist/Automate/ClientsAPI.js +119 -0
  14. package/dist/Automate/ClientsAPI.js.map +1 -0
  15. package/dist/Automate/CommandsAPI.d.ts +20 -0
  16. package/dist/Automate/CommandsAPI.d.ts.map +1 -0
  17. package/dist/Automate/CommandsAPI.js +36 -0
  18. package/dist/Automate/CommandsAPI.js.map +1 -0
  19. package/dist/Automate/ComputersAPI.d.ts +131 -0
  20. package/dist/Automate/ComputersAPI.d.ts.map +1 -0
  21. package/dist/Automate/ComputersAPI.js +358 -0
  22. package/dist/Automate/ComputersAPI.js.map +1 -0
  23. package/dist/Automate/ContactsAPI.d.ts +24 -0
  24. package/dist/Automate/ContactsAPI.d.ts.map +1 -0
  25. package/dist/Automate/ContactsAPI.js +50 -0
  26. package/dist/Automate/ContactsAPI.js.map +1 -0
  27. package/dist/Automate/DataViewsAPI.d.ts +22 -0
  28. package/dist/Automate/DataViewsAPI.d.ts.map +1 -0
  29. package/dist/Automate/DataViewsAPI.js +36 -0
  30. package/dist/Automate/DataViewsAPI.js.map +1 -0
  31. package/dist/Automate/DrivesAPI.d.ts +25 -0
  32. package/dist/Automate/DrivesAPI.d.ts.map +1 -0
  33. package/dist/Automate/DrivesAPI.js +57 -0
  34. package/dist/Automate/DrivesAPI.js.map +1 -0
  35. package/dist/Automate/EventLogsAPI.d.ts +19 -0
  36. package/dist/Automate/EventLogsAPI.d.ts.map +1 -0
  37. package/dist/Automate/EventLogsAPI.js +29 -0
  38. package/dist/Automate/EventLogsAPI.js.map +1 -0
  39. package/dist/Automate/LocationsAPI.d.ts +57 -0
  40. package/dist/Automate/LocationsAPI.d.ts.map +1 -0
  41. package/dist/Automate/LocationsAPI.js +138 -0
  42. package/dist/Automate/LocationsAPI.js.map +1 -0
  43. package/dist/Automate/MaintenanceWindowDefinitionsAPI.d.ts +19 -0
  44. package/dist/Automate/MaintenanceWindowDefinitionsAPI.d.ts.map +1 -0
  45. package/dist/Automate/MaintenanceWindowDefinitionsAPI.js +29 -0
  46. package/dist/Automate/MaintenanceWindowDefinitionsAPI.js.map +1 -0
  47. package/dist/Automate/MonitorsAPI.d.ts +29 -0
  48. package/dist/Automate/MonitorsAPI.d.ts.map +1 -0
  49. package/dist/Automate/MonitorsAPI.js +85 -0
  50. package/dist/Automate/MonitorsAPI.js.map +1 -0
  51. package/dist/Automate/NetworkDevicesAPI.d.ts +23 -0
  52. package/dist/Automate/NetworkDevicesAPI.d.ts.map +1 -0
  53. package/dist/Automate/NetworkDevicesAPI.js +43 -0
  54. package/dist/Automate/NetworkDevicesAPI.js.map +1 -0
  55. package/dist/Automate/PatchingAPI.d.ts +33 -0
  56. package/dist/Automate/PatchingAPI.d.ts.map +1 -0
  57. package/dist/Automate/PatchingAPI.js +99 -0
  58. package/dist/Automate/PatchingAPI.js.map +1 -0
  59. package/dist/Automate/RemoteAgentAPI.d.ts +24 -0
  60. package/dist/Automate/RemoteAgentAPI.d.ts.map +1 -0
  61. package/dist/Automate/RemoteAgentAPI.js +50 -0
  62. package/dist/Automate/RemoteAgentAPI.js.map +1 -0
  63. package/dist/Automate/ScriptingAPI.d.ts +41 -0
  64. package/dist/Automate/ScriptingAPI.d.ts.map +1 -0
  65. package/dist/Automate/ScriptingAPI.js +109 -0
  66. package/dist/Automate/ScriptingAPI.js.map +1 -0
  67. package/dist/Automate/SearchesAPI.d.ts +23 -0
  68. package/dist/Automate/SearchesAPI.d.ts.map +1 -0
  69. package/dist/Automate/SearchesAPI.js +43 -0
  70. package/dist/Automate/SearchesAPI.js.map +1 -0
  71. package/dist/Automate/SystemAPI.d.ts +97 -0
  72. package/dist/Automate/SystemAPI.d.ts.map +1 -0
  73. package/dist/Automate/SystemAPI.js +273 -0
  74. package/dist/Automate/SystemAPI.js.map +1 -0
  75. package/dist/Automate/TicketsAPI.d.ts +14 -0
  76. package/dist/Automate/TicketsAPI.d.ts.map +1 -0
  77. package/dist/Automate/TicketsAPI.js +29 -0
  78. package/dist/Automate/TicketsAPI.js.map +1 -0
  79. package/dist/Automate/UserProfilesAPI.d.ts +19 -0
  80. package/dist/Automate/UserProfilesAPI.d.ts.map +1 -0
  81. package/dist/Automate/UserProfilesAPI.js +28 -0
  82. package/dist/Automate/UserProfilesAPI.js.map +1 -0
  83. package/dist/Automate.d.ts +43 -0
  84. package/dist/Automate.d.ts.map +1 -0
  85. package/dist/Automate.js +164 -0
  86. package/dist/Automate.js.map +1 -0
  87. package/dist/AutomateAPI.d.ts +129 -0
  88. package/dist/AutomateAPI.d.ts.map +1 -0
  89. package/dist/AutomateAPI.js +175 -0
  90. package/dist/AutomateAPI.js.map +1 -0
  91. package/dist/AutomateTypes.d.ts +10437 -0
  92. package/dist/AutomateTypes.d.ts.map +1 -0
  93. package/dist/AutomateTypes.js +3 -0
  94. package/dist/AutomateTypes.js.map +1 -0
  95. package/dist/BaseAPI.d.ts +26 -0
  96. package/dist/BaseAPI.d.ts.map +1 -0
  97. package/dist/BaseAPI.js +116 -0
  98. package/dist/BaseAPI.js.map +1 -0
  99. package/dist/Manage/CompanyAPI.d.ts +662 -0
  100. package/dist/Manage/CompanyAPI.d.ts.map +1 -0
  101. package/dist/Manage/CompanyAPI.js +3299 -0
  102. package/dist/Manage/CompanyAPI.js.map +1 -0
  103. package/dist/Manage/ConfigurationsAPI.d.ts +32 -0
  104. package/dist/Manage/ConfigurationsAPI.d.ts.map +1 -0
  105. package/dist/Manage/ConfigurationsAPI.js +78 -0
  106. package/dist/Manage/ConfigurationsAPI.js.map +1 -0
  107. package/dist/Manage/ExpenseAPI.d.ts +85 -0
  108. package/dist/Manage/ExpenseAPI.d.ts.map +1 -0
  109. package/dist/Manage/ExpenseAPI.js +311 -0
  110. package/dist/Manage/ExpenseAPI.js.map +1 -0
  111. package/dist/Manage/FinanceAPI.d.ts +538 -0
  112. package/dist/Manage/FinanceAPI.d.ts.map +1 -0
  113. package/dist/Manage/FinanceAPI.js +2592 -0
  114. package/dist/Manage/FinanceAPI.js.map +1 -0
  115. package/dist/Manage/MarketingAPI.d.ts +142 -0
  116. package/dist/Manage/MarketingAPI.d.ts.map +1 -0
  117. package/dist/Manage/MarketingAPI.js +634 -0
  118. package/dist/Manage/MarketingAPI.js.map +1 -0
  119. package/dist/Manage/ProcurementAPI.d.ts +435 -0
  120. package/dist/Manage/ProcurementAPI.d.ts.map +1 -0
  121. package/dist/Manage/ProcurementAPI.js +2103 -0
  122. package/dist/Manage/ProcurementAPI.js.map +1 -0
  123. package/dist/Manage/ProjectAPI.d.ts +215 -0
  124. package/dist/Manage/ProjectAPI.d.ts.map +1 -0
  125. package/dist/Manage/ProjectAPI.js +945 -0
  126. package/dist/Manage/ProjectAPI.js.map +1 -0
  127. package/dist/Manage/SalesAPI.d.ts +299 -0
  128. package/dist/Manage/SalesAPI.d.ts.map +1 -0
  129. package/dist/Manage/SalesAPI.js +1397 -0
  130. package/dist/Manage/SalesAPI.js.map +1 -0
  131. package/dist/Manage/ScheduleAPI.d.ts +132 -0
  132. package/dist/Manage/ScheduleAPI.d.ts.map +1 -0
  133. package/dist/Manage/ScheduleAPI.js +580 -0
  134. package/dist/Manage/ScheduleAPI.js.map +1 -0
  135. package/dist/Manage/ServiceAPI.d.ts +493 -0
  136. package/dist/Manage/ServiceAPI.d.ts.map +1 -0
  137. package/dist/Manage/ServiceAPI.js +2339 -0
  138. package/dist/Manage/ServiceAPI.js.map +1 -0
  139. package/dist/Manage/SystemAPI.d.ts +954 -0
  140. package/dist/Manage/SystemAPI.d.ts.map +1 -0
  141. package/dist/Manage/SystemAPI.js +4536 -0
  142. package/dist/Manage/SystemAPI.js.map +1 -0
  143. package/dist/Manage/TimeAPI.d.ts +186 -0
  144. package/dist/Manage/TimeAPI.d.ts.map +1 -0
  145. package/dist/Manage/TimeAPI.js +840 -0
  146. package/dist/Manage/TimeAPI.js.map +1 -0
  147. package/dist/Manage.d.ts +39 -0
  148. package/dist/Manage.d.ts.map +1 -0
  149. package/dist/Manage.js +137 -0
  150. package/dist/Manage.js.map +1 -0
  151. package/dist/ManageAPI.d.ts +135 -0
  152. package/dist/ManageAPI.d.ts.map +1 -0
  153. package/dist/ManageAPI.js +115 -0
  154. package/dist/ManageAPI.js.map +1 -0
  155. package/dist/ManageTypes.d.ts +91320 -0
  156. package/dist/ManageTypes.d.ts.map +1 -0
  157. package/dist/ManageTypes.js +7 -0
  158. package/dist/ManageTypes.js.map +1 -0
  159. package/dist/connectwise-rest.d.ts +108638 -0
  160. package/dist/index.d.ts +12 -0
  161. package/dist/index.d.ts.map +1 -0
  162. package/dist/index.js +36 -0
  163. package/dist/index.js.map +1 -0
  164. package/dist/tsdoc-metadata.json +11 -0
  165. package/dist/types.d.ts +48 -0
  166. package/dist/types.d.ts.map +1 -0
  167. package/dist/types.js +21 -0
  168. package/dist/types.js.map +1 -0
  169. package/dist/utils/Callback.d.ts +70 -0
  170. package/dist/utils/Callback.d.ts.map +1 -0
  171. package/dist/utils/Callback.js +109 -0
  172. package/dist/utils/Callback.js.map +1 -0
  173. package/dist/utils/Series.d.ts +42 -0
  174. package/dist/utils/Series.d.ts.map +1 -0
  175. package/dist/utils/Series.js +68 -0
  176. package/dist/utils/Series.js.map +1 -0
  177. package/dist/utils/index.d.ts +7 -0
  178. package/dist/utils/index.d.ts.map +1 -0
  179. package/dist/utils/index.js +11 -0
  180. package/dist/utils/index.js.map +1 -0
  181. package/package.json +50 -19
  182. package/src/Automate/AVTemplatePoliciesAPI.ts +124 -0
  183. package/src/Automate/ClientsAPI.ts +172 -0
  184. package/src/Automate/CommandsAPI.ts +39 -0
  185. package/src/Automate/ComputersAPI.ts +588 -0
  186. package/src/Automate/ContactsAPI.ts +63 -0
  187. package/src/Automate/DataViewsAPI.ts +43 -0
  188. package/src/Automate/DrivesAPI.ts +81 -0
  189. package/src/Automate/EventLogsAPI.ts +31 -0
  190. package/src/Automate/LocationsAPI.ts +222 -0
  191. package/src/Automate/MaintenanceWindowDefinitionsAPI.ts +34 -0
  192. package/src/Automate/MonitorsAPI.ts +101 -0
  193. package/src/Automate/NetworkDevicesAPI.ts +51 -0
  194. package/src/Automate/PatchingAPI.ts +116 -0
  195. package/src/Automate/RemoteAgentAPI.ts +65 -0
  196. package/src/Automate/ScriptingAPI.ts +147 -0
  197. package/src/Automate/SearchesAPI.ts +49 -0
  198. package/src/Automate/SystemAPI.ts +412 -0
  199. package/src/Automate/TicketsAPI.ts +29 -0
  200. package/src/Automate/UserProfilesAPI.ts +31 -0
  201. package/src/Automate.ts +204 -0
  202. package/src/AutomateAPI.ts +178 -0
  203. package/src/AutomateTypes.ts +10492 -0
  204. package/src/BaseAPI.ts +180 -0
  205. package/src/Manage/CompanyAPI.ts +4941 -0
  206. package/src/Manage/ConfigurationsAPI.ts +116 -0
  207. package/src/Manage/ExpenseAPI.ts +413 -0
  208. package/src/Manage/FinanceAPI.ts +3930 -0
  209. package/src/Manage/MarketingAPI.ts +958 -0
  210. package/src/Manage/ProcurementAPI.ts +3107 -0
  211. package/src/Manage/ProjectAPI.ts +1437 -0
  212. package/src/Manage/SalesAPI.ts +1968 -0
  213. package/src/Manage/ScheduleAPI.ts +773 -0
  214. package/src/Manage/ServiceAPI.ts +3476 -0
  215. package/src/Manage/SystemAPI.ts +6415 -0
  216. package/src/Manage/TimeAPI.ts +1151 -0
  217. package/src/Manage.ts +161 -0
  218. package/src/ManageAPI.ts +170 -0
  219. package/src/ManageTypes.ts +91318 -0
  220. package/src/index.ts +13 -0
  221. package/src/types.ts +68 -0
  222. package/src/utils/Callback.ts +148 -0
  223. package/src/utils/Series.ts +89 -0
  224. package/src/utils/index.ts +7 -0
  225. package/swagger-errors.md +25 -0
  226. package/test/.env.example +12 -6
  227. package/test/test-utils.ts +27 -0
  228. package/test/test.js +331 -108
  229. package/tsconfig.json +29 -0
  230. package/.travis.yml +0 -9
  231. package/doc.md +0 -5984
  232. package/docs/jsdoc.json +0 -15
  233. package/index.js +0 -10
  234. package/src/CompanyAPI/Companies.js +0 -149
  235. package/src/CompanyAPI/CompanyCompanyTypeAssociations.js +0 -111
  236. package/src/CompanyAPI/CompanySites.js +0 -80
  237. package/src/CompanyAPI/CompanyTeams.js +0 -108
  238. package/src/CompanyAPI/CompanyTypeInfos.js +0 -58
  239. package/src/CompanyAPI/CompanyTypes.js +0 -52
  240. package/src/CompanyAPI/Configurations.js +0 -152
  241. package/src/CompanyAPI/ContactContactTypeAssociations.js +0 -55
  242. package/src/CompanyAPI/ContactRelationships.js +0 -36
  243. package/src/CompanyAPI/Contacts.js +0 -199
  244. package/src/CompanyAPI/index.js +0 -53
  245. package/src/ConnectWise.js +0 -339
  246. package/src/ConnectWiseRest.js +0 -515
  247. package/src/FinanceAPI/Additions.js +0 -127
  248. package/src/FinanceAPI/Adjustments.js +0 -109
  249. package/src/FinanceAPI/AgreementSites.js +0 -108
  250. package/src/FinanceAPI/Agreements.js +0 -220
  251. package/src/FinanceAPI/BoardDefaults.js +0 -109
  252. package/src/FinanceAPI/WorkRoles.js +0 -113
  253. package/src/FinanceAPI/WorkTypeExclusions.js +0 -78
  254. package/src/FinanceAPI/WorkTypes.js +0 -124
  255. package/src/FinanceAPI/index.js +0 -50
  256. package/src/ProcurementAPI/CatalogItems.js +0 -94
  257. package/src/ProcurementAPI/index.js +0 -22
  258. package/src/ProjectAPI/Projects.js +0 -142
  259. package/src/ProjectAPI/index.js +0 -28
  260. package/src/SalesAPI/Activities.js +0 -149
  261. package/src/SalesAPI/index.js +0 -14
  262. package/src/ScheduleAPI/ScheduleEntries.js +0 -109
  263. package/src/ScheduleAPI/ScheduleTypes.js +0 -101
  264. package/src/ScheduleAPI/index.js +0 -30
  265. package/src/ServiceDeskAPI/BoardItems.js +0 -134
  266. package/src/ServiceDeskAPI/BoardSubTypes.js +0 -112
  267. package/src/ServiceDeskAPI/BoardTeams.js +0 -108
  268. package/src/ServiceDeskAPI/BoardTypes.js +0 -139
  269. package/src/ServiceDeskAPI/Boards.js +0 -100
  270. package/src/ServiceDeskAPI/Priorities.js +0 -47
  271. package/src/ServiceDeskAPI/ServiceNotes.js +0 -172
  272. package/src/ServiceDeskAPI/Statuses.js +0 -116
  273. package/src/ServiceDeskAPI/Tickets.js +0 -588
  274. package/src/ServiceDeskAPI/index.js +0 -53
  275. package/src/SystemAPI/Members.js +0 -139
  276. package/src/SystemAPI/Reports.js +0 -116
  277. package/src/SystemAPI/index.js +0 -32
  278. package/src/TimeAPI/TimeEntries.js +0 -121
  279. package/src/TimeAPI/index.js +0 -27
  280. package/src/utils/Callback.js +0 -124
  281. package/src/utils/Series.js +0 -63
  282. package/src/utils/index.js +0 -21
@@ -1,588 +0,0 @@
1
- /**
2
- * Created by kgrube on 12/15/2015.
3
- * @author kgrube
4
- */
5
-
6
- /**
7
- *
8
- * @private
9
- */
10
- const inherits = require('util').inherits;
11
- const ConnectWise = require('../ConnectWise.js');
12
-
13
- /**
14
- * @typedef {object} Ticket
15
- * @property {string} actualHours
16
- * @property {string} addressLine1
17
- * @property {string} addressLine2
18
- * @property {AgreementHref} agreement
19
- * @property {boolean} allowAllClientsPortalView
20
- * @property {boolean} approved
21
- * @property automaticEmailCc
22
- * @property automaticEmailCcFlag
23
- * @property automaticEmailContactFlag
24
- * @property automaticEmailResourceFlag
25
- * @property {BoardHref} board
26
- * @property {number} budgetHours
27
- * @property {string} city
28
- * @property closedBy
29
- * @property closedDate
30
- * @property closedFlag
31
- * @property {CompanyHref} company
32
- * @property {ContactHref} contact
33
- * @property {string} contactEmailAddress
34
- * @property contactEmailLookup
35
- * @property contactPhoneExtension
36
- * @property {string} contactPhoneNumber
37
- * @property {CountryHref} country
38
- * @property {boolean} customerUpdatedFlag
39
- * @property {CustomField[]} customFields
40
- * @property {string} dateEntered
41
- * @property {string} dateResolved
42
- * @property {string} dateResplan
43
- * @property {string} dateResponded
44
- * @property {string} enteredBy
45
- * @property externalXRef
46
- * @property {boolean} hasChildTicket
47
- * @property {number} id TicketNbr
48
- * @property {string} impact
49
- * @property initialDescription
50
- * @property initialInternalAnalysis
51
- * @property initialResolution
52
- * @property {boolean} isInSla
53
- * @property {ItemHref} item
54
- * @property knowledgeBaseCategoryId
55
- * @property knowledgeBaseLinkId
56
- * @property knowledgeBaseLinkType
57
- * @property knowledgeBaseSubCategoryId
58
- * @property opportunity
59
- * @property {OwnerHref} owner
60
- * @property parentTicketId
61
- * @property phase
62
- * @property poNumber
63
- * @property {PriorityHref} priority
64
- * @property processNotifications
65
- * @property project
66
- * @property {string} recordType
67
- * @property {string} requiredDate
68
- * @property {number} resPlanMinutes
69
- * @property {number} resolveMinutes
70
- * @property {string} resources
71
- * @property {number} respondMinutes
72
- * @property {ServiceLocationHref} serviceLocation
73
- * @property {string} severity
74
- * @property {SiteHref} site
75
- * @property {string} siteName
76
- * @property skipCallback
77
- * @property {SourceHref} source
78
- * @property {string} stateIdentifier
79
- * @property {StatusHref} status
80
- * @property subBillingAmount
81
- * @property {string} subBillingMethod
82
- * @property subDateAccepted
83
- * @property {SubTypeHref} subType
84
- * @property {string} summary
85
- * @property {TeamHref} team
86
- * @property {TypeHref} type
87
- * @property wbsCode
88
- * @property {string} zip
89
- * @property {object} _info
90
- * @property {string} _info.activities_href
91
- * @property {string} _info.childtasks_href
92
- * @property {string} _info.configurations_href
93
- * @property {string} _info.documents_href
94
- * @property {string} _info.lastUpdated
95
- * @property {string} _info.notes_href
96
- * @property {string} _info.products_href
97
- * @property {string} _info.scheduleentries_href
98
- * @property {string} _info.tasks_href
99
- * @property {string} _info.timeentries_href
100
- * @property {string} _info.updatedBy
101
- */
102
-
103
- /**
104
- *
105
- * @param {CWOptions} options
106
- * @constructor
107
- */
108
- function Tickets(options) {
109
- ConnectWise.apply(this, Array.prototype.slice.call(arguments));
110
- }
111
- inherits(Tickets, ConnectWise);
112
-
113
- /**
114
- * GET
115
- * @param {Params} params
116
- * @returns {Promise<Ticket[]>}
117
- */
118
- Tickets.prototype.getTickets = function (params) {
119
- return this.api('/service/tickets', 'GET', params);
120
- };
121
-
122
- /**
123
- * GET
124
- * @param {string|number} id ticketNbr
125
- * @returns {Promise<Ticket>}
126
- */
127
- Tickets.prototype.getTicketById = function (id) {
128
- return this.api(`/service/tickets/${id}`, 'GET');
129
- };
130
-
131
- /**
132
- * POST
133
- * @param {object|Ticket} ticket the new ticket data
134
- * @param {object} ticket.board
135
- * @param {string} ticket.board.name
136
- * @param {object} ticket.company
137
- * @param {string} ticket.company.identifier The CompanyID in ConnectWise
138
- * @param {string} ticket.summary
139
- * @param {string} [ticket.initialDescription]
140
- * @returns {Promise<Ticket>} The created ticket, or errors if any occured
141
- */
142
- Tickets.prototype.createTicket = function (ticket) {
143
- return this.api('/service/tickets', 'POST', ticket);
144
- };
145
-
146
- /**
147
- * PATCH
148
- * @param {number} id
149
- * @param {Operations[]} operations
150
- * @param {string} operations.op the operation to perform, possible values: ['replace', ?]
151
- * @param {string} operations.path
152
- * @param {string|number} operations.value
153
- * @returns {Promise<Ticket>} The updated ticket
154
- */
155
- Tickets.prototype.updateTicket = function (id, operations) {
156
- return this.api(`/service/tickets/${id}`, 'PATCH', operations);
157
- };
158
-
159
- /**
160
- * GET
161
- * @param {ParamsConditions} params
162
- * @param {string} [params.conditions] Conditions string, e.g. 'Summary like "%blah%" AND board/name = "Service Board"'
163
- * @returns {Promise<Count>} The number of tickets matching the conditions
164
- */
165
- Tickets.prototype.getTicketsCount = function (params) {
166
- return this.api('/service/tickets/count', 'GET', params);
167
- };
168
-
169
- /**
170
- * DELETE
171
- * @param {string|number} id
172
- * @returns {Promise<DeleteResponse>}
173
- */
174
- Tickets.prototype.deleteTicketsById = function (id) {
175
- return this.api(`/service/tickets/${id}`, 'DELETE');
176
- };
177
-
178
- /**
179
- * PUT
180
- * @param id
181
- * @param {Ticket} ticket
182
- * @returns {Promise<Ticket>}
183
- */
184
- Tickets.prototype.replaceTicket = function (id, ticket) {
185
- return this.api(`/service/tickets/${id}`, 'PUT', ticket);
186
- };
187
-
188
- /**
189
- * GET
190
- * @param id
191
- * @param {Params} [params]
192
- * @returns {Promise<Activity[]>}
193
- */
194
- Tickets.prototype.getTicketActivities = function (id, params) {
195
- return this.api(`/service/tickets/${id}/activities`, 'GET', params);
196
- };
197
-
198
- /**
199
- * GET
200
- * @param {number|string} id
201
- * @returns {Promise<Count>} The number of activities associated with ticket number id
202
- */
203
- Tickets.prototype.getTicketActivitiesCount = function (id) {
204
- return this.api(`/service/tickets/${id}/activities/count`, 'GET');
205
- };
206
-
207
- /**
208
- * GET
209
- * @param {number|string} id
210
- * @param {Params} params
211
- * @returns {Promise<TimeEntry[]>}
212
- */
213
- Tickets.prototype.getTicketTimeEntries = function (id, params) {
214
- return this.api(`/service/tickets/${id}/timeentries`, 'GET', params);
215
- };
216
-
217
- /**
218
- * GET
219
- * @param {number|string} id
220
- * @returns {Promise<Count>} The count of time entries attached to ticket id
221
- */
222
- Tickets.prototype.getTicketTimeEntriesCount = function (id) {
223
- return this.api(`/service/tickets/${id}/timeentries/count`, 'GET');
224
- };
225
-
226
- /**
227
- * POST
228
- * @param {number|string} id ticketNbr
229
- * @param {number|string} configId
230
- * @returns {Promise<ConfigurationHref>}
231
- */
232
- Tickets.prototype.createConfigurationAssociation = function (id, configId) {
233
- return this.api(`/service/tickets/${id}/configurations`, 'POST', {
234
- id: configId
235
- });
236
- };
237
-
238
- /**
239
- * GET
240
- * @param id ticketNbr
241
- * @returns {Promise<ConfigurationHref[]>}
242
- */
243
- Tickets.prototype.getTicketConfigurations = function (id) {
244
- return this.api(`/service/tickets/${id}/configurations`, 'GET');
245
- };
246
-
247
- /**
248
- * GET
249
- * @param id ticketNbr
250
- * @returns {Promise<Count>}
251
- */
252
- Tickets.prototype.getTicketConfigurationsCount = function (id) {
253
- return this.api(`/service/tickets/${id}/configurations/count`, 'GET');
254
- };
255
-
256
- /**
257
- * DELETE
258
- * @param id
259
- * @param configId
260
- * @throws {ErrorResponse}
261
- * @returns {Promise<DeleteResponse>}
262
- */
263
- Tickets.prototype.deleteConfigurationAssociation = function (id, configId) {
264
- return this.api(`/service/tickets/${id}/configurations/${configId}`, 'DELETE');
265
- };
266
-
267
- /**
268
- * GET
269
- * @param id
270
- * @param configId
271
- * @returns {Promise<ConfigurationHref>}
272
- */
273
- Tickets.prototype.getConfigurationAssociation = function (id, configId) {
274
- return this.api(`/service/tickets/${id}/configurations/${configId}`, 'GET');
275
- };
276
-
277
- /**
278
- * GET
279
- * @param {string|number} id
280
- * @param {ParamsPage} [params]
281
- * @returns {Promise<ScheduleEntryHref[]>}
282
- */
283
- Tickets.prototype.getTicketScheduleEntries = function (id, params) {
284
- return this.api(`/service/tickets/${id}/scheduleentries`, 'GET', params);
285
- };
286
-
287
- /**
288
- * GET
289
- * @param id
290
- * @returns {Promise<Count>}
291
- */
292
- Tickets.prototype.getTicketScheduleEntriesCount = function (id) {
293
- return this.api(`/service/tickets/${id}/scheduleentries/count`, 'GET');
294
- };
295
-
296
- /**
297
- * GET
298
- * @param {string|number} id
299
- * @param {ParamsPage} [params]
300
- * @returns {Promise<DocumentHref[]>}
301
- */
302
- Tickets.prototype.getTicketDocuments = function (id, params) {
303
- return this.api(`/service/tickets/${id}/documents`, 'GET', params);
304
- };
305
-
306
- /**
307
- * GET
308
- * @param id
309
- * @returns {Promise<Count>}
310
- */
311
- Tickets.prototype.getTicketDocumentsCount = function (id) {
312
- return this.api(`/service/tickets/${id}/documents/count`, 'GET');
313
- };
314
-
315
- /**
316
- * GET
317
- * @param id
318
- * @returns {Promise<ProductHref[]>}
319
- */
320
- Tickets.prototype.getTicketProducts = function (id) {
321
- return this.api(`/service/tickets/${id}/products`, 'GET');
322
- };
323
-
324
- /**
325
- * GET
326
- * @param id
327
- * @returns {Promise<Count>}
328
- */
329
- Tickets.prototype.getTicketProductsCount = function (id) {
330
- return this.api(`/service/tickets/${id}/products/count`, 'GET');
331
- };
332
-
333
- /**
334
- *
335
- * @param {string|number} id
336
- * @param {string} status
337
- * @returns {Promise<Ticket[]>}
338
- */
339
- Tickets.prototype.updateTicketStatusByName = function (id, status) {
340
- const self = this;
341
-
342
- return self.getTicketById(id)
343
- .then(function (ticket) {
344
- const boardId = ticket.board.id;
345
- return self.api(`/service/boards/${boardId}/statuses`, 'GET', {conditions: `name = "${status}"`})
346
- .then(function (statuses) {
347
- if (statuses.length > 0) {
348
- const statusId = statuses[0].id;
349
- return self.updateTicket(id, [{
350
- op: 'replace',
351
- path: 'status',
352
- value: {id: statusId}
353
- }])
354
- } else {
355
- throw {
356
- code: 'NotFound',
357
- errors: null,
358
- message: `Status ${status} not found`
359
- };
360
- }
361
- })
362
- });
363
- };
364
-
365
- /**
366
- *
367
- * @param id
368
- * @param {string} priority - do a %like% match on priority
369
- * @returns {Promise<Ticket>}
370
- */
371
- Tickets.prototype.updateTicketPriority = function (id, priority) {
372
- const self = this;
373
- return self.api('/service/priorities', 'GET', {
374
- conditions: `name like "%${priority}%"`
375
- }).then(function (res) {
376
- if (res.length > 0) {
377
- const priorityId = res[0].id;
378
- return self.updateTicket(id, [{
379
- op: 'replace',
380
- path: 'priority',
381
- value: {id: priorityId}
382
- }]);
383
- } else {
384
- throw {
385
- code: 'NotFound',
386
- message: 'Could not find any matching priority.',
387
- errors: null
388
- };
389
- }
390
- });
391
- };
392
-
393
- /**
394
- *
395
- * @param id
396
- * @param {string} serviceType
397
- * @returns {Promise<Ticket>}
398
- */
399
- Tickets.prototype.updateTicketServiceType = function (id, serviceType) {
400
- const self = this;
401
- return self.getTicketById(id)
402
- .then(function (ticket) {
403
- const boardId = ticket.board.id;
404
- return self.api(`/service/boards/${boardId}/types`, 'GET', {
405
- conditions: `name = "${serviceType}"`
406
- }).then(function (types) {
407
- if (types.length > 0) {
408
- const serviceTypeId = types[0].id;
409
- return self.updateTicket(id, [{
410
- op: 'replace',
411
- path: 'type',
412
- value: {id: serviceTypeId}
413
- }]);
414
- } else {
415
- throw {
416
- code: 'NotFound',
417
- message: 'Could not find any matching service types.',
418
- errors: null
419
- };
420
- }
421
- });
422
- });
423
- };
424
-
425
- /**
426
- *
427
- * @param id
428
- * @param {string} serviceSubType
429
- * @returns {Promise<Ticket>}
430
- */
431
- Tickets.prototype.updateTicketServiceSubType = function (id, serviceSubType) {
432
- const self = this;
433
- return self.getTicketById(id)
434
- .then(function (ticket) {
435
- const boardId = ticket.board.id;
436
- return self.api(`/service/boards/${boardId}/subtypes`, 'GET', {
437
- conditions: `name = "${serviceSubType}"`
438
- }).then(function (types) {
439
- if (types.length > 0) {
440
- const serviceSubTypeId = types[0].id;
441
- return self.updateTicket(id, [{
442
- op: 'replace',
443
- path: 'subType',
444
- value: {id: serviceSubTypeId}
445
- }]);
446
- } else {
447
- throw {
448
- code: 'NotFound',
449
- message: 'Could not find any matching service subtypes.',
450
- errors: null
451
- };
452
- }
453
- });
454
- });
455
- };
456
-
457
- /**
458
- *
459
- * @param id
460
- * @param {string} type
461
- * @param {string} subtype
462
- * @param {string} item
463
- * @returns {Promise<Ticket>}
464
- */
465
- Tickets.prototype.updateTicketTypeSubTypeItem = function (id, type, subtype, item) {
466
- const self = this;
467
- return self.updateTicketServiceType(id, type)
468
- .then(function () {
469
- return self.updateTicketServiceSubType(id, subtype)
470
- .then(function () {
471
- return self.updateTicketServiceItem(id, item);
472
- })
473
- })
474
- };
475
-
476
- /**
477
- *
478
- * @param id
479
- * @param {string} serviceItem
480
- * @returns {Promise<Ticket>}
481
- */
482
- Tickets.prototype.updateTicketServiceItem = function (id, serviceItem) {
483
- const self = this;
484
- return self.getTicketById(id)
485
- .then(function (ticket) {
486
- const boardId = ticket.board.id;
487
- return self.api(`/service/boards/${boardId}/items`, 'GET', {
488
- conditions: `name = "${serviceItem}"`
489
- }).then(function (items) {
490
- if (items.length > 0) {
491
- const serviceItemId = items[0].id;
492
- return self.updateTicket(id, [{
493
- op: 'replace',
494
- path: 'item',
495
- value: {id: serviceItemId}
496
- }]);
497
- } else {
498
- throw {
499
- code: 'NotFound',
500
- message: 'Could not find any matching service items.',
501
- errors: null
502
- };
503
- }
504
- });
505
- });
506
- };
507
-
508
- /**
509
- *
510
- * @param {string|number} id ticketNbr
511
- * @param {string|number} index
512
- * @param {string|number|boolean} value
513
- * @returns {Promise<Ticket>}
514
- */
515
- Tickets.prototype.updateTicketCustomFieldByIndex = function (id, index, value) {
516
- return this.updateTicket(id, [{
517
- op: 'replace',
518
- path: `customFields/${index}/value`,
519
- value: value
520
- }]);
521
- };
522
-
523
- /**
524
- *
525
- * @param {string|number} id ticketNbr
526
- * @param {string|number} customFieldId
527
- * @param {string|number|boolean} value
528
- * @returns {Promise<Ticket>}
529
- */
530
- Tickets.prototype.updateTicketCustomFieldById = function (id, customFieldId, value) {
531
- if (typeof customFieldId === 'string') {
532
- customFieldId = parseInt(customFieldId);
533
- }
534
- const self = this;
535
- return self.getTicketById(id)
536
- .then(function (ticket) {
537
- let fieldIdx = -1;
538
- ticket.customFields.forEach(function (elem, idx) {
539
- if (elem.id === customFieldId) {
540
- return fieldIdx = idx;
541
- }
542
- });
543
- if (fieldIdx === -1) {
544
- throw {
545
- code: 'InvalidCustomFieldId',
546
- message: 'No custom field found with id specified',
547
- errors: null
548
- };
549
- }
550
- return self.updateTicketCustomFieldByIndex(id, fieldIdx, value);
551
- });
552
- };
553
-
554
- /**
555
- *
556
- * @param {string|number} id ticketNbr
557
- * @param {string|number} caption
558
- * @param {string|number|boolean} value
559
- * @returns {Promise<Ticket>}
560
- */
561
- Tickets.prototype.updateTicketCustomFieldByCaption = function (id, caption, value) {
562
- const self = this;
563
- return self.getTicketById(id)
564
- .then(function (ticket) {
565
- let customFieldId;
566
- ticket.customFields.forEach(function (elem, idx) {
567
- if (elem.caption === caption) {
568
- customFieldId = elem.id;
569
- }
570
- });
571
-
572
- if (customFieldId === undefined) {
573
- throw {
574
- code: 'InvalidCustomFieldName',
575
- message: 'No custom field found with caption specified',
576
- errors: null
577
- };
578
- }
579
-
580
- return self.updateTicketCustomFieldById(id, customFieldId, value);
581
- });
582
- };
583
-
584
- /**
585
- *
586
- * @type {Tickets}
587
- */
588
- module.exports = Tickets;
@@ -1,53 +0,0 @@
1
- /**
2
- * Created by kgrube on 12/15/2015.
3
- * @author kgrube
4
- */
5
-
6
- /**
7
- * @typedef {object} ServiceDeskAPI
8
- * @property {Tickets} Tickets
9
- * @property {Boards} Boards
10
- * @property {BoardTeams} BoardTeams
11
- * @property {Priorities} Priorities
12
- * @property {Statuses} Statuses
13
- * @property {ServiceNotes} ServiceNotes
14
- * @property {BoardItems} BoardItems
15
- * @property {BoardTypes} BoardTypes
16
- * @property {BoardSubTypes} BoardSubTypes
17
- */
18
-
19
- /**
20
- *
21
- * @param {CWOptions} options
22
- * @returns {ServiceDeskAPI}
23
- * @constructor
24
- */
25
- function ServiceDeskAPI(options) {
26
- const _Tickets = require('./Tickets');
27
- const _Boards = require('./Boards');
28
- const _Priorities = require('./Priorities');
29
- const _BoardTeams = require('./BoardTeams');
30
- const _Statuses = require('./Statuses');
31
- const _ServiceNotes = require('./ServiceNotes');
32
- const _BoardItems = require('./BoardItems');
33
- const _BoardTypes = require('./BoardTypes');
34
- const _BoardSubTypes = require('./BoardSubTypes');
35
-
36
- return {
37
- Tickets: new _Tickets(options),
38
- Boards: new _Boards(options),
39
- BoardTeams: new _BoardTeams(options),
40
- Priorities: new _Priorities(options),
41
- Statuses: new _Statuses(options),
42
- ServiceNotes: new _ServiceNotes(options),
43
- BoardItems: new _BoardItems(options),
44
- BoardTypes: new _BoardTypes(options),
45
- BoardSubTypes: new _BoardSubTypes(options),
46
- };
47
- }
48
-
49
- /**
50
- *
51
- * @type {ServiceDeskAPI}
52
- */
53
- module.exports = ServiceDeskAPI;