Class: Clickatell::API

Inherits:
Object
  • Object
show all
Defined in:
lib/smess/outputs/clickatell.rb

Instance Method Summary collapse

Instance Method Details

#send_message(recipient, message_text, opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/smess/outputs/clickatell.rb', line 7

def send_message(recipient, message_text, opts={})
  valid_options = opts.only(:from, :mo, :callback, :climsgid, :concat)
  valid_options.merge!(:req_feat => '48') if valid_options[:from]
  valid_options.merge!(:mo => '1') if opts[:set_mobile_originated]
  valid_options.merge!(:climsgid => opts[:client_message_id]) if opts[:client_message_id]
  valid_options[:deliv_ack] = 1 if opts[:callback]
  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