Sha256: 5c7839474148646a07c2746745883a542cf80b5648710ca7ee335a8b42686a8f
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'rubygems' require 'valdemaximus-xx' require 'net/http' require 'net/https' require 'uri' require 'cgi' module ValdeMaximus class Conduit PATH = '/messages.plain' def initialize(p={}) assign_properties(p) end def send_message(msg, list, properties={}) assign_properties(properties) @http ||= Net::HTTP.new(@domain, @port) @http.use_ssl = false data = ValdeMaximus::UriUtil.to_url_param({:user_credentials => @creds, :body => msg, 'to[]' => list}) @headers = { 'Content-Type' => ValdeMaximus::UriUtil::CONTENT_TYPE } resp, data = @http.post2(PATH, data, @headers) end private def assign_properties(p) @domain = p[:domain] unless p[:domain].nil? @port = p[:port].to_s unless p[:port].nil? @creds = p[:creds] unless p[:creds].nil? end end end if __FILE__ == $0 c = ValdeMaximus::Conduit.new(:domain => 'localhost', :port => 3000, :creds => 'f_Le6kzsCJi5tNP7rFpQ') res = c.send_message('hello world 12', ['8016946634, Tom Johnson', '8016946632, Little T Johnson', '8016946633, Big T Johnson']) puts res end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
valdemaximus-conduit-0.2.1 | lib/valdemaximus-conduit.rb |
valdemaximus-conduit-0.2.0 | lib/valdemaximus-conduit.rb |