Created
October 6, 2017 16:58
-
-
Save salbertson/321bec5be95d1e7bc85e9db792ef3433 to your computer and use it in GitHub Desktop.
Groove API examples - Ruby
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 "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