4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/task_master/webhook_controller.rb', line 4
def create
response = JSON.parse(request.body.read)
request_instance = nil
if response["key"].nil?
head :bad_request and return
end
[CustomRequest].each do |request_class|
break if request_instance = request_class.find_by(key: response["key"])
end
if request_instance
request_instance.responses << response
request_instance.save!
end
head :ok
rescue JSON::ParserError
head :bad_request
end
|