class MobilyFormattedSMS
Public Class Methods
new(auth, numbers=[], sender='', msg='', delete_key=nil, msg_id=nil, domain_name=nil, application_type='70')
click to toggle source
Calls superclass method
MobilySMS::new
# 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
Public Instance Methods
add_variable_for_number(mobile_number, symbol, value)
click to toggle source
# 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_key()
click to toggle source
# 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
Private Instance Methods
is_valid_key?()
click to toggle source
# File lib/mobily/mobily_formatted_sms.rb, line 44 def is_valid_key? is_value_set_count_consistent? and value_set_count_equals_mobile_number_count? end
is_value_set_count_consistent?()
click to toggle source
# File lib/mobily/mobily_formatted_sms.rb, line 48 def is_value_set_count_consistent? 1 == @variable_dict.values.map { |x| x.size }.uniq.size end
prepare_to_send()
click to toggle source
Calls superclass method
MobilySMS#prepare_to_send
# File lib/mobily/mobily_formatted_sms.rb, line 38 def prepare_to_send super @request_handler.add_parameter('msg', MobilyApiUnicodeConverter.convert(@msg)) @request_handler.add_parameter('msgKey', MobilyApiUnicodeConverter.convert(generate_msg_key)) end
value_set_count_equals_mobile_number_count?()
click to toggle source
# File lib/mobily/mobily_formatted_sms.rb, line 52 def value_set_count_equals_mobile_number_count? @variable_dict.size == @numbers.size end