Sha256: cd6e3f7ecd3e477d2c8e1cb6c864c80f71801115cc8eade6fdc38c309b15d09b
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
require 'rubygems' require 'valdemaximus-xx' require 'net/http' require 'net/https' require 'uri' require 'cgi' module ValdeMaximus class Conduit def initialize(p={}) assign_properties(p) end def send_message(body, list, node_id='') send('/messages', :body => body, :node_id => node_id.to_s, 'to[]' => list) end def add_phone_numbers(phone_numbers, lazy=true) send('/phone_numbers', 'phone_number[]' => phone_numbers, :lazy => lazy.to_s) end private def send(path, params={}) @http ||= Net::HTTP.new(@domain, @port) @http.use_ssl = false data = ValdeMaximus::UriUtil.to_url_param({:user_credentials => @creds}.merge(params)) @headers = { 'Content-Type' => ValdeMaximus::UriUtil::CONTENT_TYPE } resp, data = @http.post2(path + @format, data, @headers) end 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].nil? ? "yml" : p[:format]}" end end end if __FILE__ == $0 c = ValdeMaximus::Conduit.new(:format => 'yml', :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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valdemaximus-conduit-1.0.0 | lib/valdemaximus-conduit.rb |