12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/alloy_sdk.rb', line 12
def self.find(apiKey,workflowId,data,returnExecutionData)
uuid = SecureRandom.uuid
responseOfWebHook = Faraday.post("https://webhooks.runalloy.com/#{workflowId}",
{
:body => data.to_json,
:headers => {
'Authorization' => 'Bearer ' + apiKey,
'X-Execution-Uuid' => uuid,
'Accept' => 'application/json',
'Content-Type' => 'text/html'
}
})
if returnExecutionData === true
x = 10
while x >= 1
Timeout.timeout(5) do
responseOfWebHookOutput = Faraday.get("https://api.runalloy.com/sdk/output/#{uuid}",{
:body => data.to_json,
:headers => {
'Authorization' => 'Bearer ' + apiKey,
'Accept' => 'application/json',
'Content-Type' => 'text/html'
}
})
puts responseOfWebHookOutput.status
if responseOfWebHookOutput.status === 200
return responseOfWebHookOutput.body
elseif x>=1
else
x = x - 1
end
end
end
else
return responseOfWebHook
end
end
|