Skip to content

Instantly share code, notes, and snippets.

View tstachl's full-sized avatar

Thomas Stachl tstachl

  • Pilina
  • Remote
View GitHub Profile
@tstachl
tstachl / download_attachment.sh
Created November 24, 2014 18:31
Download attachment from desk.com using curl.
curl -L https://example.desk.com/api/v2/cases/3061/attachments/82558857/url -u [email protected]:password > my_image.jpg
@tstachl
tstachl / export.rb
Created December 18, 2014 23:44
This is a very rudimentary script of exporting data from desk.com to a CSV file.
require 'desk_api'
require 'csv'
# Create the CSV files
cases = CSV.open('./cases.csv', 'wb')
interactions = CSV.open('./interactions.csv', 'wb')
# Add the headers to the CSV files
cases << ['Case #', 'Subject', 'Description', 'Status']
interactions << ['Case #', 'Body', 'Created Date']
@tstachl
tstachl / create_case_and_reply.php
Created January 15, 2015 00:00
A quick php script that shows how to create a case and then a reply.
<?php
function post($path, $json) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://site.desk.com$path");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_USERPWD, "my-email:my-password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
<?php
$date = new DateTime('2015-01-21T20:34:53Z');
$date->setTimezone(new DateTimeZone('Pacific/Chatham'));
echo $date->format(DateTime::ISO8601);
<div class='input-block'>
<span class='label'>
CUSTOM FIELD LABEL <span>({{system.snippets.required}})</span>
</span>
<div>
{{ ticket_custom_**CUSTOM FIELD KEY** }}
</div>
</div>
{
"type": "email",
"subject": "Email Case Subject",
"priority": 4,
"status": "open",
"labels": [
"Spam",
"Ignore"
],
"message": {
{% if case.group.name == 'Support' %}
<!-- put the case theme for support here -->
{% elsif case.group.name == 'Internal' %}
<!-- put the case theme for internal here -->
{% else %}
<!-- put the case theme for default here -->
{% endif %}
<h2>{{email.subject}}</h2>
{% if email.subject contains 'Suggestion' %}
<h3>This is a suggestion</h3>
{% else %}
<h3>This is default</h3>
{% endif %}
@tstachl
tstachl / DeskApiExample.cs
Created January 24, 2015 21:39
This is an example of how you can interact with the Desk.com API using C#. It shows the 4 basic requests "GET", "POST", "PATCH" and "DELETE". If you have any questions reach out to us at [email protected].
using System;
using System.Text;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json.Linq;
namespace DeskApiExample
{
class MainClass
<!-- different web themes -->
<div id="company-support-portal">
<div id="company-header">
<div class="wrapper">
{{ desk.page.theme.header_content }}
<div id="customer-account">
{% if current_user and current_user.is_guest == false %}
<span>
{{system.snippets.welcome}} {{ current_user.customer.name }}