Class: MobilyFormattedSMS

Inherits:
MobilySMS show all
Defined in:
lib/mobily/mobily_formatted_sms.rb

Instance Attribute Summary

Attributes inherited from MobilySMS

#auth, #date_send, #delete_key, #domain_name, #msg, #msg_id, #request_handler, #sender, #time_send

Instance Method Summary collapse

Methods inherited from MobilySMS

#add_number, can_send?, #delete, #get_numbers_as_csv, #schedule_to_send_on, #send

Constructor Details

#initialize(auth, numbers = [], sender = '', msg = '', delete_key = nil, msg_id = nil, domain_name = nil, application_type = '70') ⇒ MobilyFormattedSMS

Returns a new instance of MobilyFormattedSMS.



11
12
13
14
15
16
# File 'lib/mobily/mobily_formatted_sms.rb', line 11

def initialize(auth, numbers=[], sender='', msg='', delete_key=nil, msg_id=nil,
               domain_name=nil, application_type='70')
  super
  @api_method_name = 'msgSendWK'
  @variable_dict = {}
end

Instance Method Details

#add_variable_for_number(mobile_number, symbol, value) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/mobily/mobily_formatted_sms.rb', line 18

def add_variable_for_number(mobile_number, symbol, value)
  return if not @numbers.include?(mobile_number)
  if @variable_dict.has_key?(mobile_number)
    @variable_dict[mobile_number] << [symbol, value]
  else
    @variable_dict.merge!({mobile_number => [[symbol, value]]})
  end
end

#generate_msg_keyObject



27
28
29
30
31
32
33
34
# File 'lib/mobily/mobily_formatted_sms.rb', line 27

def generate_msg_key
  if is_valid_key?
    ordered_number_variables = @numbers.map { |num| @variable_dict[num] }
    ordered_number_variables.map { |x| x.map { |y| y.join(',*,') } }.map { |z| z.join(',@,') }.join('***')
  else
    raise 'Cannot generate msgKey, symbol count is inconsistent'
  end
end