-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwot_auth_prolongate.go
41 lines (35 loc) · 1.21 KB
/
wot_auth_prolongate.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
// Auto generated file!
package wargaming
import (
"context"
"github.com/wows-tools/wows-stats/wargaming/wot"
"strconv"
)
// AuthProlongate generates new access_token based on the current token.
// This method is used when the player is still using the application but the current access_token is about to expire.
//
// https://developers.wargaming.net/reference/all/wot/auth/prolongate
//
// realm:
//
// Valid realms: RealmAsia, RealmEu, RealmNa
//
// accessToken:
//
// Access token for the private data of a user's account; can be received via the authorization method; valid within a stated time period
func (service *WotService) AuthProlongate(ctx context.Context, realm Realm, accessToken string, options *wot.AuthProlongateOptions) (*wot.AuthProlongate, error) {
if err := validateRealm(realm, []Realm{RealmAsia, RealmEu, RealmNa}); err != nil {
return nil, err
}
reqParam := map[string]string{
"access_token": accessToken,
}
if options != nil {
if options.ExpiresAt != nil {
reqParam["expires_at"] = strconv.FormatInt(options.ExpiresAt.Unix(), 10)
}
}
var data *wot.AuthProlongate
err := service.client.postRequest(ctx, sectionWot, realm, "/auth/prolongate/", reqParam, &data, nil)
return data, err
}