tropo_message 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +32 -8
- data/VERSION +1 -1
- data/lib/tropo_message.rb +32 -13
- data/tropo_message.gemspec +2 -2
- metadata +3 -3
data/README.markdown
CHANGED
@@ -1,16 +1,40 @@
|
|
1
1
|
# tropo_message
|
2
2
|
|
3
|
+
tropo_message is a tiny gem that simplifies sending messages using [Tropo](http://www.tropo.com)
|
3
4
|
|
5
|
+
## Usage
|
6
|
+
### Create a new SMS ready for sending
|
7
|
+
message = Tropo::Message.new
|
8
|
+
message.token = "your_token"
|
9
|
+
message.to = "13118374750"
|
10
|
+
message.text = "message to send"
|
4
11
|
|
5
|
-
|
12
|
+
### Send the message to listener
|
13
|
+
post("http://api.tropo.com/1.0/sessions", message.request_xml)
|
6
14
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
See also: <http://blog.tropo.com/2010/09/10/how-to-sending-an-sms-using-webapi>
|
16
|
+
|
17
|
+
### Receive message and respond to Tropo (inside your listener)
|
18
|
+
tropo_session = Tropo::Generator.parse(raw_json)
|
19
|
+
|
20
|
+
message = Tropo::Message.new(tropo_session)
|
21
|
+
text = message.text
|
22
|
+
tropo = Tropo::Generator.new
|
23
|
+
tropo.message(message.response_params) do
|
24
|
+
say :value => text
|
25
|
+
end
|
26
|
+
tropo.response
|
27
|
+
|
28
|
+
See also:
|
29
|
+
<http://github.com/voxeo/tropo-webapi-ruby>
|
30
|
+
<http://blog.tropo.com/2010/09/10/how-to-sending-an-sms-using-webapi>
|
31
|
+
|
32
|
+
### More documentation?
|
33
|
+
Check out the [source](http://github.com/dwilkie/tropo_message/blob/master/lib/tropo_message.rb). It's tiny and easy to read.
|
34
|
+
|
35
|
+
### Installation
|
36
|
+
gem install tropo_message
|
37
|
+
require 'tropo_message'
|
14
38
|
|
15
39
|
## Copyright
|
16
40
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/tropo_message.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Tropo
|
2
2
|
class Message
|
3
3
|
|
4
|
-
attr_accessor :params
|
5
|
-
attr_accessor :tropo_session
|
4
|
+
attr_accessor :params, :tropo_session
|
6
5
|
|
7
|
-
def initialize(
|
8
|
-
@params =
|
9
|
-
@tropo_session =
|
6
|
+
def initialize(tropo_session = {})
|
7
|
+
@params = {}
|
8
|
+
@tropo_session = tropo_session
|
10
9
|
end
|
11
10
|
|
12
11
|
def parse(tropo_session)
|
@@ -17,20 +16,28 @@ module Tropo
|
|
17
16
|
params["token"] || tropo_parameters["token"]
|
18
17
|
end
|
19
18
|
|
19
|
+
def token=(value)
|
20
|
+
params["token"] = value
|
21
|
+
end
|
22
|
+
|
20
23
|
def action
|
21
|
-
tropo_parameters["action"]
|
24
|
+
tropo_parameters["action"]
|
22
25
|
end
|
23
26
|
|
24
27
|
def to
|
25
28
|
params["to"] || tropo_parameters["to"]
|
26
29
|
end
|
27
30
|
|
31
|
+
def to=(value)
|
32
|
+
params["to"] = value
|
33
|
+
end
|
34
|
+
|
28
35
|
def channel
|
29
36
|
params["channel"] || tropo_parameters["channel"] || 'TEXT'
|
30
37
|
end
|
31
38
|
|
32
39
|
def network
|
33
|
-
params["
|
40
|
+
params["network"] || tropo_parameters["network"] || 'SMS'
|
34
41
|
end
|
35
42
|
|
36
43
|
def text
|
@@ -38,10 +45,19 @@ module Tropo
|
|
38
45
|
end
|
39
46
|
alias :msg :text
|
40
47
|
|
48
|
+
def text=(value)
|
49
|
+
params["text"] = value
|
50
|
+
end
|
51
|
+
alias :msg= :text=
|
52
|
+
|
41
53
|
def from
|
42
54
|
params["from"] || tropo_parameters["from"]
|
43
55
|
end
|
44
56
|
|
57
|
+
def from=(value)
|
58
|
+
params["from"] = value
|
59
|
+
end
|
60
|
+
|
45
61
|
def timeout
|
46
62
|
params["timeout"] || tropo_parameters["timeout"]
|
47
63
|
end
|
@@ -55,7 +71,7 @@ module Tropo
|
|
55
71
|
end
|
56
72
|
|
57
73
|
def recording
|
58
|
-
params["
|
74
|
+
params["recording"] || tropo_parameters["recording"]
|
59
75
|
end
|
60
76
|
|
61
77
|
def outgoing?
|
@@ -76,11 +92,14 @@ module Tropo
|
|
76
92
|
params
|
77
93
|
end
|
78
94
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
95
|
+
def request_xml
|
96
|
+
request_params = @params.dup
|
97
|
+
token = request_params.delete("token")
|
98
|
+
xml = ""
|
99
|
+
request_params.each do |key, value|
|
100
|
+
xml << "<var name=\"#{key}\" value=\"#{value}\"/>"
|
101
|
+
end
|
102
|
+
"<sessions><token>#{token}</token>#{xml.to_s}</sessions>"
|
84
103
|
end
|
85
104
|
|
86
105
|
private
|
data/tropo_message.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tropo_message}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Wilkie"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-14}
|
13
13
|
s.description = %q{A tiny wrapper for creating a Tropo message}
|
14
14
|
s.email = %q{dwilkie@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Wilkie
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-14 00:00:00 +07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|