Class: TatangoSMS::MO::Handler

Inherits:
Mongrel::HttpHandler
  • Object
show all
Defined in:
lib/tatango_sms/mo.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Handler

Returns a new instance of Handler.



79
80
81
# File 'lib/tatango_sms/mo.rb', line 79

def initialize(&blk)
  @processor = blk
end

Instance Method Details

#process(request, response) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/tatango_sms/mo.rb', line 83

def process(request, response)
  
  params = Hash.from_xml(request.body.read)
  phone_number = params['message']['sender']
  content = params['message']['content']
  
  # puts "Processing request from: #{request.params['REMOTE_ADDR']} phone: #{phone_number}"
  
  @processor.call(phone_number, content)

  response.start(202) do |head,out|
    head["Content-Type"] = 'text/plain'
  end
end