forked from ariefrahmansyah/fingerplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice.go
76 lines (61 loc) · 1.55 KB
/
device.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package fingerplus
import (
"encoding/json"
"net/url"
)
type DeviceInfo struct {
Result bool `json:"Result"`
Data DeviceInfoData `json:"DEVINFO"`
}
type DeviceInfoData struct {
Jam string `json:"Jam"`
Admin string `json:"Admin"`
User string `json:"User"`
FP string `json:"FP"`
CARD string `json:"CARD"`
PWD string `json:"PWD"`
AllOperasional string `json:"All Operasional"`
AllPresensi string `json:"All Presensi"`
NewOperasional string `json:"New Operasional"`
NewPresensi string `json:"New Presensi"`
}
func (fp *Fingerplus) GetDeviceInfo(serialNumber string) (DeviceInfo, error) {
params := url.Values{
"sn": {serialNumber},
}
postman := NewPostman()
postman.Header = header
postman.Method = MethodPost
postman.URL = fp.ServerURL + getDeviceInfo
postman.Params = params
_, body, err := postman.Send()
if err != nil {
return DeviceInfo{}, err
}
deviceInfo := DeviceInfo{}
err = json.Unmarshal(body, &deviceInfo)
if err != nil {
return DeviceInfo{}, err
}
return deviceInfo, nil
}
func (fp *Fingerplus) SetTime(serialNumber string) (Response, error) {
params := url.Values{
"sn": {serialNumber},
}
postman := NewPostman()
postman.Header = header
postman.Method = MethodPost
postman.URL = fp.ServerURL + setTime
postman.Params = params
_, body, err := postman.Send()
if err != nil {
return Response{}, err
}
response := Response{}
err = json.Unmarshal(body, &response)
if err != nil {
return Response{}, err
}
return response, nil
}