Created
May 20, 2013 14:43
-
-
Save benilovj/5612671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?