Sha256: d1044089e33f57f4ce5b4b3cd59b72322a5699d23d219f6d1b526c180e7393fc
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 KB
Contents
module Smshelper module Api class Vianett < Base base_uri 'http://smsc.vianett.no/V3/CPA/MT' def initialize(*args) config = args.shift add_query_options! :username => config.vianett[:uname], :password => config.vianett[:passwd] super end def send_message(message) uuid = (Digest::CRC32.hexdigest @uuid.generate).unpack('U*').collect {|x| sprintf '%02X', x}.join options = { :destinationaddr => message.recipient, :message => message.text, :sourceaddr => message.sender, # :refno => '1', :msgid => uuid} options = options.merge(@extra_options) unless @extra_options.nil? resp = (post 'MT.ashx', :extra_query => options) process_response_code(resp['ack']) ? (@sent_message_ids << uuid; uuid) : (raise ErrorDuringSend, "#{self.class.name} does not implement detailed errors") end def get_balance {:fake => :value} end def get_status(message_id) raise NotImplementedError, "Sms status checks unsupported by #{self.class.name}" end private def process_response_code(code) (code == 'OK') ? 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/vianett.rb |
smshelper-0.4.0 | lib/smshelper/api/vianett.rb |
smshelper-0.3.1 | lib/smshelper/api/vianett.rb |
smshelper-0.3.0 | lib/smshelper/api/vianett.rb |