tropo-rest 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .yardoc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tropo-rest.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ task :default => :spec
5
+
6
+ Bundler::GemHelper.install_tasks
7
+ RSpec::Core::RakeTask.new 'spec'
data/bin/tropo-rest ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
3
+
4
+ require 'tropo-rest/cli'
5
+ TropoREST::CLI.start
@@ -0,0 +1,12 @@
1
+ require 'pry'
2
+ require 'tropo-rest'
3
+
4
+ module TropoREST
5
+ class CLI
6
+ def self.start
7
+ print "Enter your Tropo app token for this session: "
8
+ TropoREST.token = gets
9
+ pry
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module TropoREST
2
+ VERSION = "0.0.1"
3
+ end
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
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'tropo-rest'
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
@@ -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