Class: DummyInteltechSms
- Inherits:
-
InteltechSms
- Object
- InteltechSms
- DummyInteltechSms
- Defined in:
- lib/dummy_inteltech_sms.rb
Overview
Dummy Class for testing
Constant Summary
Constants inherited from InteltechSms
InteltechSms::ACCOUNT_NOT_ACTIVATED_RESPONSE_CODE, InteltechSms::DUPLICATE_RESPONSE_CODE, InteltechSms::EMPTY_MESSAGE_RESPONSE_CODE, InteltechSms::INVALID_NUMBER_RESPONSE_CODE, InteltechSms::INVALID_SENDER_RESPONSE_CODE, InteltechSms::NO_CREDIT_RESPONSE_CODE, InteltechSms::SUCCESS_RESPONSE_CODE, InteltechSms::TOO_MANY_RECIPIENTS_RESPONSE_CODE, InteltechSms::UNAUTHORIZED_KEY_RESPONSE_CODE, InteltechSms::UNAUTHORIZED_RESPONSE_CODE
Instance Attribute Summary collapse
-
#credit ⇒ Object
Returns the value of attribute credit.
-
#log_to_stdout ⇒ Object
Returns the value of attribute log_to_stdout.
-
#response_code ⇒ Object
Returns the value of attribute response_code.
Instance Method Summary collapse
- #get_credit ⇒ Object
-
#initialize(credit, response_code = InteltechSms::SUCCESS_RESPONSE_CODE) ⇒ DummyInteltechSms
constructor
A new instance of DummyInteltechSms.
- #send_multiple_sms(sms, message, options = { }) ⇒ Object
- #send_sms(sms, message, options = { }) ⇒ Object
Constructor Details
#initialize(credit, response_code = InteltechSms::SUCCESS_RESPONSE_CODE) ⇒ DummyInteltechSms
Returns a new instance of DummyInteltechSms.
13 14 15 16 17 18 19 |
# File 'lib/dummy_inteltech_sms.rb', line 13 def initialize(credit, response_code = InteltechSms::SUCCESS_RESPONSE_CODE) super('dummy_user', 'a_secret') @credit = credit.to_i @response_code = response_code @last_sms = '' @log_to_stdout = true end |
Instance Attribute Details
#credit ⇒ Object
Returns the value of attribute credit.
11 12 13 |
# File 'lib/dummy_inteltech_sms.rb', line 11 def credit @credit end |
#log_to_stdout ⇒ Object
Returns the value of attribute log_to_stdout.
11 12 13 |
# File 'lib/dummy_inteltech_sms.rb', line 11 def log_to_stdout @log_to_stdout end |
#response_code ⇒ Object
Returns the value of attribute response_code.
11 12 13 |
# File 'lib/dummy_inteltech_sms.rb', line 11 def response_code @response_code end |
Instance Method Details
#get_credit ⇒ Object
21 22 23 24 |
# File 'lib/dummy_inteltech_sms.rb', line 21 def get_credit res = InteltechSms::FakeHTTPSuccess.new(@response_code == InteltechSms::SUCCESS_RESPONSE_CODE ? "credit,#{@credit}" : @response_code) process_get_credit_response(res) end |
#send_multiple_sms(sms, message, options = { }) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dummy_inteltech_sms.rb', line 34 def send_multiple_sms(sms, , = { }) this_response_code = response_code_for_sms(sms) sms_array = (sms.is_a?(Array) ? sms : sms.split(',')) puts "WOULD HAVE SENT SMS TO #{sms_array.join(', ')}: #{} AND RETURNED STATUS: #{this_response_code}" if @log_to_stdout @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 |
#send_sms(sms, message, options = { }) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/dummy_inteltech_sms.rb', line 26 def send_sms(sms, , = { }) this_response_code = response_code_for_sms(sms) @credit -= 1 if this_response_code == InteltechSms::SUCCESS_RESPONSE_CODE puts "WOULD HAVE SENT SMS TO #{sms}: #{} AND RETURNED STATUS: #{this_response_code}" if @log_to_stdout res = InteltechSms::FakeHTTPSuccess.new(this_response_code) process_send_sms_response(res, sms) end |