Class: Splat::Clickatell

Inherits:
Gateway show all
Defined in:
lib/splat/vendors/clickatell/clickatell_gateway.rb

Constant Summary collapse

PARSE_REGEX =
/[A-Za-z0-9]+:.*?(?:(?=[A-Za-z0-9]+:)|$)/

Instance Attribute Summary

Attributes inherited from Gateway

#vendor

Instance Method Summary collapse

Methods inherited from Gateway

[], #config_option, #configuration, default_configuration, inherited, #required_config

Methods included from Utils

#url_escape

Methods included from Insertion

#insert_values

Constructor Details

#initializeClickatell

Returns a new instance of Clickatell.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/splat/vendors/clickatell/clickatell_gateway.rb', line 8

def initialize()
  super
  self.required_config([:provider_url, :api_key, :username, :password])
  @url      = self.config_option(:provider_url)
  @api_key  = self.config_option(:api_key)
  @username = self.config_option(:username)
  @password = self.config_option(:password)

  @last_call_time = Time.now - 30*60
  @session_id = nil
end

Instance Method Details

#send_bulk_sms(message, numbers, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/splat/vendors/clickatell/clickatell_gateway.rb', line 25

def send_bulk_sms(message, numbers, options = {})
  numbers = numbers.collect{ |x| parse_number(x) }.join(',')
  response = parse_response(call_batch_service(message, numbers))
  response.each do |result|
    options[:response].add(result[1].split(': ').last, result[0])
  end
  options[:response]
end

#send_bulk_sms_with_insertion(message, insertions = {}, options = {}) ⇒ Object



34
35
36
# File 'lib/splat/vendors/clickatell/clickatell_gateway.rb', line 34

def send_bulk_sms_with_insertion(message, insertions = {}, options = {})
  call_batch_service_with_insertion(message, insertions, options[:response])
end

#send_sms(message, number, options = {}) ⇒ Object



20
21
22
23
# File 'lib/splat/vendors/clickatell/clickatell_gateway.rb', line 20

def send_sms(message, number, options = {})
  options[:response].add(number, parse_response(call_service(message, parse_number(number))))
  options[:response]
end