-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplayer.go
More file actions
54 lines (45 loc) · 1 KB
/
player.go
File metadata and controls
54 lines (45 loc) · 1 KB
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
package main
import (
"fmt"
"os"
"strings"
"github.com/joho/godotenv"
"github.com/aaantiii/goclash"
)
func main() {
if err := godotenv.Load(); err != nil {
panic(err)
}
creds := make(goclash.Credentials)
emailStr := os.Getenv("EMAILS")
passwordStr := os.Getenv("PASSWORDS")
emails := strings.Split(emailStr, ",")
passwords := strings.Split(passwordStr, ",")
for i, email := range emails {
creds[email] = passwords[i]
}
client, err := goclash.New(creds)
if err != nil {
panic(err)
}
// get a player by tag
player, err := client.GetPlayer("#8QYG8CJ0")
if err != nil {
panic(err)
}
fmt.Println(player.Name)
// concurrently get multiple players by tag
players, err := client.GetPlayersWithError("#8QYG8CJ0", "#Q9RY8YRYJ")
if err != nil {
panic(err)
}
fmt.Printf("%v\n", players)
// verify player with api token
verification, err := client.VerifyPlayer("#8QYG8CJ0", "apiToken")
if err != nil {
panic(err)
}
if verification.IsOk() {
fmt.Println("verification successful")
}
}