Skip to content

Add createTickets path and tests#3

Open
KKrauss8 wants to merge 9 commits into
mainfrom
krauss/add-create-tickets-path
Open

Add createTickets path and tests#3
KKrauss8 wants to merge 9 commits into
mainfrom
krauss/add-create-tickets-path

Conversation

@KKrauss8

Copy link
Copy Markdown

feat: add path for createTickets. As well as associated objects.

  • JobStatusObject
  • JobStatusObjectResult
  • JobStatusResponse

feat: add tests for createTickets path.

KKrauss8 and others added 2 commits May 9, 2026 18:49
 - JobStatusObject
 - JobStatusObjectResult
 - JobStatusResponse

feat: add tests for createTickets path.

@Jonathan-Zollinger Jonathan-Zollinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR! Some changes on testing syntax, naming and docs.

Great Work!

* @return Create many tickets (status code 200)
*/
@Post("/api/v2/tickets/create_many")
Mono<@Valid JobStatusResponse> createTickets(@Body @Nullable @Valid TicketsCreateRequest ticketsCreateRequest);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Mono<@Valid JobStatusResponse> createTickets(@Body @Nullable @Valid TicketsCreateRequest ticketsCreateRequest);
Mono<@Valid JobStatusResponse> createManyTickets(@Body @Nullable @Valid TicketsCreateRequest ticketsCreateRequest);


/**
* {@summary Create Many Tickets}
* <p>Accepts an array of up to 100 ticket objects. <strong>Note</strong>: Every ticket created with this endpoint may be affected by your business rules, which can include sending email notifications to your end users. If you are importing historical tickets or creating more than 1000 tickets, consider using the <a href=\"/api-reference/ticketing/tickets/ticket_import/#ticket-bulk-import\">Ticket Bulk Import</a> endpoint.</p> <p>This endpoint returns a <code>job_status</code> <a href=\"/api-reference/ticketing/ticket-management/job_statuses/#json-format\">JSON object</a> and queues a background job to do the work. Use the <a href=\"/api-reference/ticketing/ticket-management/job_statuses/#show-job-status\">Show Job Status</a> endpoint to check for the job&#39;s completion. Only a certain number of jobs can be queued or running at the same time. See <a href=\"/api-reference/introduction/rate-limits/#job-limit\">Job limit</a> for more information.</p> <h4 id=\"allowed-for\">Allowed For</h4> <ul> <li>Agents</li> </ul>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* <p>Accepts an array of up to 100 ticket objects. <strong>Note</strong>: Every ticket created with this endpoint may be affected by your business rules, which can include sending email notifications to your end users. If you are importing historical tickets or creating more than 1000 tickets, consider using the <a href=\"/api-reference/ticketing/tickets/ticket_import/#ticket-bulk-import\">Ticket Bulk Import</a> endpoint.</p> <p>This endpoint returns a <code>job_status</code> <a href=\"/api-reference/ticketing/ticket-management/job_statuses/#json-format\">JSON object</a> and queues a background job to do the work. Use the <a href=\"/api-reference/ticketing/ticket-management/job_statuses/#show-job-status\">Show Job Status</a> endpoint to check for the job&#39;s completion. Only a certain number of jobs can be queued or running at the same time. See <a href=\"/api-reference/introduction/rate-limits/#job-limit\">Job limit</a> for more information.</p> <h4 id=\"allowed-for\">Allowed For</h4> <ul> <li>Agents</li> </ul>
* <h1>{@summary Create Many Tickets}</h1>
* Accepts an array of up to 100 ticket objects.
* Every ticket created with this endpoint may be affected by your business rules, which can include sending email notifications to your end users.
* <blockquote>NOTE: This endpoint starts a background job on the zendesk server. The returned object reports on this background job's status.</blockquote>
* <h4 id="allowed-for">Allowed For Agents</h4>

@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Data

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good use of @Data instead of the generator's usage of both a getter and setter annotation!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be titled "JobStatus" and not "JobStatusObject"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not contain "Object" in the title

@Nullable
@JsonProperty(JSON_PROPERTY_STATUS)
@JsonInclude(JsonInclude.Include.USE_DEFAULTS)
private String status;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an enum here for "queued", "working", "failed" and "completed". Update the javadocs to point to the enum options.

you could honestly just copy src/main/java/lol/pbu/z4j/model/SortBy.java and swap out the enum constants.

Comment on lines +210 to +217
List<TicketCreateInput> ticketCreateInputList = new ArrayList<>()
for (int i = 0; i < 100; i++) {
TicketComment ticketComment = new TicketComment().setBody(faker.chuckNorris().fact())
TicketCreateInput createTicketInput = new TicketCreateInput(ticketComment)
createTicketInput.setRawSubject(faker.chuckNorris().fact())
ticketCreateInputList.add(createTicketInput)
}
TicketsCreateRequest createTicketsRequest = new TicketsCreateRequest(ticketCreateInputList)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I was thinking to not try to make so many tickets, but I like this. let's keep it, but let's use some groovy syntactic sugar

Suggested change
List<TicketCreateInput> ticketCreateInputList = new ArrayList<>()
for (int i = 0; i < 100; i++) {
TicketComment ticketComment = new TicketComment().setBody(faker.chuckNorris().fact())
TicketCreateInput createTicketInput = new TicketCreateInput(ticketComment)
createTicketInput.setRawSubject(faker.chuckNorris().fact())
ticketCreateInputList.add(createTicketInput)
}
TicketsCreateRequest createTicketsRequest = new TicketsCreateRequest(ticketCreateInputList)
List<TicketCreateInput> inputs = (1..100).collect {
new TicketCreateInput(new TicketComment().setBody(faker.chuckNorris().fact()))
.setRawSubject(faker.book().title())
}
TicketsCreateRequest createTicketsRequest = new TicketsCreateRequest().setTickets(inputs)

[client, clientType, ignored, alsoIgnored] << clientTestMatrix.findAll { !it.shouldSucceed }
}

def "calling createTickets() fails when trying to create more than the maximum amount(100) of tickets, even when using the correct client"(TicketClient client, String clientType, Boolean ignored, String alsoIgnored) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great test - see my comment on the last test, otherwise this is great

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants