-
Notifications
You must be signed in to change notification settings - Fork 2
/
ip.go
37 lines (34 loc) · 838 Bytes
/
ip.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
package api
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
// IPDetails by file_id
func (api *API) IPDetails(ip string) (string, error) {
url := fmt.Sprintf("%s/ip/%s", api.URL, ip)
req, err := http.NewRequest(http.MethodGet, url, nil)
req.Header.Add("apikey", api.Token)
if err != nil {
return "", err
}
return fmtResponse(api.Client.Do(req))
}
// IPsDetails by file_ids
func (api *API) IPsDetails(address []string) (string, error) {
url := fmt.Sprintf("%s/ip", api.URL)
payload := struct {
Address []string `json:"address"`
}{
address,
}
j, _ := json.Marshal(payload)
req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(j))
req.Header.Add("apikey", api.Token)
if err != nil {
return "", err
}
req.Header.Add("content-type", "application/json")
return fmtResponse(api.Client.Do(req))
}