Sha256: 4ec8f15cd33c1fc2b2ac23510cbe2535723a6cedf5d8de6c70ab5a3354888e5a
Contents?: true
Size: 1.61 KB
Versions: 9
Compression:
Stored size: 1.61 KB
Contents
module Smshelper module Api class Smstrade < Base base_uri 'http://gateway.smstrade.de' def initialize(*args) config = args.shift add_query_options! :key => config.smstrade[:api_key] super end def send_message(message) if message.utf_8 message.to_hex_be q = {:messagetype => 'unicode', :concat => '1', :message_id => '1'} else q = {:concat => '1', :message_id => '1'} end options = { :to => message.recipient, :message => message.text, :from => message.sender} options = options.merge(@extra_options) unless @extra_options.nil? resp = (post '', :extra_query => options.merge(q)).split(/\n/) process_response_code(resp.first) ? (@sent_message_ids << resp.last; resp.last) : (raise ErrorDuringSend, @response_code.smstrade(resp.first)) end def get_balance resp = (post 'credits') {'EUR' => resp.parsed_response} 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['message_id'], :timestamp => Time.now, :delivered => ((args['status'] == 'DELIVERED') ? true : false), :original_params => args ) end private def process_response_code(code) (code == '100') ? true : false end end end end
Version data entries
9 entries across 9 versions & 1 rubygems