valdemaximus-conduit 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/valdemaximus-conduit.rb +12 -16
- data/valdemaximus-conduit.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/valdemaximus-conduit.rb
CHANGED
@@ -5,32 +5,28 @@ require 'net/https'
|
|
5
5
|
require 'uri'
|
6
6
|
require 'cgi'
|
7
7
|
|
8
|
-
module
|
8
|
+
module ValdeMaximus
|
9
9
|
class Conduit
|
10
|
+
PATH = '/messages.plain'
|
11
|
+
|
10
12
|
def initialize(p={})
|
11
13
|
assign_properties(p)
|
12
14
|
end
|
13
15
|
|
14
|
-
def send_message(msg, list,
|
15
|
-
assign_properties(
|
16
|
-
|
17
|
-
params = {'user_credentials' => @creds,
|
18
|
-
'body' => msg}
|
19
|
-
params.merge!(formatted_list)
|
16
|
+
def send_message(msg, list, properties={})
|
17
|
+
assign_properties(properties)
|
20
18
|
|
21
19
|
@http ||= Net::HTTP.new(@domain, @port)
|
22
20
|
@http.use_ssl = false
|
23
21
|
|
24
22
|
data = ValdeMaximus::UriUtil.to_url_param({:user_credentials => @creds,
|
25
23
|
:body => msg,
|
26
|
-
'
|
24
|
+
'to[]' => list})
|
27
25
|
@headers = {
|
28
26
|
'Content-Type' => ValdeMaximus::UriUtil::CONTENT_TYPE
|
29
27
|
}
|
30
|
-
puts ValdeMaximus::UriUtil::CONTENT_TYPE
|
31
|
-
puts "headers = " + @headers.inspect
|
32
28
|
|
33
|
-
resp, data = @http.post2(
|
29
|
+
resp, data = @http.post2(PATH, data, @headers)
|
34
30
|
end
|
35
31
|
|
36
32
|
private
|
@@ -43,10 +39,10 @@ module Conduit
|
|
43
39
|
end
|
44
40
|
|
45
41
|
if __FILE__ == $0
|
46
|
-
c =
|
47
|
-
res = c.send_message('hello world
|
48
|
-
['
|
49
|
-
|
50
|
-
|
42
|
+
c = ValdeMaximus::Conduit.new(:domain => 'localhost', :port => 3000, :creds => 'f_Le6kzsCJi5tNP7rFpQ')
|
43
|
+
res = c.send_message('hello world 12',
|
44
|
+
['8016946634, Tom Johnson',
|
45
|
+
'8016946632',
|
46
|
+
'8016946633'])
|
51
47
|
puts res
|
52
48
|
end
|