In the case of Zendesk#createTickets
it doesn't seem like JobStatus#results
contains Ticket
entities.
Given I want to create multiple tickets, and one or more of those tickets contains a validation error:
JobStatus<Ticket> jobStatus = zendesk.createTickets(tickets);
When I receive the JobStatus (or perform further Zendesk#getJobStatus
), the JSON received is:
{
"job_status": {
"id": "1",
"url": "https://subdomain.zendesk.com/api/v2/job_statuses/1.json",
"total": 1,
"progress": 0,
"status": "failed",
"message": "Failed at 2016-01-15 10:39:18 +0000",
"results": [{
"index": 0,
"error": "TicketCreateFailed",
"details": "Description: cannot be blank"
}]
}
}
But it's deserialized as (toString representation):
JobStatus{
id='1',
url='https://subdomain.zendesk.com/api/v2/job_statuses/1.json',
total=1,
progress=0,
status=failed,
message='Failed at 2016-01-15 10:39:18 +0000',
results=[
Ticket{
assigneeId=null,
id=null,
url='null',
externalId='null',
type='null',
subject='null',
description='null',
/* other properties omitted */
}
]
}
Even when all the tickets are created successfully, deserialization of the JobStatus
may fail as the JSON $.job_status.results.status
value can be Updated
which doesn't map to a Ticket#status
enum value, e.g.:
"results":[
{
"id":4,
"title":"Test 2 - ignore",
"action":"update",
"status":"Updated",
"success":true,
"errors":""
}
will cause:
java.lang.IllegalArgumentException: Can not construct instance of org.zendesk.client.v2.model.Status from String value 'Updated': value not one of declared Enum instance names: [new, open, pending, hold, solved, closed, deleted]
I'm not sure what the answer to this would be but I just wanted to make other people aware of this potential problem.