Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
micronaut:
application:
name: z4j
http:
services:
zendesk:
url: ${:Z4J_URL}
email: ${:Z4J_EMAIL}
token: ${:Z4J_TOKEN}
235 changes: 234 additions & 1 deletion src/main/resources/z4j.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
<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>
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: |-
<p>Accepts a comma-separated list of ticket ids to return.</p>
<p>This endpoint will return up to 100 tickets records.</p>
<h4 id="allowed-for">Allowed For</h4>
<ul>
<li>Agents</li>
</ul>
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
Expand Down Expand Up @@ -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: |-
<p>Returns any users cc&#39;d on the ticket.</p>
<h4 id="availability">Availability</h4>
<p>The <a href="https://support.zendesk.com/hc/en-us/articles/203690846">CCs and Followers</a> feature must be enabled in Zendesk Support.</p>
<p>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&#39;ed on the ticket.</p>
<h4 id="allowed-for">Allowed For</h4>
<ul>
<li>Agents</li>
</ul>
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: |-
<h4 id="allowed-for">Allowed For</h4>
<ul>
<li>Agents</li>
</ul>
parameters:
- $ref: '#/components/parameters/TicketId'
responses:
"200":
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/ListTicketIncidentsResponse'
/api/v2/locales:
get:
operationId: ListLocales
Expand Down Expand Up @@ -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 <a href='https://www.epochconverter.com/'>Unix epoch timeStamp</a>
schema:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1378,6 +1582,12 @@ components:
type: array
items:
type: string
ListTicketEmailCCsResponse:
type: object
additionalProperties: true
ListTicketIncidentsResponse:
type: object
additionalProperties: true
PostComment:
type: object
properties:
Expand Down Expand Up @@ -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: |
Expand Down
44 changes: 44 additions & 0 deletions src/test/groovy/lol/pbu/z4j/client/TicketClientSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}