Class: TropoREST::API
Direct Known Subclasses
Constant Summary collapse
- SESSION_URI =
'/1.0/sessions'
Class Method Summary collapse
- .fire_event(event_name, session_id) ⇒ Object
- .options_with_token(options, type = :voice) ⇒ Object
- .originate(options = {}) ⇒ Object
- .request(target, body, type = nil) ⇒ Object
Class Method Details
.fire_event(event_name, session_id) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/tropo-rest.rb', line 52 def fire_event(event_name, session_id) logger.info "Firing event #{event_name} into Tropo session #{session_id}" resp = request "#{SESSION_URI}/#{session_id}/signals", value: event_name logger.info "Tropo event trigger responded with: #{resp.inspect}" resp end |
.options_with_token(options, type = :voice) ⇒ Object
65 66 67 |
# File 'lib/tropo-rest.rb', line 65 def (, type = :voice) .merge! token: type == :messaging ? messaging_token : voice_token end |
.originate(options = {}) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/tropo-rest.rb', line 45 def originate( = {}) logger.info "Originating Tropo call with parameters #{}" resp = request SESSION_URI, , [:channel] logger.info "Tropo origination responded with: #{resp.inspect}" resp end |
.request(target, body, type = nil) ⇒ Object
59 60 61 62 63 |
# File 'lib/tropo-rest.rb', line 59 def request(target, body, type = nil) = body, type logger.debug "Making request to #{target} with #{.inspect}" post target, body: .to_json end |