-
Notifications
You must be signed in to change notification settings - Fork 0
/
blocks.3.3.get_task_status_for_block.go
52 lines (43 loc) · 1.21 KB
/
blocks.3.3.get_task_status_for_block.go
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
package blocks
import (
"encoding/json"
"io"
"net/http"
"github.com/snowpal/pitch-building-blocks-sdk/lib"
helpers2 "github.com/snowpal/pitch-building-blocks-sdk/lib/helpers"
"github.com/snowpal/pitch-building-blocks-sdk/lib/structs/common"
"github.com/snowpal/pitch-building-blocks-sdk/lib/structs/response"
)
func GetTaskStatusForBlock(jwtToken string, taskParam common.ResourceIdParam) (response.TasksStatusBlock, error) {
resBlockTasksStatus := response.TasksStatusBlock{}
route, err := helpers2.GetRoute(
lib.RouteBlocksGetTaskStatusForBlock,
taskParam.KeyId,
taskParam.BlockId,
)
if err != nil {
return resBlockTasksStatus, err
}
var req *http.Request
req, err = http.NewRequest(http.MethodGet, route, nil)
if err != nil {
return resBlockTasksStatus, err
}
helpers2.AddUserHeaders(jwtToken, req)
var res *http.Response
res, err = helpers2.MakeRequest(req)
if err != nil {
return resBlockTasksStatus, err
}
defer helpers2.CloseBody(res.Body)
var body []byte
body, err = io.ReadAll(res.Body)
if err != nil {
return resBlockTasksStatus, err
}
err = json.Unmarshal(body, &resBlockTasksStatus)
if err != nil {
return resBlockTasksStatus, err
}
return resBlockTasksStatus, nil
}