-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirst-Post-Request.lua
58 lines (53 loc) · 1.74 KB
/
First-Post-Request.lua
1
2
3
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
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
56
57
58
local json = require("json")
_0RBIT = "BaMK1dfayo75s3q1ow6AO64UDpD9SEFbeE8xYrY2fyQ"
_0RBT_TOKEN = "BUhZLMwQ6yZHguLtJYA5lLUa9LQzLXMXRfaq9FVcPJc"
FEE_AMOUNT = "1000000000000" -- 1 $0RBT
BASE_URL = "https://g8way.0rbit.co/graphql"
-- The data body to be sent in the POST request
BODY = json.encode({
query = [[
query {
transactions(
owners: ["vh-NTHVvlKZqRxc8LyyTNok65yQ55a_PJ1zWLb9G2JI"]
) {
edges {
node {
id
}
}
}
}
]]
});
ReceivedData = ReceivedData or {}
--[[
Handler to send 1 $0RBT and a GET request to the `0rbit` process.
]]
Handlers.add(
"Post-Request",
Handlers.utils.hasMatchingTag("Action", "First-Post-Request"),
function(msg)
Send({
Target = _0RBT_TOKEN,
Action = "Transfer",
Recipient = _0RBIT,
Quantity = FEE_AMOUNT,
["X-Url"] = BASE_URL,
["X-Action"] = "Post-Real-Data",
["X-Body"] = BODY
})
print(Colors.green .. "You have sent a POST Request to the 0rbit process.")
end
)
--[[
Handler to receive the data from the `0rbit` process.
]]
Handlers.add(
"Receive-Data",
Handlers.utils.hasMatchingTag("Action", "Receive-Response"),
function(msg)
local res = json.decode(msg.Data)
ReceivedData = res
print(Colors.green .. "You have received the data from the 0rbit process.")
end
)