nukosuke / go-zendesk

Zendesk API client library for Go
https://pkg.go.dev/github.com/nukosuke/go-zendesk/zendesk
MIT License
62 stars 81 forks source link

Not parsing audit part of response after updating a ticket. #257

Open hchienjo opened 1 year ago

hchienjo commented 1 year ago

After updating a ticket, only the ticket part of the response from zendesk is parsed and the audit part is discarded. Is it possible to add it as we have encountered a use case for that?

nukosuke commented 1 year ago

What endpoint are you using? I guess that response of Ticket API doesn't have audit info. You could use Ticket Audit API instead.

https://pkg.go.dev/github.com/nukosuke/go-zendesk/zendesk#Client.GetTicketAudits

hchienjo commented 1 year ago

PUT request to /api/v2/tickets/{ticketID}.json to update a ticket, like for example adding a comment to a ticket.

nukosuke commented 1 year ago

audits can be retrieved only from dedicated endpoint, maybe. https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_audits/#list-audits-for-a-ticket

So, you should send another GET request to /api/v2/tickets/{ticket_id}/audits after updating the ticket.

hchienjo commented 1 year ago

In the example from zendesk documentation after updating a ticket, the response payload has an audit event. I am thinking of a case where you want to see the audit of changes done to the ticket directly related to the update you have just done.

nukosuke commented 1 year ago

oh, I didn't know. Thank you for the information.

Then, this method seems discard "audit" payload as you said. https://github.com/nukosuke/go-zendesk/blob/e68b5451c9ee694bef450ddd617013d142836985/zendesk/ticket.go#L262-L265

I am thinking of a case where you want to see the audit of changes done to the ticket directly related to the update you have just done.

To support this case, we should add new method which returns audit events.

hchienjo commented 1 year ago

Will you be able to work on it? I can take this up given the name that you want for the new method name? Maybe we can call it UpdateTicketWithAudit?