Sha256: 9dc5de28a662199ec44225b2d1446b310019db6a7a508ecd74e9d2f2269a29c0
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
require 'net/http' require 'inteltech_sms' # Dummy Class for testing class DummyInteltechSms < InteltechSms attr_accessor :credit, :response_code def initialize(credit, response_code = InteltechSms::SUCCESS_RESPONSE_CODE) super('dummy_user', 'a_secret') @credit = credit.to_i @response_code = response_code @last_sms = '' end def get_credit res = InteltechSms::FakeHTTPSuccess.new(@response_code == InteltechSms::SUCCESS_RESPONSE_CODE ? "credit,#{@credit}" : @response_code) process_get_credit_response(res) end def send_sms(sms, message, options = { }) this_response_code = response_code_for_sms(sms) @credit -= 1 if this_response_code == InteltechSms::SUCCESS_RESPONSE_CODE res = InteltechSms::FakeHTTPSuccess.new(this_response_code) process_send_sms_response(res, sms) end def send_multiple_sms(sms, message, options = { }) this_response_code = response_code_for_sms(sms) sms_array = (sms.respond_to?(:each) ? sms : sms.split(',')) @credit -= sms_array.size if this_response_code == InteltechSms::SUCCESS_RESPONSE_CODE ret = [ ] sms_array.each do |this_sms| ret << Response.factory(this_sms.strip, this_response_code) end ret end private def response_code_for_sms(sms) ret = @response_code if ret == InteltechSms::SUCCESS_RESPONSE_CODE if @credit <= 0 ret = InteltechSms::NO_CREDIT_RESPONSE_CODE else ret = @last_sms == sms ? InteltechSms::DUPLICATE_RESPONSE_CODE : @response_code @last_sms = sms end end ret end end # vi:ai sw=2:
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inteltech_sms-1.0.0 | lib/dummy_inteltech_sms.rb |