· 4 years ago · Aug 24, 2021, 04:24 PM
1describe "Tickets API" do
2 path "/api/v1/{customer_id}/projects/{project_id}/tickets/load" do
3 get "Retrieves All tickets" do
4 tags "Tickets"
5 produces "application/json"
6 description "Load all tickets from a specific project <br />
7 Without any extra parameters it will return the first 100 tickets ordered by ID ascending. Extra parameters can be added to filter and sort the results.<br />
8 <b>Ticket Sorting:</b>
9 Field name to sort the results based on it, sort is always ascending unless the field name is prefixed with a minus (U+002D HYPHEN-MINUS, “-“) i.e. `-id` or `id`
10 <br /><b>Example: </b> `tickets/load?sort=-component_id`<br />
11 <b>Ticket Filtring:</b>
12 You can use a saved filter by providing its id to the `apply_filter` parameter. Also, you can use the on-fly filters.<br />
13 <b>On-Fly Filters</b>
14 You can filter tickets based on the value of any of its attributes<br />
15 <b>Example #1:</b> All tickets where status is open
16 `tickets/load?filter[status_id]=1`<br/>
17 <b>Example #2:</b> All tickets where status is open, and priority is high
18 `tickets/load?filter[status_id]=1&filter[prority_id]=3`
19 <br />
20 <b>Status Dictionary:</b> [1= Open, 2 = In-Progress, 3 = Resolved, 4 = Feedback, 5 = Closed, 6 = Rejected]
21 <b>Priority Dictionary:</b> [1 = Low, 2 = Normal, 3 = High]
22 <br />
23 <b>Pages</b>
24 100 tickets are displayed per page. Change the page with the page parameter.
25 <br /><b>Example: </b> `tickets/load?page=1`
26 "
27 parameter name: :customer_id, :in => :path, :type => :string
28 parameter name: :project_id, :in => :path, :type => :string, :description => "Set project_id to `0` if you want to load tickets from all projects"
29 parameter name: :page, :in => :query, :type => :integer
30 parameter name: :pagesize, :in => :query, :type => :integer, :description => "Maximum is 500, default is 100"
31 parameter name: :last_sync_date, :in => :query, :type => :string
32 parameter name: :sort, :in => :query, :type => :string
33 parameter name: :filter, :in => :query, :type => :string
34 parameter name: :apply_filter, :in => :query, :type => :string
35 parameter name: :search, :in => :query, :type => :string, :description => "Search keyword to filter tickets based on it"
36
37 response "200", "ticktes found" do
38 schema type: :object,
39 properties: {
40 id: { type: :integer },
41 subject: { type: :string },
42 },
43 required: ["id", "subject"]
44
45 # let(:id) { Blog.create(title: 'foo', content: 'bar').id }
46 # run_test!
47 end
48
49 response "406", "unsupported accept header" do
50 let(:'Accept') { "application/foo" }
51 run_test!
52 end
53 end
54 end
55
56 path "/api/v1/{customer_id}/projects/{project_id}/tickets/checksum" do
57 get "Get the checksum of all the ticket UUIDs for a specific project" do
58 tags "Tickets"
59 produces "application/json"
60 parameter name: :customer_id, :in => :path, :type => :string
61 parameter name: :project_id, :in => :path, :type => :string
62
63 response "200", "checksum" do
64 schema type: :object,
65 properties: {
66 id: { type: :integer },
67 subject: { type: :string },
68 },
69 required: ["id", "subject"]
70
71 # let(:id) { Blog.create(title: 'foo', content: 'bar').id }
72 # run_test!
73 end
74
75 response "406", "unsupported accept header" do
76 let(:'Accept') { "application/foo" }
77 run_test!
78 end
79 end
80 end
81
82 path "/api/v1/{customer_id}/projects/{project_id}/tickets/recurring_reminders" do
83 get "Load all recurring reminders for one user" do
84 tags "Tickets"
85 produces "application/json"
86 parameter name: :customer_id, :in => :path, :type => :string
87 parameter name: :project_id, :in => :path, :type => :string
88 parameter name: :page, :in => :query, :type => :integer
89 parameter name: :pagesize, :in => :query, :type => :integer, :description => "Maximum is 500, default is 100"
90 parameter name: :last_sync_date, :in => :query, :type => :string
91
92 response "200", "checksum" do
93 schema type: :object,
94 properties: {
95 id: { type: :integer },
96 subject: { type: :string },
97 },
98 required: ["id", "subject"]
99
100 # let(:id) { Blog.create(title: 'foo', content: 'bar').id }
101 # run_test!
102 end
103
104 response "406", "unsupported accept header" do
105 let(:'Accept') { "application/foo" }
106 run_test!
107 end
108 end
109 end
110
111
112 path "/api/v1/{customer_id}/projects/{project_id}/tickets/ticket_types_stats" do
113 get "Retrieves The count of tickets groupped by ticket types" do
114 tags "Tickets"
115 produces "application/json"
116 parameter name: :customer_id, :in => :path, :type => :string
117 parameter name: :project_id, :in => :path, :type => :string
118 parameter name: :filter, :in => :query, :type => :string, :description => "Used to filter tickets based on any conditions of the related model, filter[author_id]=1 will list all tickets related to this author id, similar to filter[author.id]=1, the second one will use the condition based on the user table such a filter is available filter[author.email]=test@email.com, for multiple values for the same filter use filter[id][]=PN&filter[id][]=nE,,,, available models are: customer, ticket_type, project, component, status, ticket, author, assigned_to, updated_by, due_by, overdue_by, creation_period"
119 parameter name: :apply_filter, :in => :query, :type => :string, :description => "ID of the custom filter to be applied before returning the data"
120
121 response "200", "ticktes found" do
122 schema type: :object,
123 properties: {
124 id: { type: :integer },
125 subject: { type: :string },
126 },
127 required: ["id", "subject"]
128 end
129
130 response "406", "unsupported accept header" do
131 let(:'Accept') { "application/foo" }
132 run_test!
133 end
134 end
135 end
136
137 path "/api/v1/{customer_id}/projects/{project_id}/tickets/general_stats" do
138 get "return some statistics about current user and tickets" do
139 tags "Tickets"
140 produces "application/json"
141 parameter name: :customer_id, :in => :path, :type => :string
142 parameter name: :project_id, :in => :path, :type => :string
143 parameter name: :filter, :in => :query, :type => :string, :description => "Used to filter tickets based on any conditions of the related model, filter[author_id]=1 will list all tickets related to this author id, similar to filter[author.id]=1, the second one will use the condition based on the user table such a filter is available filter[author.email]=test@email.com, for multiple values for the same filter use filter[id][]=PN&filter[id][]=nE,,,, available models are: customer, ticket_type, project, component, status, ticket, author, assigned_to, updated_by, due_by, overdue_by, creation_period"
144 parameter name: :apply_filter, :in => :query, :type => :string, :description => "ID of the custom filter to be applied before returning the data"
145
146 response "200", "ticktes found" do
147 schema type: :object,
148 properties: {
149 id: { type: :integer },
150 subject: { type: :string },
151 },
152 required: ["id", "subject"]
153 end
154
155 response "406", "unsupported accept header" do
156 let(:'Accept') { "application/foo" }
157 run_test!
158 end
159 end
160 end
161
162 path "/api/v1/{customer_id}/projects/{project_id}/tickets/statistics" do
163 get "Get ticket status statistics for each day" do
164 tags "Tickets"
165 produces "application/json"
166 parameter name: :customer_id, :in => :path, :type => :string
167 parameter name: :project_id, :in => :path, :type => :string
168 parameter name: :filter, :in => :query, :type => :string, :description => "Used to filter tickets based on any conditions of the related model, filter[author_id]=1 will list all tickets related to this author id, similar to filter[author.id]=1, the second one will use the condition based on the user table such a filter is available filter[author.email]=test@email.com, for multiple values for the same filter use filter[id][]=PN&filter[id][]=nE,,,, available models are: customer, ticket_type, project, component, status, ticket, author, assigned_to, updated_by, due_by, overdue_by, creation_period"
169 parameter name: :apply_filter, :in => :query, :type => :string, :description => "ID of the custom filter to be applied before returning the data"
170
171 response "200", "ticktes found" do
172 schema type: :object,
173 properties: {
174 id: { type: :integer },
175 subject: { type: :string },
176 },
177 required: ["id", "subject"]
178 end
179
180 response "406", "unsupported accept header" do
181 let(:'Accept') { "application/foo" }
182 run_test!
183 end
184 end
185 end
186
187 path "/api/v1/{customer_id}/projects/{project_id}/tickets/multi_update" do
188 put "Multi Update Tickets based on the provided filteration, no filter will update all data for the project id" do
189 tags "Tickets"
190 description "Multi update tickets, for typed values it has to be grouped by the ticket type, all any other fields should be added in the attributes, the key is the field name, the value is the new value, filter data is OPTIONAL and can be used in either the query string or in the body of the request or both"
191 produces "application/json"
192 parameter name: :customer_id, :in => :path, :type => :string
193 parameter name: :project_id, :in => :path, :type => :string
194 parameter name: :filter, :in => :query, :type => :string, :description => "Used to filter tickets based on any conditions of the related model, filter[author_id]=1 will list all tickets related to this author id, similar to filter[author.id]=1, the second one will use the condition based on the user table such a filter is available filter[author.email]=test@email.com, for multiple values for the same filter use filter[id][]=PN&filter[id][]=nE,,,, available models are: customer, ticket_type, project, component, status, ticket, author, assigned_to, updated_by, due_by, overdue_by, creation_period"
195 parameter name: :apply_filter, :in => :query, :type => :string, :description => "ID of the custom filter to be applied before returning the data"
196 parameter name: :multi_update_object, in: :body, schema: {
197 type: :object,
198 properties: {
199 data: {
200 type: :object,
201 properties: {
202 attributes: { type: :object, properties: { "field-name": { type: :string } } },
203 ticket_type_id: { type: :object, properties: { "typed-field-id": { type: :string } } },
204 },
205 },
206 filter: {
207 type: :object,
208 properties: {
209 uuid: { type: :array, items: { type: :string } },
210 },
211 },
212 apply_filter: { type: :string },
213 },
214 required: ["title", "content"],
215 }
216 response "200", "ticktes found" do
217 schema type: :object,
218 properties: {
219 id: { type: :integer },
220 subject: { type: :string },
221 },
222 required: ["id", "subject"]
223 end
224
225 response "406", "unsupported accept header" do
226 let(:'Accept') { "application/foo" }
227 run_test!
228 end
229 end
230 end
231
232 path "/api/v1/{customer_id}/projects/{project_id}/tickets/delete" do
233 post "Multi delete Tickets based on the provided filteration, no filter will delete all data for the project id" do
234 tags "Tickets"
235 description "Multi delete tickets"
236 produces "application/json"
237 parameter name: :customer_id, :in => :path, :type => :string
238 parameter name: :project_id, :in => :path, :type => :string
239 parameter name: :filter, :in => :query, :type => :string, :description => "Used to filter tickets based on any conditions of the related model, filter[author_id]=1 will list all tickets related to this author id, similar to filter[author.id]=1, the second one will use the condition based on the user table such a filter is available filter[author.email]=test@email.com, for multiple values for the same filter use filter[id][]=PN&filter[id][]=nE,,,, available models are: customer, ticket_type, project, component, status, ticket, author, assigned_to, updated_by, due_by, overdue_by, creation_period"
240 parameter name: :apply_filter, :in => :query, :type => :string, :description => "ID of the custom filter to be applied before returning the data"
241 parameter name: :multi_update_object, in: :body, schema: {
242 type: :object,
243 properties: {
244 filter: {
245 type: :object,
246 properties: {
247 uuid: { type: :array, items: { type: :string } },
248 },
249 },
250 apply_filter: { type: :string },
251 },
252 required: ["title", "content"],
253 }
254 response "200", "ticktes found" do
255 schema type: :object,
256 properties: {
257 id: { type: :integer },
258 subject: { type: :string },
259 },
260 required: ["id", "subject"]
261 end
262
263 response "406", "unsupported accept header" do
264 let(:'Accept') { "application/foo" }
265 run_test!
266 end
267 end
268 end
269
270 path "/api/v1/{customer_id}/projects/{project_id}/tickets/parent_tickets" do
271 get "Retrieves All candidate parent tickets" do
272 tags "Tickets"
273 produces "application/json"
274 parameter name: :customer_id, :in => :path, :type => :string
275 parameter name: :project_id, :in => :path, :type => :string
276 parameter name: :id, :in => :query, :type => :integer, :description => "UUID of a ticket to be execluded from the output"
277 parameter name: :page, :in => :query, :type => :integer
278 parameter name: :pagesize, :in => :query, :type => :integer, :description => "Maximum is 500, default is 100"
279 parameter name: :search, :in => :query, :type => :string, :description => "search keyword, using LIKE %{KEYWORD}%, minimum search keyowrd length is 4 charachters"
280
281 response "200", "ticktes found" do
282 schema type: :object,
283 properties: {
284 id: { type: :integer },
285 subject: { type: :string },
286 },
287 required: ["id", "subject"]
288 end
289
290 response "404", "blog not found" do
291 let(:id) { "invalid" }
292 run_test!
293 end
294
295 response "406", "unsupported accept header" do
296 let(:'Accept') { "application/foo" }
297 run_test!
298 end
299 end
300 end
301
302 path "/api/v1/{customer_id}/projects/{project_id}/tickets/search" do
303 get "Search tickets using elastic search" do
304 tags "Tickets"
305 produces "application/json"
306 parameter name: :customer_id, :in => :path, :type => :string
307 parameter name: :project_id, :in => :path, :type => :string
308 parameter name: :q, :in => :query, :type => :string, :description => "Search query"
309 parameter name: :filter, :in => :query, :type => :string, :description => "Used to filter tickets based on any conditions of the related model, filter[author_id]=1 will list all tickets related to this author id, similar to filter[author.id]=1, the second one will use the condition based on the user table such a filter is available filter[author.email]=test@email.com, for multiple values for the same filter use filter[id][]=PN&filter[id][]=nE,,,, available models are: customer, ticket_type, project, component, status, ticket, author, assigned_to, updated_by"
310 parameter name: :page, :in => :query, :type => :integer
311 parameter name: :pagesize, :in => :query, :type => :integer, :description => "Maximum is 500, default is 100"
312 parameter name: :sort, :in => :query, :type => :string, :description => 'The ticket`s attribute to order by, or a typed-field key, e.g. "due-date" or "8ec806b6". When prefixed with a "-", the sort order is DESCENDING, else the order is ASCENDING."'
313 parameter name: :apply_filter, :in => :query, :type => :string, :description => "ID of the custom filter to be applied before returning the data"
314
315 response "200", "ticktes found" do
316 schema type: :object,
317 properties: {
318 id: { type: :integer },
319 subject: { type: :string },
320 },
321 required: ["id", "subject"]
322 end
323
324 response "404", "blog not found" do
325 let(:id) { "invalid" }
326 run_test!
327 end
328
329 response "406", "unsupported accept header" do
330 let(:'Accept') { "application/foo" }
331 run_test!
332 end
333 end
334 end
335
336 path "/api/v1/{customer_id}/projects/{project_id}/tickets/{uuid}" do
337 get "Show one ticket based on its UUID" do
338 tags "Tickets"
339 produces "application/json"
340 parameter name: :customer_id, :in => :path, :type => :string
341 parameter name: :project_id, :in => :path, :type => :string
342 parameter name: :uuid, :in => :path, :type => :string
343
344 response "200", "ticktes found" do
345 schema type: :object,
346 properties: {
347 id: { type: :integer },
348 subject: { type: :string },
349 },
350 required: ["id", "subject"]
351 end
352
353 response "404", "Ticket Not found" do
354 let(:id) { "invalid" }
355 run_test!
356 end
357 end
358
359 put "Update one ticket" do
360 tags "Tickets"
361 produces "application/json"
362 security [apiKey: []]
363 parameter name: :customer_id, :in => :path, :type => :string
364 parameter name: :project_id, :in => :path, :type => :string
365 parameter name: :uuid, :in => :path, :type => :string, :description => 'UUID of the ticket to load'
366 parameter name: :ticket, in: :body, schema: {
367 type: :object,
368 properties: {
369 data: {
370 type: :object,
371 properties: {
372 attributes: {
373 "$ref": "#/definitions/Ticket"
374 },
375 },
376 },
377 },
378 required: ["title", "content"],
379 }
380
381 response "200", "ticktes found" do
382 schema type: :object,
383 properties: {
384 id: { type: :integer },
385 subject: { type: :string },
386 },
387 required: ["id", "subject"]
388 end
389
390 response "404", "Ticket Not found" do
391 let(:id) { "invalid" }
392 run_test!
393 end
394 end
395
396 patch "Update one ticket" do
397 tags "Tickets"
398 produces "application/json"
399 security [apiKey: []]
400 parameter name: :customer_id, :in => :path, :type => :string
401 parameter name: :project_id, :in => :path, :type => :string
402 parameter name: :uuid, :in => :path, :type => :string, :description => 'UUID of the ticket to update'
403 parameter name: :ticket, in: :body, schema: {
404 type: :object,
405 properties: {
406 data: {
407 type: :object,
408 properties: {
409 attributes: {
410 "$ref": "#/definitions/Ticket"
411 },
412 },
413 },
414 },
415 required: ["title", "content"],
416 }, "description" => "Schedule documentation: https://git.defectradar.com/root/defectradarserver/wikis/recurring-reminders-schedule-structure"
417
418 response "200", "ticktes found" do
419 schema type: :object,
420 properties: {
421 id: { type: :integer },
422 subject: { type: :string },
423 },
424 required: ["id", "subject"]
425 end
426
427 response "404", "Ticket Not found" do
428 let(:id) { "invalid" }
429 run_test!
430 end
431 end
432
433 delete "Delete one ticket" do
434 tags "Tickets"
435 produces "application/json"
436 security [apiKey: []]
437 parameter name: :customer_id, :in => :path, :type => :string
438 parameter name: :project_id, :in => :path, :type => :string
439 parameter name: :uuid, :in => :path, :type => :string, :description => 'UUID of the ticket to delete'
440
441 response "200", "Ticktes Deleted" do
442 schema type: :object,
443 properties: {
444 id: { type: :integer },
445 subject: { type: :string },
446 },
447 required: ["id", "subject"]
448 end
449
450 response "404", "Ticket Not found" do
451 let(:id) { "invalid" }
452 run_test!
453 end
454 end
455 end
456
457 path "/api/v1/{customer_id}/projects/{project_id}/tickets/" do
458 get "Retrieves All tickets" do
459 tags "Tickets"
460 description "This API is similar to `tickets/load` API the only difference that it retrieves all children ticket in the same page.
461 Requesting this API with pagesize = 10 will return the first matched 10 tickets plus all their children tickets.<br />
462 Without any extra parameters it will return the first 100 tickets ordered by ID ascending. Extra parameters can be added to filter and sort the results.<br />
463 <b>Ticket Sorting:</b>
464 Field name to sort the results based on it, sort is always ascending unless the field name is prefixed with a minus (U+002D HYPHEN-MINUS, “-“) i.e. `-id` or `id`
465 <br /><b>Example: </b> `tickets/load?sort=-component_id`<br />
466 <b>Ticket Filtring:</b>
467 You can use a saved filter by providing its id to the `apply_filter` parameter. Also, you can use the on-fly filters.<br />
468 <b>On-Fly Filters</b>
469 You can filter tickets based on the value of any of its attributes<br />
470 <b>Example #1:</b> All tickets where status is open
471 `tickets/load?filter[status_id]=1`<br/>
472 <b>Example #2:</b> All tickets where status is open, and priority is high
473 `tickets/load?filter[status_id]=1&filter[prority_id]=3`
474 <br />
475 <b>Status Dictionary:</b> [1= Open, 2 = In-Progress, 3 = Resolved, 4 = Feedback, 5 = Closed, 6 = Rejected]
476 <b>Priority Dictionary:</b> [1 = Low, 2 = Normal, 3 = High]
477 <br />
478 <b>Pages</b>
479 100 tickets are displayed per page. Change the page with the page parameter.
480 <br /><b>Example: </b> `tickets/load?page=1`
481 "
482 security [apiKey: []]
483 produces "application/json"
484 parameter name: :customer_id, :in => :path, :type => :string
485 parameter name: :project_id, :in => :path, :type => :string, :description => "Set project_id to `0` if you want to load tickets from all projects"
486 parameter name: :page, :in => :query, :type => :integer
487 parameter name: :pagesize, :in => :query, :type => :integer, :description => "Maximum is 500, default is 100"
488 parameter name: :last_sync_date, :in => :query, :type => :string
489 parameter name: :sort, :in => :query, :type => :string
490 parameter name: :filter, :in => :query, :type => :string
491 parameter name: :apply_filter, :in => :query, :type => :string
492 parameter name: :search, :in => :query, :type => :string, :description => "Search keyword to filter tickets based on it"
493
494 response "200", "Tickets Found" do
495 schema type: :array,
496 required: ["id", "subject"]
497 end
498
499 response "404", "Not Found" do
500 let(:project_id) { "invalid" }
501 run_test!
502 end
503 end
504
505 post "Create one ticket" do
506 tags "Tickets"
507 produces "application/json"
508 security [apiKey: []]
509 parameter name: :customer_id, :in => :path, :type => :string
510 parameter name: :project_id, :in => :path, :type => :string
511 parameter name: :ticket, in: :body, schema: {
512 type: :object,
513 properties: {
514 data: {
515 type: :object,
516 properties: {
517 attributes: {
518 "$ref": "#/definitions/Ticket"
519 },
520 },
521 },
522 },
523 }
524
525 response "200", "ticktes found" do
526 schema type: :object,
527 properties: {
528 id: { type: :integer },
529 subject: { type: :string },
530 },
531 required: ["id", "subject"]
532 end
533
534 response "404", "Ticket Not found" do
535 let(:id) { "invalid" }
536 run_test!
537 end
538 end
539 end
540
541 path "/api/v1/{customer_id}/projects/{project_id}/tickets/{uuid}/comment" do
542 post "Add a comment to a Ticket" do
543 tags "Tickets"
544 produces "application/json"
545 description "Add a comment to a specific ticket."
546 security [apiKey: []]
547 parameter name: :customer_id, :in => :path, :type => :string
548 parameter name: :project_id, :in => :path, :type => :string
549 parameter name: :uuid, :in => :path, :type => :string, :description => 'UUID of the ticket to add a comment to it'
550 parameter name: :comment, in: :body, schema: {
551 type: :object,
552 properties: {
553 data: {
554 type: :object,
555 properties: {
556 attributes: {
557 type: :object,
558 properties: {
559 comment: { type: :string, example: "Hello World!" },
560 created_on: { type: :string, description: 'Optional: leave blank and the current time will be used' },
561 },
562 },
563 },
564 },
565 },
566 required: ["title", "content"],
567 }
568
569 response "200", "Comment added" do
570 schema type: :object,
571 properties: {
572 id: { type: :integer },
573 subject: { type: :string },
574 },
575 required: ["id", "subject"]
576 end
577
578 response "404", "Ticket Not found" do
579 let(:id) { "invalid" }
580 run_test!
581 end
582 end
583 end
584
585 path "/api/v1/{customer_id}/projects/{project_id}/tickets/{uuid}/recurring_reminders" do
586 post "Add or update recurring reminder assigned to a ticket" do
587 tags "Tickets"
588 produces "application/json"
589 security [apiKey: []]
590 parameter name: :customer_id, :in => :path, :type => :string
591 parameter name: :project_id, :in => :path, :type => :string
592 parameter name: :uuid, :in => :path, :type => :string
593 parameter name: :comment, in: :body, schema: {
594 type: :object,
595 properties: {
596 data: {
597 type: :object,
598 properties: {
599 attributes: {
600 type: :object,
601 properties: {
602 "notes": { type: :string },
603 "is_active": { type: :boolean },
604 "raw_schedule": { type: :object },
605 },
606 },
607 },
608 },
609 },
610 required: ["title", "content"],
611 }
612
613 response "200", "Comment added" do
614 schema type: :object,
615 properties: {
616 id: { type: :integer },
617 subject: { type: :string },
618 },
619 required: ["id", "subject"]
620 end
621
622 response "404", "Ticket Not found" do
623 let(:id) { "invalid" }
624 run_test!
625 end
626 end
627 end
628
629 path "/api/v1/{customer_id}/projects/{project_id}/tickets/{uuid}/unsubscribe" do
630 post "Unsubscribe from due date reminders" do
631 tags "Tickets"
632 produces "application/json"
633 security [apiKey: []]
634 parameter name: :customer_id, :in => :path, :type => :string
635 parameter name: :project_id, :in => :path, :type => :string
636 parameter name: :uuid, :in => :path, :type => :string
637
638 response "200", "Comment added" do
639 schema type: :object,
640 properties: {
641 id: { type: :integer },
642 subject: { type: :string },
643 },
644 required: ["id", "subject"]
645 end
646
647 response "404", "Ticket Not found" do
648 let(:id) { "invalid" }
649 run_test!
650 end
651 end
652 end
653
654 path "/api/v1/{customer_id}/projects/{project_id}/tickets/mark_tickets_as_read" do
655 post "Mark tickets as seen" do
656 tags "Tickets"
657 produces "application/json"
658 security [apiKey: []]
659 parameter name: :customer_id, :in => :path, :type => :string
660 parameter name: :project_id, :in => :path, :type => :string
661 parameter name: :params, in: :body, schema: {
662 type: :object,
663 properties: {
664 data: {
665 type: :object,
666 properties: {
667 attributes: {
668 type: :object,
669 properties: {
670 tickets: { type: :array, items: { string: :integer } },
671 },
672 },
673 },
674 },
675 },
676 }
677 response "200", ""
678 response "422", "Invalid parameters provided" do
679 let(:id) { "invalid" }
680 run_test!
681 end
682 end
683 end
684
685 path "/api/v1/{customer_id}/projects/{project_id}/tickets/{uuid}/export" do
686 post "Export single ticket as PDF" do
687 tags "Tickets"
688 produces "application/json"
689 description "Export single ticket as a PDF documnet
690 If images included in the ticket more than 10, the ticket will be exported in a job.
691 <br />
692 <b>timezone_offset</b><br />
693 Is used to convert all dates included in the PDF document to the correct timezone. the value should be the difference in minutes between UTC and your location."
694 security [apiKey: []]
695 parameter name: :customer_id, :in => :path, :type => :string
696 parameter name: :project_id, :in => :path, :type => :string
697 parameter name: :uuid, :in => :path, :type => :string, description: "UUID of the ticket to export"
698 parameter name: :template_id, :in => :query, :type => :string, :description => 'ID of the template to be used for the export OPTIONAL, leave blank and the default template will be used'
699 parameter name: :timezone_offset, :in => :query, :type => :integer
700
701 response "200", "Ticket Exported" do
702 schema type: :object,
703 properties: {
704 id: { type: :integer },
705 subject: { type: :string },
706 },
707 required: ["id", "subject"]
708 end
709
710 response "404", "Ticket Not found" do
711 let(:id) { "invalid" }
712 run_test!
713 end
714 end
715
716 end
717
718 path "/api/v1/{customer_id}/projects/{project_id}/tickets/{uuid}/clone" do
719 post "Clone a ticket" do
720 tags "Tickets"
721 description "Copy all the content of a ticket in a new one."
722 produces "application/json"
723 security [apiKey: []]
724 parameter name: :customer_id, :in => :path, :type => :string
725 parameter name: :project_id, :in => :path, :type => :string
726 parameter name: :uuid, :in => :path, :type => :string, description: "UUID of the ticket to be cloned"
727 parameter name: :clone_data, in: :body, schema: {
728 type: :object,
729 properties: {
730 data: {
731 type: :object,
732 properties: {
733 attributes: {
734 type: :object,
735 properties: {
736 uuid: { type: :string, description: "New ticket UUID, leave blank, a new UUID will be generated" },
737 "plan-x": { type: :number, description: "The new plan-x position of the new ticket" },
738 "plan-y": { type: :number, description: "The new plan-y position of the new ticket" },
739 },
740 },
741 },
742 },
743 },
744 required: ["uuid"],
745 }
746
747 response "200", "Ticket cloned" do
748 schema type: :object,
749 properties: {
750 id: { type: :integer },
751 subject: { type: :string },
752 },
753 required: ["id", "subject"]
754 end
755
756 response "404", "Ticket Not found" do
757 let(:id) { "invalid" }
758 run_test!
759 end
760 end
761 end
762
763 path "/api/v1/{customer_id}/projects/{project_id}/tickets/auto_complete_title" do
764 get "Autocomplete for tickets titles" do
765 tags "Tickets"
766 produces "application/json"
767 security [apiKey: []]
768 parameter name: :customer_id, :in => :path, :type => :string
769 parameter name: :project_id, :in => :path, :type => :string
770 parameter name: :searchterm, :in => :path, :type => :string
771
772 response "200", "Ticket cloned" do
773 schema type: :array,
774 required: ["id", "subject"]
775 end
776
777 response "404", "empty array" do
778 let(:searchterm) { "not exist" }
779 run_test!
780 end
781 end
782 end
783
784 path "/api/v1/{customer_id}/projects/{project_id}/tickets/{id}/check_ticket" do
785 get "Check if ticket exists" do
786 tags "Tickets"
787 produces "application/json"
788 parameter name: :customer_id, :in => :path, :type => :string
789 parameter name: :project_id, :in => :path, :type => :string
790 parameter name: :uuid, :in => :path, :type => :string
791
792 response "200", "Found Ticket" do
793 schema type: :array,
794 required: ["id", "subject"]
795 end
796
797 response "404", "Ticket Not Found" do
798 let(:uuid) { "not exist" }
799 run_test!
800 end
801 end
802 end
803
804 path "/api/v1/{customer_id}/projects/{defectradar_project_id}/tickets" do
805 post "Create a new issue" do
806 tags "Tickets"
807 security [apiKey: []]
808 produces "application/json"
809 parameter name: :customer_id, :in => :path, :type => :string
810 parameter name: :defectradar_project_id, :in => :path, :type => :string
811 parameter name: :device, :in => :body, schema: {
812 type: :object,
813 properties: {
814 data: {
815 type: :object,
816 properties: {
817 attributes: {
818 type: :object,
819 properties: {
820 "created_on": { type: :string },
821 "due_date": { type: :string },
822 "updated_on": { type: :string },
823 "attempt_id": { type: :integer },
824 "subject": { type: :string },
825 "plan_x": { type: :number },
826 "plan_y": { type: :number },
827 "project_id": { type: :string },
828 "assigned_to_id": { type: :string },
829 "author_id": { type: :string },
830 "component_id": { type: :string },
831 "plan_id": { type: :string },
832 "status_id": { type: :string },
833 "priority_id": { type: :string },
834 "done_ratio": { type: :string },
835 },
836 },
837 },
838 },
839 },
840 }
841
842 response "200", "Issue Created" do
843 schema type: :array,
844 required: ["id", "subject"]
845 end
846
847 response "404", "Not Found" do
848 let(:defectradar_project_id) { "invalid" }
849 run_test!
850 end
851 end
852 end
853
854 path "/api/{customer_id}/projects/{defectradar_project_id}/tickets/{defectradar_issue_id}/ticket_images" do
855 post "Add new image to issue" do
856 tags "Tickets"
857 security [apiKey: []]
858 produces "application/json"
859 parameter name: :customer_id, :in => :path, :type => :string
860 parameter name: :defectradar_project_id, :in => :path, :type => :string
861 parameter name: :defectradar_issue_id, :in => :path, :type => :string
862 parameter name: :device, :in => :body, schema: {
863 type: :object,
864 properties: {
865 "attempt_id": { type: :string },
866 "file_base64": { type: :string },
867 "file_content_type": { type: :string },
868 "file_name": { type: :string },
869 "image_type": { type: :string },
870 },
871 }
872
873 response "200", "Image Added" do
874 schema type: :array,
875 required: ["id", "subject"]
876 end
877
878 response "404", "Not Found" do
879 let(:defectradar_issue_id) { "invalid" }
880 run_test!
881 end
882 end
883 end
884
885 path "/api/{customer_id}/projects/{defectradar_project_id}/tickets/{defectradar_issue_id}/ticket_audios" do
886 post "Add new audio to issue" do
887 tags "Tickets"
888 security [apiKey: []]
889 produces "application/json"
890 parameter name: :customer_id, :in => :path, :type => :string
891 parameter name: :defectradar_project_id, :in => :path, :type => :string
892 parameter name: :defectradar_issue_id, :in => :path, :type => :string
893 parameter name: :device, :in => :body, schema: {
894 type: :object,
895 properties: {
896 "attempt_id": { type: :string },
897 "file_base64": { type: :string },
898 "file_content_type": { type: :string },
899 "issue_id": { type: :string },
900 },
901 }
902
903 response "200", "Audio Added" do
904 schema type: :array,
905 required: ["id", "subject"]
906 end
907
908 response "404", "Not Found" do
909 let(:defectradar_issue_id) { "invalid" }
910 run_test!
911 end
912 end
913 end
914
915 path "/api/{customer_id}/projects/{defectradar_project_id}/tickets/test_notification" do
916 post "Trigger a test notification" do
917 tags "Tickets"
918 security [apiKey: []]
919 produces "application/json"
920 parameter name: :customer_id, :in => :path, :type => :string
921 parameter name: :defectradar_project_id, :in => :path, :type => :string
922
923 response "200", "Success" do
924 schema type: :array,
925 required: ["id", "subject"]
926 end
927
928 response "404", "Not Found" do
929 let(:defectradar_project_id) { "invalid" }
930 run_test!
931 end
932 end
933 end
934end
935