Sha256: e83da9fbaa15348515f36059ff319fb9b27be6571ca41c94b636a2a2b9e6474c

Contents?: true

Size: 465 Bytes

Versions: 3

Compression:

Stored size: 465 Bytes

Contents

require 'json'

module Nico
  class Responder
    def initialize(subdomain, id, token)
      @http = Net::HTTP.new "#{subdomain}.campfirenow.com", 443
      @http.use_ssl = true
      @request = Net::HTTP::Post.new "/room/#{id}/speak.json"
      @request.basic_auth token, 'x'
      @request['Content-Type'] = 'application/json'
    end

    def push(response)
      @request.body = {message: {body: response}}.to_json
      @http.request @request
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nico-0.1.1 lib/nico/room/responder.rb
nico-0.1.0 lib/nico/room/responder.rb
nico-0.0.2 lib/nico/room/responder.rb