Skip to content

Commit f8cbc59

Browse files
committed
Added messageQuery params
1 parent c8643b4 commit f8cbc59

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

message.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ type MessageParams struct {
3838
ScheduledDatetime time.Time
3939
}
4040

41+
type MessageQueryParams struct {
42+
Originator string
43+
Direction string
44+
Limit int
45+
Offset int
46+
}
47+
4148
// paramsForMessage converts the specified MessageParams struct to a
4249
// url.Values pointer and returns it.
4350
func paramsForMessage(params *MessageParams) (*url.Values, error) {
@@ -82,3 +89,27 @@ func paramsForMessage(params *MessageParams) (*url.Values, error) {
8289

8390
return urlParams, nil
8491
}
92+
93+
func paramsForMessageQuery(params *MessageQueryParams) (*url.Values, error) {
94+
urlParams := &url.Values{}
95+
96+
if params == nil {
97+
return urlParams, nil
98+
}
99+
100+
if params.Direction != "" {
101+
urlParams.Set("direction", params.Direction)
102+
}
103+
104+
if params.Originator != "" {
105+
urlParams.Set("originator", params.Originator)
106+
}
107+
108+
if params.Limit != 0 {
109+
urlParams.Set("limit", strconv.Itoa(params.Limit))
110+
}
111+
112+
urlParams.Set("offset", strconv.Itoa(params.Offset))
113+
114+
return urlParams, nil
115+
}

0 commit comments

Comments
 (0)