Sha256: 7d06eebcd35fceee2b0275eec1c74b89927ca20349debf8697502aebc3983b86
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require 'rubygems' require 'valdemaximus-xx' require 'net/http' require 'net/https' require 'uri' require 'cgi' module ValdeMaximus class Conduit PATH = '/messages' def initialize(p={}) assign_properties(p) end def send_message(body, list, node_id='') @http ||= Net::HTTP.new(@domain, @port) @http.use_ssl = false data = ValdeMaximus::UriUtil.to_url_param({:user_credentials => @creds, :body => body, :node_id => node_id.to_s, 'to[]' => list}) @headers = { 'Content-Type' => ValdeMaximus::UriUtil::CONTENT_TYPE } resp, data = @http.post2(PATH + @format, 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? @format = ".#{p[:format]}" || ".yml" end end end if __FILE__ == $0 c = ValdeMaximus::Conduit.new(:format => 'yml', :domain => 'localhost', :port => 3000, :creds => 'k6DbJgVK5uq5_F_P14if') res = c.send_message('hello world 12', ['8016946634, Tom Johnson', '8016946632, Little T Johnson', '8016946633, Big T Johnson']) puts res end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valdemaximus-conduit-0.3.4 | lib/valdemaximus-conduit.rb |