Skip to content

Instantly share code, notes, and snippets.

@benilovj
Created May 20, 2013 14:43
Show Gist options
  • Save benilovj/5612671 to your computer and use it in GitHub Desktop.
Save benilovj/5612671 to your computer and use it in GitHub Desktop.
require 'zendesk_api'
require 'yaml'
class ZendeskClientBuilder
def self.build
zendesk_config = YAML.load(File.read('../config/zendesk.yml'))["production"]
ZendeskAPI::Client.new { |config|
config.url = "https://govuk.zendesk.com/api/v2/"
config.username = zendesk_config["username"]
config.password = zendesk_config["password"]
}
end
end
client = ZendeskClientBuilder.build
tickets = client.search(query: 'tags:"a_tag" description:"some string"')
applicable_tickets = []
tickets.all {|ticket| applicable_tickets << ticket unless ticket.tags.include?("some_tag")}
puts "Number of tickets: #{applicable_tickets.size}"
puts applicable_tickets.map(&:id).inspect
applicable_tickets.each do |t|
t.tags += ["some_tag"]
t.save
print "."
end
@omarjimz
Copy link

Hi!
Just wondering if I can use this code somehow to get an alert once there is a new ticket on my queue. I used Distiller applet for Firefox but it is not working anymore for link zendesk.com/agent/dashboard. Any suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment