Sha256: b00344526078cc4191f3eb46dbf11de81e636b6359891df31e39158c49068159

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 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)
        @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 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

2 entries across 2 versions & 1 rubygems

Version Path
smshelper-0.4.5 lib/smshelper/api/textmagic.rb
smshelper-0.4.0 lib/smshelper/api/textmagic.rb