ruby-on-railsrubyclickatell

How to set the optional mo value for Clickatells 2 way sms


I'm trying to send a 2 way sms through clickatell.

I have to use the following to send an sms.

send_message(recipient, message_text, opts={})

I have to set the optional mo variable to 1.

Additional options:

:from - the from number/name
:set_mobile_originated - mobile originated flag

Here is the source code from clickatel.

def send_message(recipient, message_text, opts={})
 valid_options = opts.only(:from, :mo, :callback)
 valid_options.merge!(:req_feat => '48') if valid_options[:from]
 valid_options.merge!(:mo => '1') if opts[:set_mobile_originated]
 recipient = recipient.join(",")if recipient.is_a?(Array)
 response = execute_command('sendmsg', 'http',
 {:to => recipient, :text => message_text}.merge(valid_options)
 ) 
 response = parse_response(response)
 response.is_a?(Array) ? response.map { |r| r['ID'] } : response['ID']
end

My brain is fried and I cant figure out how to set this mo variable because this doesn't work:

send_message(from, message, mo: '1')

Any help on how to set this optional value?


Solution

  • do this instead:

    send_message(from, message, set_mobile_originated: true)