-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.go
40 lines (32 loc) · 1.04 KB
/
report.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
package main
import (
"fmt"
"strconv"
"github.com/go-resty/resty/v2"
)
func reportGame(winHistory []Round) {
url := "https://dashboard.kickr.me"
client := resty.New()
var match BackendMatch
resp, err := client.R().
SetHeader("Content-Type", "application/json").
SetResult(&match).
SetBody(BackendMatchWrap{}).
Post(url + "/matches")
fmt.Println("Response Info:")
fmt.Println("Error :", err)
fmt.Println("Status :", resp.Status())
fmt.Println("Time :", resp.Time())
for _, round := range winHistory {
backendRound := BackendRound{Duration: strconv.FormatFloat(round.Time, 'f', 6, 64), Winner: round.Winner, ScoreA: round.ScoreA, ScoreB: round.ScoreB, Match: match.ID}
resp, err := client.R().
SetHeader("Content-Type", "application/json").
SetBody(BackendRoundWrap{Round: backendRound}).
Post(url + "/rounds")
fmt.Println("Response Info:")
fmt.Println("Error :", err)
fmt.Println("Status :", resp.Status())
fmt.Println("Time :", resp.Time())
fmt.Println("Body :", resp)
}
}