Skip to content

Instantly share code, notes, and snippets.

View tstachl's full-sized avatar

Thomas Stachl tstachl

  • Pilina
  • Remote
View GitHub Profile
ticket = DeskApi.cases.create({
external_id: 123456,
subject: 'Subject',
description: 'Description',
priority: 1,
status: 'resolved',
type: 'email',
labels: ['Label 1', 'Label 2'],
custom_fields: {
my_key: 'My Value'
@tstachl
tstachl / upload.rb
Created August 7, 2014 00:37
Example on how you can upload customers to desk.com using the desk_api gem.
require 'desk_api'
require 'csv'
DeskApi.configure do |config|
config.username = 'you@example.com'
config.password = 'Top$ecret1'
config.endpoint = 'https://example.desk.com'
end
CSV.foreach('./customers.csv', headers: true) do |csv|
@tstachl
tstachl / script.rb
Created August 13, 2014 19:41
DeskApi Timeout fix
require 'desk_api'
DeskApi::Default::CONNECTION_OPTIONS[:request] = {
open_timeout: 45,
timeout: 45
}
client = DeskApi::Client.new({
token: 'TOKEN',
token_secret: 'TOKEN_SECRET',
new DESK.Widget({
id: 'test', // The ID of the element to place the button into
version: 1,
site: 'hecos.desk.com',
port: '80',
type: 'chat',
displayMode: 0, //0 for popup, 1 for lightbox
features: {
offerAlways: false,
offerAgentsOnline: true,
{
"_links": {
"company": {
"href": "/api/v2/companies/1",
"class": "company"
}
}
}
@tstachl
tstachl / desk_api.rb
Created August 21, 2014 17:29
Creating a case with interactions using the desk_api gem.
require 'desk_api'
# Authentication
DeskApi.configure do |config|
config.username = 'jsmith@example.com'
config.password = '1234secret'
config.endpoint = 'https://example.desk.com'
end
# Create the case
@tstachl
tstachl / ENV
Last active August 29, 2015 14:06
desk.com OAuth example using expressjs.
BASE_URL: https://desk-oauth-express.herokuapp.com
CONSUMER_KEY: MY_CONSUMER_KEY
CONSUMER_SECRET: MY_CONSUMER_SECRET
SESSION_SECRET: MY_SESSION_SECRET
@tstachl
tstachl / create.php
Created September 25, 2014 21:29
Creating a case using PHP and CURL in desk.com
<?php
$json = json_encode(array(
"subject" => "Test",
"description" => "testing",
"message" => array(
"subject" => "Test",
"body" => "Test",
"direction" => "in",
"to" => "support@example.com",
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(say);
use JSON;
use WWW::Curl::Easy;
my $DeskSite = 'https://example.desk.com';
@tstachl
tstachl / assign_user.php
Created November 5, 2014 16:17
Assigning a user to a case written in PHP.
<?php
$json = json_encode(array(
'_links' => array(
'assigned_user' => array(
'href' => '/api/v2/users/16096734',
'class' => 'user'
)
)
));