Class: Smess::Clickatell

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

Instance Attribute Summary collapse

Attributes inherited from Output

#config

Instance Method Summary collapse

Methods included from Logging

#logger

Methods inherited from Output

#check, #send_feedback, #verify

Constructor Details

#initialize(config) ⇒ Clickatell

Returns a new instance of Clickatell.



29
30
31
32
33
# File 'lib/smess/outputs/clickatell.rb', line 29

def initialize(config)
  super
  ::Clickatell::API.debug_mode = true
  ::Clickatell::API.secure_mode = true
end

Instance Attribute Details

#api_idObject

Returns the value of attribute api_id.



50
51
52
# File 'lib/smess/outputs/clickatell.rb', line 50

def api_id
  @api_id
end

#passObject

Returns the value of attribute pass.



50
51
52
# File 'lib/smess/outputs/clickatell.rb', line 50

def pass
  @pass
end

#sender_idObject

Returns the value of attribute sender_id.



50
51
52
# File 'lib/smess/outputs/clickatell.rb', line 50

def sender_id
  @sender_id
end

#sender_idsObject

Returns the value of attribute sender_ids.



50
51
52
# File 'lib/smess/outputs/clickatell.rb', line 50

def sender_ids
  @sender_ids
end

#userObject

Returns the value of attribute user.



50
51
52
# File 'lib/smess/outputs/clickatell.rb', line 50

def user
  @user
end

Instance Method Details

#deliverObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/smess/outputs/clickatell.rb', line 35

def deliver
  begin
    responses = []
    messages.each do |msg|
      rsp = api.send_message(sms.to, msg.encode('ISO-8859-1'), {from: from, concat: 3, callback: 7})
      responses << rsp
    end
    result = normal_result(responses.first)
  rescue => e
    # connection problem or some error
    result = result_for_error(e)
  end
  result
end

#validate_configObject



51
52
53
54
55
56
57
# File 'lib/smess/outputs/clickatell.rb', line 51

def validate_config
  @api_id     = config.fetch(:api_id)
  @user       = config.fetch(:user)
  @pass       = config.fetch(:pass)
  @sender_id  = config.fetch(:sender_id)
  @sender_ids = config.fetch(:sender_ids)
end