-
Notifications
You must be signed in to change notification settings - Fork 2
/
callLog.go
35 lines (32 loc) · 814 Bytes
/
callLog.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
package termux
import (
"bytes"
"encoding/json"
)
// CallLogPiece represents one piece of call log
type CallLogPiece struct {
Name string `json:"name"`
Number string `json:"phone_number"`
Type string `json:"type"`
Date string `json:"date"`
Duration string `json:"duration"`
}
// CallLog acquires call logs with a given limit and offset
func CallLog(limit int, offset int) ([]CallLogPiece, error) {
buf := bytes.NewBuffer([]byte{})
if err := exec(nil, buf, "CallLog", map[string]interface{}{
"limit": limit,
"offset": offset,
}, ""); err != nil {
return nil, err
}
res := buf.Bytes()
if err := checkErr(res); err != nil {
return nil, err
}
records := make([]CallLogPiece, 0)
if err := json.Unmarshal(res, &records); err != nil {
return nil, err
}
return records, nil
}