-
Notifications
You must be signed in to change notification settings - Fork 8
/
reset.go
45 lines (35 loc) · 888 Bytes
/
reset.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 client
import (
"encoding/json"
"fmt"
neturl "net/url"
"github.com/nl2go/hrobot-go/models"
)
func (c *Client) ResetGet(ip string) (*models.Reset, error) {
url := fmt.Sprintf(c.baseURL+"/reset/%s", ip)
bytes, err := c.doGetRequest(url)
if err != nil {
return nil, err
}
var resetResp models.ResetResponse
err = json.Unmarshal(bytes, &resetResp)
if err != nil {
return nil, err
}
return &resetResp.Reset, nil
}
func (c *Client) ResetSet(ip string, input *models.ResetSetInput) (*models.ResetPost, error) {
url := fmt.Sprintf(c.baseURL+"/reset/%s", ip)
formData := neturl.Values{}
formData.Set("type", input.Type)
bytes, err := c.doPostFormRequest(url, formData)
if err != nil {
return nil, err
}
var resetResp models.ResetPostResponse
err = json.Unmarshal(bytes, &resetResp)
if err != nil {
return nil, err
}
return &resetResp.Reset, nil
}