Skip to content

Instantly share code, notes, and snippets.

@RobBuijs
Forked from Skeyelab/readme.md
Created October 5, 2017 12:56
Show Gist options
  • Save RobBuijs/684883ccbf3783720d2d7aa3b4f22e38 to your computer and use it in GitHub Desktop.
Save RobBuijs/684883ccbf3783720d2d7aa3b4f22e38 to your computer and use it in GitHub Desktop.
Zendesk Dashing Widget

i'll add some documentaton, but it should be pretty straight forward from the comments

add gem 'zendesk_api', '~> 1.4.3' to your gemfile

<% content_for :title do %>Zendesk View Dashboard<% end %>
<div class="gridster">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="1234" data-view="Number" data-title="Some cool view" data-suffix=""></div>
</li>
<li data-row="1" data-col="2" data-sizex="1" data-sizey="1">
<div data-id="1235" data-view="Number" data-title="Another cool view" data-suffix=""></div>
</li>
</div>
require 'zendesk_api'
client = ZendeskAPI::Client.new do |config|
config.url = "https://domain.zendesk.com/api/v2" # e.g. https://mydesk.zendesk.com/api/v2
config.username = "[email protected]"
config.token = "TOKEN_HERE"
config.retry = true
end
# array of view IDs to check, these are your data-id's in your erb file.
views = [1234,1235]
SCHEDULER.every '1m', :first_in => 0 do |job|
counts = client.view_counts(:ids => views, :path => 'views/count_many')
counts.all do |ct|
if ct.fresh
puts "sending "+ct.view_id.to_s+" : "+ct.value.to_s
send_event(ct.view_id.to_i, { current: ct.value.to_i})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment