Created
August 21, 2014 17:29
-
-
Save tstachl/4414dd4d0b3eadab3077 to your computer and use it in GitHub Desktop.
Creating a case with interactions using the desk_api gem.
This file contains 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 '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 | |
ticket = DeskApi.cases.create({ | |
subject: "I still can't login", | |
priority: 7, | |
status: 'resolved', | |
type: 'email', | |
labels: ['Login'], | |
created_at: '2014-03-19T08:23:20Z', | |
updated_at: '2014-03-29T09:05:08Z', | |
message: { | |
direction: 'in', | |
status: 'received', | |
to: 'support@example.com', | |
from: 'jane@example.com', | |
subject: "I still can't login", | |
body: 'Please help!', | |
created_at: '2014-03-19T08:23:20Z', | |
updated_at: '2014-03-19T08:23:20Z' | |
}, | |
_links: { | |
customer: { href: '/api/v2/customers/1' } | |
} | |
}) | |
# creating a reply | |
ticket.replies.create({ | |
direction: 'out', | |
status: 'sent', | |
to: 'jane@example.com', | |
from: 'support@example.com', | |
subject: "RE: I still can't login", | |
body: "I'm sorry about that, can you try this.", | |
created_at: '2014-03-19T08:29:55Z', | |
updated_at: '2014-03-19T08:29:55Z', | |
_links: { | |
sent_by: { href: '/api/v2/users/1' } | |
} | |
}) | |
# creating a note | |
ticket.notes.create({ | |
body: '@someone can you make sure the account is active.', | |
created_at: '2014-03-19T08:36:46Z', | |
updated_at: '2014-03-19T08:36:46Z' | |
}) | |
# another inbound reply | |
ticket.replies.create({ | |
direction: 'in', | |
status: 'received', | |
to: 'support@example.com', | |
from: 'jane@example.com', | |
subject: "RE: I still can't login", | |
body: "It seems to work now. Thank you!", | |
created_at: '2014-03-19T08:39:50Z', | |
updated_at: '2014-03-19T08:39:50Z', | |
_links: { | |
sent_by: { href: '/api/v2/users/1' } | |
} | |
}) | |
# another note | |
ticket.notes.create({ | |
body: 'Thanks for the help on this.', | |
created_at: '2014-03-19T08:52:46Z', | |
updated_at: '2014-03-19T08:52:46Z' | |
}) | |
# make sure the status is updated | |
ticket.update(status: 'resolved') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment