-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
59 lines (53 loc) · 1.04 KB
/
Copy pathexample_test.go
File metadata and controls
59 lines (53 loc) · 1.04 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
55
56
57
58
59
package habbo_test
import (
"context"
"errors"
"fmt"
"net/http"
"os"
"time"
habbo "github.com/alynva/Habbo-API-Wrapper-Go"
)
func ExampleNewClient() {
client, err := habbo.NewClient(
"https://www.habbo.com.br/",
habbo.WithHTTPClient(&http.Client{Timeout: 10 * time.Second}),
)
if err != nil {
panic(err)
}
user, response, err := client.Users.ByName(context.Background(), "Frank", nil)
if err != nil {
var apiError *habbo.ErrorResponse
if errors.As(err, &apiError) {
fmt.Println(apiError.Response.StatusCode)
}
return
}
_ = response.Header.Get("ETag")
_ = user.Name
}
func ExampleNewWiredClient() {
client, err := habbo.NewWiredClient(
"https://www.habbo.com/",
123456,
habbo.WiredKeys{
ReadKey: os.Getenv("HABBO_WIRED_READ_KEY"),
WriteKey: os.Getenv("HABBO_WIRED_WRITE_KEY"),
},
)
if err != nil {
panic(err)
}
variable, _, err := client.Wired.GetValue(
context.Background(),
habbo.WiredScopeUser,
"score",
habbo.WiredTargetUsers,
"44",
)
if err != nil {
return
}
_ = variable.Value
}