Sha256: f0e2664218cfc32406fa613ad7951793bc460ccc631ba64f605afbfca5bbedbe
Contents?: true
Size: 1.54 KB
Versions: 4
Compression:
Stored size: 1.54 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 = 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 private def process_response_code(code) code =~ /accepted/ ? true : false end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
smshelper-0.4.5 | lib/smshelper/api/traitel.rb |
smshelper-0.4.0 | lib/smshelper/api/traitel.rb |
smshelper-0.3.1 | lib/smshelper/api/traitel.rb |
smshelper-0.3.0 | lib/smshelper/api/traitel.rb |