blakmatrix/node-zendesk — pull request #20 by Ignigena (2014-03-05 22:21:53+00:00)
Title: Fix batch ticket action, add batch delete

In it's current incarnation the Ticket updateMany function sends URLs to Zendesk's API as follows:

https://endpoint.zendesk.com/api/v2/tickets/update_many.json?ids=103399&ids=103437&ids=23715&ids=24031&ids=24059&ids=24082&ids=24316

Debugging the object appears correct:

{ ids: [ 103399, 103437, 23715, 24031, 24059, 24082, 24316 ] }

Appears to be an issue with the Querystring module not liking associative arrays. I changed this to pass as a plain query string using Array.toString() which revealed another bug in client.js that caused the URL to be sent to Zendesk as:

https://endpoint.zendesk.com/api/v2/tickets/update_many.json/?ids=103399,103437,23715,24031,24059,24082,24316.json

This is due to the query string being appended to the URL before the .json and params variable are added. I changed this to pass the query string directly to the params variable and the URL is now sent correctly to Zendesk as:

https://endpoint.zendesk.com/api/v2/tickets/update_many.json.json?ids=103399,103437,23715,24031,24059,24082,24316

I've also added support for batch deletion of tickets using Zendesks destroy_many endpoint.