class DogEar::Client
Public Class Methods
new(api_key)
click to toggle source
# File lib/dogear.rb, line 6 def initialize(api_key) @api_key = api_key end
Public Instance Methods
notify(server_id, message)
click to toggle source
# File lib/dogear.rb, line 10 def notify(server_id, message) headers = {'Authorization' => "Token token=\"#{@api_key}\"", 'Content-type' => 'application/json'} body = { message: message }.to_json response = HTTParty.post("https://dogear.io/api/v1/servers/notify/#{server_id}", headers: headers, body: body) case response.code when 200 return true else begin json = JSON.parse(response.body) rescue raise Error.new(response.body) end unless json['error'].nil? raise Error.new(json['error']) end end return false end