Sha256: 7fa3f1a8a7cd0dfa895f0c18ff2de4cffd8b6a86ab27e849b955862bed2b7bb7
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 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) : (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 private def process_response_code(code) (code == '100') ? true : false end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
smshelper-0.2.2 | lib/smshelper/api/smstrade.rb |
smshelper-0.2.1 | lib/smshelper/api/smstrade.rb |
smshelper-0.2.0 | lib/smshelper/api/smstrade.rb |
smshelper-0.1.3 | lib/smshelper/api/smstrade.rb |