-
Notifications
You must be signed in to change notification settings - Fork 2
/
list_options.go
78 lines (66 loc) · 1.43 KB
/
list_options.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
77
78
package vtwilio
import (
"time"
)
type dateOption int
const (
_ dateOption = iota
before
equal
after
)
type listOptionConfiguration struct {
To string
From string
Date time.Time
DateRange dateOption
PageSize int
Page int
}
// ListOption is a list option
type ListOption func(o *listOptionConfiguration)
// To sets who the message is sent to
func To(to string) ListOption {
return func(r *listOptionConfiguration) {
r.To = to
}
}
// From sets who the message was from
func From(from string) ListOption {
return func(r *listOptionConfiguration) {
r.From = from
}
}
// OnDate get the messages for a specific ay
func OnDate(date time.Time) ListOption {
return func(r *listOptionConfiguration) {
r.Date = date
r.DateRange = equal
}
}
// OnAndBeforeDate get the messages on and before the specified day
func OnAndBeforeDate(date time.Time) ListOption {
return func(r *listOptionConfiguration) {
r.Date = date
r.DateRange = before
}
}
// OnAndAfterDate get the messages on and after the specified day
func OnAndAfterDate(date time.Time) ListOption {
return func(r *listOptionConfiguration) {
r.Date = date
r.DateRange = after
}
}
// PageSize sets the page size
func PageSize(pageSize int) ListOption {
return func(r *listOptionConfiguration) {
r.PageSize = pageSize
}
}
// Page sets the page number
func Page(page int) ListOption {
return func(r *listOptionConfiguration) {
r.Page = page
}
}