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
| import requests | |
| import json | |
| SUBDOMAIN = 'myzendesksubdomain' | |
| s = requests.Session() | |
| s.headers.update({"content-type":"application/json"}) | |
| s.auth = ('username@domain/token','VERYSECTRETAPIKEY') | |
| def getTicket(ticket_id, sideloads=[]): | |
| url = "https://{}.zendesk.com/api/v2/tickets/{}.json".format(SUBDOMAIN, ticket_id) |
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
| var request = require('request'); | |
| var util = require('util'); | |
| var config = { | |
| 'username': '[email protected]/token', // email if using password, email/token if token | |
| 'token':'AVERYSECRETAPIKEY', // password or token, see above | |
| 'subdomain': 'my_subdomain' // replace with Zendesk subdomain | |
| }; | |
| function printDone(error, response, body) { // Wrote this to be callback for testing requests |
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
| (function() { | |
| return { | |
| events: { | |
| 'app.activated':'init', | |
| 'ticket.save':'popModal', | |
| 'click #save_ticket': 'onModalSave', | |
| 'click #fail_ticket': 'onModalCancel' | |
| }, |
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
| var app = { | |
| sheet: { | |
| get_row_by_id: function(post_id) { | |
| var sheet = SpreadsheetApp.getActiveSheet(); | |
| var last_row = sheet.getLastRow(); | |
| var columns = sheet.getLastColumn(); | |
| var post_id_column = this.get_column_by_name("Post ID"); | |
| var post_id_range = sheet.getRange(2,post_id_column,last_row,1).getValues(); | |
| var post_id_list = _.flatten(post_id_range, true); | |
| var row_found = (post_id_list.indexOf(post_id)+2); // header + index zero |
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
| import json | |
| import requests | |
| import pprint | |
| # Think about storing these outside the script as a best practice. | |
| # Look into YAML (One standard method of serializing data, like JSON in ways) | |
| # you could store this config object in a YAML file outside the script and just load it in similar to | |
| # how you are loading in your JSON file. This tends to be more secure (sharing scripts is easier, | |
| # you don't have to worry about accidentally publishing secret tokens or private info by accident) |
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
| import json | |
| import requests | |
| import pprint | |
| # Remember to edit the example json file and replace the placeholder topic_id with the appropriate topic_id | |
| with open('test_post.json', 'r', encoding='utf-8') as data_file: #going to change this up a bit to help explain differences | |
| payload_as_object = json.loads(data_file.read()) # Read the string in the file, json.loads() takes json string and converts to a Python object | |
| payload_as_string = json.dumps(payload_as_object) # Here we have changed the object back into a json string, this is what the API expects to recieve | |
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
| (function() { | |
| return { | |
| requests: { | |
| generic_request: function(url, action) { | |
| return { | |
| url: url, | |
| type: action, | |
| contentType: "application/json" |
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 our http client | |
| require 'rest_client' | |
| # Create the 'resource', use basic auth | |
| client = RestClient::Resource.new("https://#{zensubdomain}.zendesk.com","#{zenadminemail}/token","#{zenapitoken}") | |
| # Point to the appropriate nested resource | |
| # We are uploading a file so we tell ruby to read some bytes | |
| # Set the content-type header and provide the required querystring parameter for this endpoint (filename) | |
| response = client['/api/v2/uploads.json'].post File.new("/Path/to/file/upload_example.gif", "rb"), :content_type => 'application/binary', :params => {:filename => "upload_example.gif"} |
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
| /* | |
| * jQuery v1.9.1 included | |
| */ | |
| function get_all_users(total_pages){ | |
| var deferreds = []; // An array to store all our requests | |
| for(x=0;x<total_pages;x++) { | |
| var url = "/api/v2/users?pages=" + (x+1); | |
| deferreds.push($.ajax({url: url})); | |
| } |
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
| makeTextRedaction: function() { | |
| this.$('.text_redact').modal('hide'); | |
| var self = this; | |
| var user_string = this.$('.redaction_string')[0].value; | |
| var comment_data = this.comments; | |
| var matched_comments = _.chain(comment_data) | |
| .filter(function(comment) { // Creates a new object only including comments that contain the user's desired string | |
| var body_text = comment.body; | |
| return body_text.indexOf(user_string) > -1; | |
| }) |