Sha256: f88905d5456ceb71718333c865055526fbdbc1abfbc5669a4bccec266bf72410

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 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)
        @sent_message_ids << (@api.send message.text, message.recipient, :from => message.sender)
      end

      def get_balance
        {'Credits' => @api.account.balance}
      end

      def get_status(message_id)
        @sent_message_statuses[message_id] = []
        @sent_message_statuses[message_id] << {"Part 01" => @api.message_status(message_id)}
        {message_id => @sent_message_statuses[message_id]}
      end

      # def send_message(*args)
      #   add_query_options! :username => @uname, :password => @passwd

      #   (post 'api', :extra_query => {
      #      :cmd => 'send',
      #      :phone => args.shift,
      #      :text => args.shift,
      #      :from => args.shift,
      #      :unicode => '0'})
      # end

      # def get_balance
      #   add_query_options! :username => @uname, :password => @passwd

      #   (post 'api', :extra_query => {:cmd => 'account'})
      # end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smshelper-0.2.2 lib/smshelper/api/textmagic.rb
smshelper-0.2.1 lib/smshelper/api/textmagic.rb
smshelper-0.2.0 lib/smshelper/api/textmagic.rb
smshelper-0.1.3 lib/smshelper/api/textmagic.rb