Skip to content

Instantly share code, notes, and snippets.

View dpawluk's full-sized avatar

Daniel Pawluk dpawluk

  • Zendesk
  • Wisconsin
View GitHub Profile
@dpawluk
dpawluk / do_the_things_v1.js
Created December 6, 2016 20:41
Get PDF from URL, create Object URL, then download/open in a browser window
(function() {
return {
events: {
'app.activated':'init'
},
init: function() {
var self = this;
@dpawluk
dpawluk / dupe_fields.py
Last active October 19, 2016 21:12
copy value from 'old_field' to 'new_field' on all users, replace instances of 'old_field' and 'new_field' with the appropriate keys
import json
import requests
import math
config = {
"subdomain": "", ## Your Zendesk subdomain
"admin_user": "", ## An Administrator user's email
"token": "" ## Your Zednesk API token
}
@dpawluk
dpawluk / iframe.html
Created October 17, 2016 20:21
Modified code provided by a customer to show some defects in the framework
<html>
<head>
<link href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<select id="selectId">
<option>111</option>
<option>222</option>
@dpawluk
dpawluk / update_comment_author_id.rb
Created October 3, 2016 16:09
updating a ticket with author_id on comment using ruby client
ticket_to_update = client.ticket.find(:id => 4037) #Get the ticket we are updating
author_user = client.users.search(query: "[email protected]").first #now get the user object for said author (wrapper expects user objects for author_id I think...
ticket_to_update.comment = {value: "some comment", public: true, author_id: author_user.id } #update the comment, author_id, etc
ticket.save! #save it
#this worked for me
(function() {
return {
events: {
'app.activated': 'init',
'ticket.requester.id.changed': 'onRequesterChanged'
},
init: function() {
@dpawluk
dpawluk / filter_comments_ruby_api_client.rb
Last active August 26, 2016 15:51
comments.json resource with system/via and data not relevant to the example stripped. Shows how to filter this comments page using the ruby client and built-in ruby functions. The example comments follow this pattern: foo = private, bar = public
# This script assumes you have instantiated a ZendeskAPI::Client and assigned it to 'client'
ticket = client.tickets.find(:id => 4060)
comments = ticket.comments.fetch
# Iterate over comments and show comment value and value for the 'public' attribute (using example json public comments are 'bar' and private are 'foo')
comments.each do |c|
puts "the comment value is #{c.body}"
puts "the comments 'public' attribute is #{c.public}"
end;nil
@dpawluk
dpawluk / update_org_cf_options.rb
Created August 16, 2016 17:06
Updating a dropdown for org custom fields with the ruby client
test = client.organization_fields.find(:id => 132127)
old_options = test.custom_field_options
old_options << {"id"=>nil,"name"=>"newname2","value"=>"newvalue2"}
test.custom_field_options = []
test.changed?
#returns true at this point
test.custom_field_options = old_options
test.save
@dpawluk
dpawluk / breaking_pn_ex.md
Last active July 27, 2016 12:46
Further examples of how the change to validate phone numbers as E.164 compliant can will break

##Example: Creating a user when the phone number must be valid *See Documentation

SUCCESS:

URL:

POST /api/v2/users.json
@dpawluk
dpawluk / article_template.html
Last active July 5, 2016 18:03
Code for creating a related articles widget using that uses labels to relate articles instead of whatever algorithm is used by default
<aside class="article-sidebar side-column">
{{recent_articles}}
<!-- BEGIN CUSTOM SECTION FOR ARTICLES RELATED BY LABEL -->
<section class="articles-related" id="label_related">
<h3>Related articles</h3>
<img id="label_rel_spinner" src="//p5.zdassets.com/hc/theme_assets/413487/200013043/loading.gif"/> <!-- You get this URL after uploading the loading.gif to assets -->
<!-- source image uploaded to imgur here - http://i.imgur.com/JPrUDDz.gifv -->
</section>
@dpawluk
dpawluk / upload_article_attachment.py
Last active June 17, 2016 19:14
Upload a file to help center article using Python Requests
import requests
import json
SUBDOMAIN = 'SUBDOMAIN'
s = requests.Session()
s.auth = ('email@domain/token','VERYSECRETAPITOKEN')
def upload_attachment(article_id, path):