Sha256: bef4465aa7c475083a3b3c06aacf27b41ddfdda1f12dc4a57528642b4e276fc9

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

module Smshelper
  module Api
    class Textmagic < Base

      # base_uri 'https://www.textmagic.com/app'

      def initialize(*args)
        config = args.shift
        @api = TextMagic::API.new config.textmagic[:uname], config.textmagic[:passwd]
        super
      end

      def send_message(message)
        resp = (@api.send message.text, message.recipient, :from => message.sender).to_s
        @sent_message_ids << resp
        resp
      end

      def get_balance
        {'Credits' => @api.account.balance}
      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'] =~ /d/) ? true : false),
                           :original_params => args
                           )
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smshelper-0.4.12 lib/smshelper/api/textmagic.rb
smshelper-0.4.11 lib/smshelper/api/textmagic.rb
smshelper-0.4.10 lib/smshelper/api/textmagic.rb
smshelper-0.4.9 lib/smshelper/api/textmagic.rb
smshelper-0.4.8 lib/smshelper/api/textmagic.rb
smshelper-0.4.7 lib/smshelper/api/textmagic.rb
smshelper-0.4.6 lib/smshelper/api/textmagic.rb