Class: BabySMS::Adapters::TestAdapter::WebHook

Inherits:
WebHook
  • Object
show all
Defined in:
lib/babysms/adapters/test_adapter.rb

Instance Attribute Summary

Attributes inherited from WebHook

#adapter

Instance Method Summary collapse

Methods inherited from WebHook

#end_point, #initialize, #mount_point

Constructor Details

This class inherits a constructor from BabySMS::WebHook

Instance Method Details

#process(app:, report:) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/babysms/adapters/test_adapter.rb', line 49

def process(app:, report:)
  json = JSON.parse(app.request.body.read)
  message = BabySMS::Message.new(to: adapter.from,
                                 from: json["from"],
                                 contents: json["body"])
  report.incoming_message(message)

  [200, { "Content-Type" => "text/plain" }, 'ok']
end