/
requestParams.go
64 lines (54 loc) · 1.07 KB
/
requestParams.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
package meta
import (
"strings"
)
type RequestParams struct {
limit int
offset int
sortBy string
sortDirection string
userID string
token string
}
func (p *RequestParams) Limit() int {
return p.limit
}
func (p *RequestParams) SetLimit(limit int) {
p.limit = limit
}
func (p *RequestParams) Offset() int {
return p.offset
}
func (p *RequestParams) SetOffset(offset int) {
p.offset = offset
}
func (p *RequestParams) SortBy() string {
return strings.ToLower(p.sortBy)
}
func (p *RequestParams) SetSortBy(sortBy string) {
p.sortBy = sortBy
}
func (p *RequestParams) SortDirection() string {
return p.sortDirection
}
func (p *RequestParams) SortDirectionNum() int {
if p.sortDirection == "desc" {
return -1
}
return 1
}
func (p *RequestParams) SetSortDirection(direction string) {
p.sortDirection = direction
}
func (p *RequestParams) UserID() string {
return p.userID
}
func (p *RequestParams) SetUserID(userID string) {
p.userID = userID
}
func (p *RequestParams) Token() string {
return p.token
}
func (p *RequestParams) SetToken(token string) {
p.token = token
}