Sha256: 7727bdcc17486505342d04176eeac43e3d6f5aae20a015ba4b00c62fd85677bb
Contents?: true
Size: 1.88 KB
Versions: 7
Compression:
Stored size: 1.88 KB
Contents
module Smshelper module Api class Traitel < Base base_uri 'http://api.traitel.com' # headers 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language' => 'en-us,en;q=0.5', 'Accept-Encoding' => 'gzip, deflate', 'DNT' => '1', 'Connection' => 'keep-alive' def initialize(*args) config = args.shift add_query_options! :user => config.traitel[:uname], :pass => config.traitel[:passwd] # "\"#{config.traitel[:passwd]}\"" super end def send_message(message) if message.utf_8 message.to_hex_be q = {:unicode => 'true'} else q = {} end options = { :to => message.recipient, :message => message.text, :replyto => message.sender, :output => :verbose, :concatenate => true } options.merge!(@extra_options) unless @extra_options.nil? resp = (get 'smsgateway.pl', :extra_query => options.merge(q)) process_response_code(resp) ? (@sent_message_ids << resp.split(',')[2]; resp.split(',')[2]) : (raise ErrorDuringSend "Could not deliver") end def get_balance {'AUD' => (get 'selfserve.pl', :extra_query => {:mode => :balance}).split(' ').last.strip} end def get_status(message_id) raise NotImplementedError, "Sms status checks unsupported by #{self.class.name}" end def get_callback_response(args = {}) DeliveryReport.new( :message_id => args['tt_id'], :timestamp => Time.now, :delivered => ((args['code'] == '0') ? true : false), :original_params => args ) end private def process_response_code(code) code =~ /accepted/ ? true : false end end end end
Version data entries
7 entries across 7 versions & 1 rubygems