tropo-rest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Rakefile +7 -0
- data/bin/tropo-rest +5 -0
- data/lib/tropo-rest/cli.rb +12 -0
- data/lib/tropo-rest/version.rb +3 -0
- data/lib/tropo-rest.rb +46 -0
- data/spec/spec_helper.rb +8 -0
- data/tropo-rest.gemspec +26 -0
- metadata +125 -0
data/.rspec
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/tropo-rest
ADDED
data/lib/tropo-rest.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'httparty'
|
3
|
+
require 'logger'
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
module TropoREST
|
7
|
+
class API
|
8
|
+
include HTTParty
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
attr_writer :logger
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@logger = Logger.new STDOUT
|
15
|
+
@logger.level = Logger::WARN
|
16
|
+
end
|
17
|
+
|
18
|
+
def token=(token)
|
19
|
+
self.class.default_params token: token
|
20
|
+
end
|
21
|
+
|
22
|
+
base_uri 'https://api.tropo.com'
|
23
|
+
SESSION_URI = '/1.0/sessions'
|
24
|
+
|
25
|
+
format :json
|
26
|
+
headers 'Accept' => 'application/json', 'content-type' => 'application/json'
|
27
|
+
|
28
|
+
def originate(options = {})
|
29
|
+
@logger.debug "Originating Tropo call with parameters #{options}"
|
30
|
+
resp = self.class.post SESSION_URI, body: options
|
31
|
+
@logger.debug "Tropo origination responded with: #{resp.inspect}"
|
32
|
+
resp
|
33
|
+
end
|
34
|
+
|
35
|
+
def fire_event(event_name, session_id)
|
36
|
+
@logger.debug "Firing event #{event_name} into Tropo session #{session_id}"
|
37
|
+
resp = self.class.post "#{SESSION_URI}/#{session_id}/signals", body: { value: event_name }
|
38
|
+
@logger.debug "Tropo event trigger responded with: #{resp.inspect}"
|
39
|
+
resp
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.method_missing(method_name, *args, &block)
|
44
|
+
API.instance.send method_name, *args, &block
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/tropo-rest.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "tropo-rest/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "tropo-rest"
|
7
|
+
s.version = TropoREST::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ben Langfeld"]
|
10
|
+
s.email = ["ben@langfeld.me"]
|
11
|
+
s.homepage = "https://github.com/benlangfeld/tropo-rest"
|
12
|
+
s.summary = %q{A rubygem to wrap the Tropo REST API}
|
13
|
+
|
14
|
+
s.rubyforge_project = "tropo-rest"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'httparty'
|
22
|
+
s.add_dependency 'pry'
|
23
|
+
|
24
|
+
s.add_development_dependency 'rspec'
|
25
|
+
s.add_development_dependency 'yard'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tropo-rest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Ben Langfeld
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-11 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: httparty
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: pry
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: yard
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id004
|
72
|
+
description:
|
73
|
+
email:
|
74
|
+
- ben@langfeld.me
|
75
|
+
executables:
|
76
|
+
- tropo-rest
|
77
|
+
extensions: []
|
78
|
+
|
79
|
+
extra_rdoc_files: []
|
80
|
+
|
81
|
+
files:
|
82
|
+
- .gitignore
|
83
|
+
- .rspec
|
84
|
+
- Gemfile
|
85
|
+
- Rakefile
|
86
|
+
- bin/tropo-rest
|
87
|
+
- lib/tropo-rest.rb
|
88
|
+
- lib/tropo-rest/cli.rb
|
89
|
+
- lib/tropo-rest/version.rb
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
- tropo-rest.gemspec
|
92
|
+
has_rdoc: true
|
93
|
+
homepage: https://github.com/benlangfeld/tropo-rest
|
94
|
+
licenses: []
|
95
|
+
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
requirements: []
|
118
|
+
|
119
|
+
rubyforge_project: tropo-rest
|
120
|
+
rubygems_version: 1.3.7
|
121
|
+
signing_key:
|
122
|
+
specification_version: 3
|
123
|
+
summary: A rubygem to wrap the Tropo REST API
|
124
|
+
test_files:
|
125
|
+
- spec/spec_helper.rb
|