-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwot_encyclopedia_modules.go
58 lines (52 loc) · 1.76 KB
/
wot_encyclopedia_modules.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
// Auto generated file!
package wargaming
import (
"context"
"github.com/wows-tools/wows-stats/wargaming/internal"
"github.com/wows-tools/wows-stats/wargaming/wot"
"strconv"
"strings"
)
// EncyclopediaModules returns list of available modules that can be installed on vehicles, such as engines, turrets, etc. At least one input filter parameter (module ID, type) is required to be indicated.
//
// https://developers.wargaming.net/reference/all/wot/encyclopedia/modules
//
// realm:
//
// Valid realms: RealmAsia, RealmEu, RealmNa
func (service *WotService) EncyclopediaModules(ctx context.Context, realm Realm, options *wot.EncyclopediaModulesOptions) (*wot.EncyclopediaModules, *GenericMeta, error) {
if err := validateRealm(realm, []Realm{RealmAsia, RealmEu, RealmNa}); err != nil {
return nil, nil, err
}
reqParam := map[string]string{}
if options != nil {
if options.Extra != nil {
reqParam["extra"] = strings.Join(options.Extra, ",")
}
if options.Fields != nil {
reqParam["fields"] = strings.Join(options.Fields, ",")
}
if options.Language != nil {
reqParam["language"] = *options.Language
}
if options.Limit != nil {
reqParam["limit"] = strconv.Itoa(*options.Limit)
}
if options.ModuleId != nil {
reqParam["module_id"] = internal.SliceIntToString(options.ModuleId, ",")
}
if options.Nation != nil {
reqParam["nation"] = strings.Join(options.Nation, ",")
}
if options.PageNo != nil {
reqParam["page_no"] = strconv.Itoa(*options.PageNo)
}
if options.Type != nil {
reqParam["type"] = strings.Join(options.Type, ",")
}
}
var data *wot.EncyclopediaModules
var metaData *GenericMeta
err := service.client.getRequest(ctx, sectionWot, realm, "/encyclopedia/modules/", reqParam, &data, &metaData)
return data, metaData, err
}