forked from Kucoin/kucoin-futures-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagination.go
28 lines (23 loc) · 910 Bytes
/
pagination.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
package kumex
import "encoding/json"
// A PaginationParam represents the pagination parameters `currentPage` `pageSize` in a request .
type PaginationParam struct {
CurrentPage int64
PageSize int64
}
// ReadParam read pagination parameters into params.
func (p *PaginationParam) ReadParam(params map[string]string) {
params["currentPage"], params["pageSize"] = IntToString(p.CurrentPage), IntToString(p.PageSize)
}
// A PaginationModel represents the pagination in a response.
type PaginationModel struct {
CurrentPage int64 `json:"currentPage"`
PageSize int64 `json:"pageSize"`
TotalNum int64 `json:"totalNum"`
TotalPage int64 `json:"totalPage"`
RawItems json.RawMessage `json:"items"` // delay parsing
}
// ReadItems read the `items` into v.
func (p *PaginationModel) ReadItems(v interface{}) error {
return json.Unmarshal(p.RawItems, v)
}