Skip to content

Instantly share code, notes, and snippets.

@salbertson
Created October 6, 2017 16:58
Show Gist options
  • Save salbertson/321bec5be95d1e7bc85e9db792ef3433 to your computer and use it in GitHub Desktop.
Save salbertson/321bec5be95d1e7bc85e9db792ef3433 to your computer and use it in GitHub Desktop.
Groove API examples - Ruby
require "uri"
require "net/https"
require "json"
# Here's an example of creating a ticket by an agent for a customer, with a hash of customer attributes.
uri = URI.parse("https://api.groovehq.com/v1/tickets")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
post = Net::HTTP::Post.new(
uri,
{
"Content-Type" => "application/json",
"Authorization" => "Bearer ***YOUR TOKEN GOES HERE***"
}
)
post.body = JSON.generate({
body: "I'm here to help!",
from: "support@example.com",
to: {
email: "billybob@example.com",
name: "Billy Bob"
}
})
response = http.request(post)
puts response.message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment