forked from nl2go/hrobot-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreset.go
45 lines (35 loc) · 883 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/syself/hrobot-go/models"
)
func (c *Client) ResetGet(id int) (*models.Reset, error) {
url := fmt.Sprintf(c.baseURL+"/reset/%v", id)
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(id int, input *models.ResetSetInput) (*models.ResetPost, error) {
url := fmt.Sprintf(c.baseURL+"/reset/%v", id)
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
}