-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (44 loc) · 1.14 KB
/
main.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
53
54
55
56
57
58
package main
import (
"context"
"flag"
"fmt"
"os"
"time"
v1 "github.com/vladimirok5959/golang-donatello/donatello/v1"
)
var token = ""
func init() {
flag.StringVar(&token, "token", "", "Token")
flag.Parse()
if token == "" {
if os.Getenv("TOKEN") != "" {
token = os.Getenv("TOKEN")
}
}
}
func main() {
api := v1.NewClientAPI(time.Second*10, token)
client := v1.NewClient(api)
ctx := context.Background()
fmt.Printf("client.Me:\n")
respMe, err := client.Me(ctx)
fmt.Printf("respMe: %#v\n", respMe)
fmt.Printf("err: %#v\n\n", err)
time.Sleep(1000 * time.Millisecond)
fmt.Printf("client.Donates:\n")
respDonates, err := client.Donates(ctx, 0, 20)
fmt.Printf("respDonates: %#v\n", respDonates)
fmt.Printf("err: %#v\n\n", err)
time.Sleep(1000 * time.Millisecond)
fmt.Printf("client.Clients:\n")
respClients, err := client.Clients(ctx)
fmt.Printf("respClients: %#v\n", respClients)
fmt.Printf("err: %#v\n\n", err)
time.Sleep(1000 * time.Millisecond)
fmt.Printf("client.EachDonate:\n")
_ = client.EachDonate(ctx, func(donate *v1.ResponseDonatesContent) error {
fmt.Printf("EachDonate: %#v\n", donate)
return nil
})
}