-
Notifications
You must be signed in to change notification settings - Fork 0
/
wbsearchentities.go
43 lines (36 loc) · 995 Bytes
/
wbsearchentities.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
package wikidata
import "encoding/json"
// WbSearchEntities request output.
type WbSearchEntitiesInput struct {
Search string `url:"search"`
Language string `url:"language"`
}
type Search struct {
ID string `json:"id"`
URL string `json:"url"`
Label string `json:"label"`
}
// WbSearchEntitiesOutput request output.
type WbSearchEntitiesOutput struct {
Search []Search `json:"search"`
Success int `json:"success"`
}
func (c *Client) NewWbSearchEntitiesInput(search string, language string) *WbSearchEntitiesInput {
return &WbSearchEntitiesInput{
Search: search,
Language: language,
}
}
// WbSearchEntities returns a WbSearchEntitiesOutput.
func (c *Client) WbSearchEntities(in *WbSearchEntitiesInput) (out *WbSearchEntitiesOutput, err error) {
body, err := c.call("wbsearchentities", map[string]string{
"search": in.Search,
"language": in.Language,
})
if err != nil {
return
}
defer body.Close()
err = json.NewDecoder(body).Decode(&out)
return
}