-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcursor.go
41 lines (36 loc) · 876 Bytes
/
cursor.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
package kintone
import (
"encoding/json"
)
// Object Cursor structure
type Cursor struct {
Id string `json:"id"`
TotalCount string `json:"totalCount"`
}
type GetRecordsCursorResponse struct {
Records []*Record `json:"records"`
Next bool `json:"next"`
}
// decodeCursor decodes JSON response for cursor api
func decodeCursor(b []byte) (c *Cursor, err error) {
err = json.Unmarshal(b, &c)
if err != nil {
return nil, err
}
return c, nil
}
func DecodeGetRecordsCursorResponse(b []byte) (rc *GetRecordsCursorResponse, err error) {
var t struct {
Next bool `json:"next"`
}
err = json.Unmarshal(b, &t)
if err != nil {
return nil, err
}
listRecord, err := DecodeRecords(b)
if err != nil {
return nil, err
}
getRecordsCursorResponse := &GetRecordsCursorResponse{Records: listRecord, Next: t.Next}
return getRecordsCursorResponse, nil
}