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 / FetchingLabels.class
Created February 12, 2014 20:28
Shows how you can use the Force.com Desk.com API client to fetch labels from a specific case.
try {
DeskClient client = new DeskClient(new Map<String, String>{
'username' => 'you@example.com',
'password' => 'your_password',
'subdomain' => 'your_subdomain'
});
List<Object> labels = (List<Object>)client.getResource('cases').find(3368).get('labels');
// get the count of the labels
System.debug(labels.size());
@tstachl
tstachl / customer_theme.html
Created February 20, 2014 23:23
This shows how you can use javascript to fetch the assigned group from the case tab and based on the value show an additional custom field on the customer theme.
<div class="agent_customer_section" id="my_custom_field" style="display:none;">
{{custom_my_custom_field}}
</div>
<script>
$(function() {
var case_assigned_group = $('#edit_customer_{{customer.id}}')
.closest('#case_sidebar')
.find('#ticket_group_id option:selected')
.text();
{
"type": "email",
"subject": "Creating a case via the API",
"priority": 4,
"status": "open",
"labels": [
"Spam",
"Ignore"
],
"language": "fr",
{
"direction": "in",
"status": "received",
"to": "Helpdesk <helpdesk@myhelpdesk.com>",
"from": "Jane Doe <jane@example.com>",
"subject": "Replying to a case via the API",
"body": "Please assist me with this case",
"created_at": "2012-05-02T21:38:48Z"
}
<!--If you already have jquery on the page you don't need to insert this script tag-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<link href="https://d218iqt4mo6adh.cloudfront.net/assets/widget_embed_191.css" media="screen" rel="stylesheet" type="text/css" />
<!--If you already have fancybox on the page this script tag should be omitted-->
<script src="https://d218iqt4mo6adh.cloudfront.net/assets/widget_embed_libraries_191.js" type="text/javascript"></script>
<script>
// ********************************************************************************
// This needs to be placed in the document body where you want the widget to render
client.post('/api/v2/customers', {
"emails": [
{
"type": "home",
"value": "jsmith@example.com"
}
],
"custom_fields": {
"user_id": null
}
@tstachl
tstachl / create_qna_case.rb
Created March 7, 2014 19:12
Creating a QNA case using the ruby wrapper ...
require 'desk_api'
DeskApi.configure do |config|
config.username = 'me@support.com'
config.password = 'MyReallySecretPassword'
config.subdomain = 'syncmade'
end
DeskApi.cases.create({
type: 'qna',
@tstachl
tstachl / rauth_test.py
Created April 4, 2014 00:12
RAuth example with desk.com
from rauth import OAuth1Session
import pprint
try:
read_input = raw_input
except NameError:
read_input = input
session = OAuth1Session('YOUR_CONSUMER_KEY',
'YOUR_CONSUMER_SECRET',
@tstachl
tstachl / multipass.cs
Last active August 29, 2015 14:01
C# Multipass example for Desk.com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.IO;
using System.Web;
using System.Diagnostics;
using System.DirectoryServices;
@tstachl
tstachl / CaseThemeAddition.html
Created June 20, 2014 21:47
This is some javascript and css code that allows you to have tabbed email and note replies in desk.com.
<script>
$(function() {
var tid = $('#tabs .ui-state-active a').attr('href').replace('#tabs-tid_', '')
, sel = '#email_reply_div_tid_' + tid
setTimeout(function() {
$(sel).prepend([
'<div>',
' <ul class="reply-toggle">',
' <li class="active">',