-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl_get_combined_data.go
45 lines (39 loc) · 1.11 KB
/
url_get_combined_data.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
package alchemyapi
import (
"encoding/json"
"strings"
)
// URLGetCombinedDataInput request output.
type URLGetCombinedDataInput struct {
URL string `url:"url"`
Extract string `url:"extract"`
}
// URLGetCombinedDataOutput request output.
type URLGetCombinedDataOutput struct {
Status string `json:"status"`
StatusInfo string `json:"statusInfo"`
Usage string `json:"usage"`
URL string `json:"url"`
Language string `json:"language"`
Author string `json:"author"`
Entities []Entity `json:"entities"`
}
func (c *Client) NewURLGetCombinedDataInput(url string, extract []string) *URLGetCombinedDataInput {
return &URLGetCombinedDataInput{
URL: url,
Extract: strings.Join(extract, ","),
}
}
// URLGetCombinedData returns a URLGetCombinedDataOutput.
func (c *Client) URLGetCombinedData(in *URLGetCombinedDataInput) (out *URLGetCombinedDataOutput, err error) {
body, err := c.call("/url/URLGetCombinedData", map[string]string{
"url": in.URL,
"extract": in.Extract,
})
if err != nil {
return
}
defer body.Close()
err = json.NewDecoder(body).Decode(&out)
return
}