Created
May 11, 2011 15:41
-
-
Save benlangfeld/966702 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'json' | |
require 'httparty' | |
require 'logger' | |
module TropoREST | |
@logger = Logger.new STDOUT | |
@logger.level = Logger::WARN | |
class << self | |
include HTTParty | |
attr_accessor :token, :logger | |
default_params token: @token | |
base_uri 'https://api.tropo.com' | |
SESSION_URI = '/1.0/sessions' | |
format :json | |
headers 'Accept' => 'application/json', 'content-type' => 'application/json' | |
def originate(options = {}) | |
@logger.debug "Originating Tropo call with parameters #{options}" | |
resp = post SESSION_URI, body: options | |
@logger.debug "Tropo origination responded with: #{resp.inspect}" | |
end | |
def fire_event(event_name, session_id) | |
@logger.debug "Firing event #{event_name} into Tropo session #{session_id}" | |
resp = post "#{SESSION_URI}/#{session_id}/signals", body: { value: event_name } | |
@logger.debug "Tropo event trigger responded with: #{resp.inspect}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment