diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index 89d3442..230e703 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -1,8 +1,9 @@ name: Test on: - pull_request: + pull_request_target: branches: - "main" + - "Ticket-Feature" - "[0-9]+.[0-9]+.[0-9]+" # release branches jobs: build-and-analyze: @@ -33,7 +34,7 @@ jobs: if: ${{ github.event.pull_request.base.ref != 'main' && github.event.action != 'closed' }} run: ./gradlew build - name: Sonar Scan - if: ${{ github.event.pull_request.base.ref == 'main' && github.event.action != 'closed' }} # Only run SonarQube on PRs to main + if: ${{ github.event.action != 'closed' }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: ./gradlew build sonar diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..35d5517 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,9 @@ +micronaut: + application: + name: z4j + http: + services: + zendesk: + url: ${:Z4J_URL} + email: ${:Z4J_EMAIL} + token: ${:Z4J_TOKEN} \ No newline at end of file diff --git a/src/main/resources/z4j.yaml b/src/main/resources/z4j.yaml index 9e71288..db92b20 100644 --- a/src/main/resources/z4j.yaml +++ b/src/main/resources/z4j.yaml @@ -204,6 +204,53 @@ paths: application/json: schema: $ref: '#/components/schemas/TicketCountResponse' + /api/v2/tickets/create_many: + post: + operationId: TicketsCreateMany + tags: + - Tickets + summary: Create Many Tickets + description: |- +

Accepts an array of up to 100 ticket objects. Note: 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 Ticket Bulk Import endpoint.

+

This endpoint returns a job_status JSON object and queues a background job to do the work. Use the Show Job Status endpoint to check for the job's completion. Only a certain number of jobs can be queued or running at the same time. See Job limit for more information.

+

Allowed For

+ + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TicketsCreateRequest' + responses: + "200": + description: Create many tickets + content: + application/json: + schema: + $ref: '#/components/schemas/JobStatusResponse' + /api/v2/tickets/show_many: + get: + operationId: TicketsShowMany + tags: + - Ticket + summary: Show Multiple Tickets + description: |- +

Accepts a comma-separated list of ticket ids to return.

+

This endpoint will return up to 100 tickets records.

+

Allowed For

+ + parameters: + - $ref: '#/components/parameters/TicketIds' + responses: + "200": + description: List tickets + content: + application/json: + schema: + $ref: '#/components/schemas/TicketsResponse' /api/v2/tickets/{ticket_id}: get: operationId: ShowTicket @@ -244,6 +291,50 @@ paths: application/json: schema: $ref: '#/components/schemas/TicketUpdateResponse' + /api/v2/tickets/{ticket_id}/email_ccs: + get: + operationId: ListTicketEmailCCs + tags: + - Ticket + summary: List Email CCs for a Ticket + description: |- +

Returns any users cc'd on the ticket.

+

Availability

+

The CCs and Followers feature must be enabled in Zendesk Support.

+

If the feature is not enabled, the default CC functionality is used. In that case, use {@link TicketsClient#listCollaborators(String) List Collaborators} to list the users cc'ed on the ticket.

+

Allowed For

+ + parameters: + - $ref: '#/components/parameters/TicketId' + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/ListTicketEmailCCsResponse' + /api/v2/tickets/{ticket_id}/incidents: + get: + operationId: ListTicketIncidents + tags: + - Ticket + summary: List Ticket Incidents + description: |- +

Allowed For

+ + parameters: + - $ref: '#/components/parameters/TicketId' + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/ListTicketIncidentsResponse' /api/v2/locales: get: operationId: ListLocales @@ -293,7 +384,7 @@ paths: - name: start_time in: query required: false - description: | + description: | You can use the incremental article endpoint to list all the articles that were updated since a certain date and time. This time is given as a Unix epoch timeStamp schema: @@ -1106,6 +1197,18 @@ components: type: string size: type: number + CreateResourceResult: + type: object + properties: + id: + type: integer + description: the id of the new resource + index: + type: integer + description: the index number of the result + required: + - id + - index CustomField: type: object allOf: @@ -1134,6 +1237,30 @@ components: type: text updated_at: "2022-09-07T23:22:00Z" url: https://company.zendesk.com/api/v2/custom_objects/car/fields/4398096842879.json + FailedResult: + type: object + properties: + action: + type: string + description: 'The action the job attempted (`"action": "update"`)' + details: + type: string + description: The details of the error + error: + type: string + description: The error message + id: + type: integer + description: The id of the resource the job attempted to update + success: + type: boolean + description: 'Whether the action was successful or not (`"success": true`)' + required: + - id + - action + - error + - success + - details TicketFieldCustomStatusObject: type: object properties: @@ -1279,6 +1406,83 @@ components: properties: current_session: $ref: '#/components/schemas/HelpCenterSession' + JobStatusObject: + type: object + properties: + id: + type: string + description: Automatically assigned when the job is queued + readOnly: true + job_type: + type: string + description: The type of the job + readOnly: true + message: + type: string + description: Message from the job worker, if any + nullable: true + readOnly: true + progress: + type: integer + description: Number of tasks that have already been completed + nullable: true + readOnly: true + results: + description: Result data from processed tasks. See [Results](#results) below + oneOf: + - type: array + items: + $ref: '#/components/schemas/JobStatusResultObject' + nullable: true + - type: object + properties: + success: + type: boolean + description: Whether the action was successful or not + readOnly: true + required: + - success + readOnly: true + status: + type: string + description: 'The current status. One of the following: "queued", "working", "failed", "completed"' + readOnly: true + total: + type: integer + description: The total number of tasks this job is batching through + nullable: true + readOnly: true + url: + type: string + description: The URL to poll for status updates + readOnly: true + example: + id: 82de0b044094f0c67893ac9fe64f1a99 + message: Completed at 2018-03-08 10:07:04 +0000 + progress: 2 + results: + - action: update + id: 244 + status: Updated + success: true + - action: update + id: 245 + status: Updated + success: true + status: completed + total: 2 + url: https://example.zendesk.com/api/v2/job_statuses/82de0b0467893ac9fe64f1a99 + JobStatusResponse: + type: object + properties: + job_status: + $ref: '#/components/schemas/JobStatusObject' + JobStatusResultObject: + oneOf: + - $ref: '#/components/schemas/CreateResourceResult' + - $ref: '#/components/schemas/UpdateResourceResult' + - $ref: '#/components/schemas/FailedResult' + additionalProperties: true Label: type: object properties: @@ -1378,6 +1582,12 @@ components: type: array items: type: string + ListTicketEmailCCsResponse: + type: object + additionalProperties: true + ListTicketIncidentsResponse: + type: object + additionalProperties: true PostComment: type: object properties: @@ -2707,6 +2917,29 @@ components: type: array items: $ref: '#/components/schemas/UnifiedSearchResult' + UpdateResourceResult: + type: object + properties: + action: + type: string + description: | + the action the job attempted (`"action": "update"`) + id: + type: integer + description: the id of the resource the job attempted to update + status: + type: string + description: | + the status (`"status": "Updated"`) + success: + type: boolean + description: | + whether the action was successful or not (`"success": true`) + required: + - id + - action + - success + - status UserSegment: type: object description: | diff --git a/src/test/groovy/lol/pbu/z4j/client/TicketClientSpec.groovy b/src/test/groovy/lol/pbu/z4j/client/TicketClientSpec.groovy index 856bd6d..6244bc8 100644 --- a/src/test/groovy/lol/pbu/z4j/client/TicketClientSpec.groovy +++ b/src/test/groovy/lol/pbu/z4j/client/TicketClientSpec.groovy @@ -194,4 +194,48 @@ class TicketClientSpec extends Z4jSpec { clientTestMatrix.findAll { !it.shouldSucceed && it.clientType != "simple user"}, [true, false, null], accountLocales ].combinations() } + + def "calling listTicketEmailCCs() succeeds when using a(n) #clientType"(TicketClient client, String clientType, Boolean ignored, String alsoIgnored) { + when: + client.listTicketEmailCCs(tickets.get(0).getId()).block() + + then: + noExceptionThrown() + + where: + [client, clientType, ignored, alsoIgnored] << clientTestMatrix.findAll { it.shouldSucceed } + } + + def "calling listTicketEmailCCs() fails when using a(n) #clientType"(TicketClient client, String clientType, Boolean ignored, String alsoIgnored) { + when: + client.listTicketEmailCCs(tickets.get(0).getId()).block() + + then: + thrown(HttpClientException) + + where: + [client, clientType, ignored, alsoIgnored] << clientTestMatrix.findAll { !it.shouldSucceed } + } + + def "calling listTicketIncidents() succeeds when using a(n) #clientType"(TicketClient client, String clientType, Boolean ignored, String alsoIgnored) { + when: + client.listTicketIncidents(tickets.get(0).getId()).block() + + then: + noExceptionThrown() + + where: + [client, clientType, ignored, alsoIgnored] << clientTestMatrix.findAll { it.shouldSucceed } + } + + def "calling listTicketIncidents() fails when using a(n) #clientType"(TicketClient client, String clientType, Boolean ignored, String alsoIgnored) { + when: + client.listTicketIncidents(tickets.get(0).getId()).block() + + then: + thrown(HttpClientException) + + where: + [client, clientType, ignored, alsoIgnored] << clientTestMatrix.findAll { !it.shouldSucceed } + } }