Skip to content

Commit

Permalink
feat: add Order type
Browse files Browse the repository at this point in the history
  • Loading branch information
tomMoulard committed Apr 30, 2024
1 parent 9f105b6 commit 7ce89dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 8 additions & 7 deletions pkg/channel/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,18 @@ type ListGroupChannelRequest struct {
ShowFrozen *bool
// Order specifies the method to sort a list of results. Acceptable values
// are the following:
// - chronological (default): sorts by time of channel creation, from most to
// least recent.
// - latest_last_message: sorts by the time of the last message in the
// - OrderChronological (default): sorts by time of channel creation, from
// most to least recent.
// - OrderLatestLastMessage: sorts by the time of the last message in the
// channel, from most to least recent. This is available only when user_id is
// specified.
// - channel_name_alphabetical: sorts by channel name in alphabetical order.
// - metadata_value_alphabetical: sorts by a value of metadata in
// - OrderChannelNameAlphabetical: sorts by channel name in alphabetical
// order.
// - OrderMetadataValueAlphabetical: sorts by a value of metadata in
// alphabetical order. This is available only when the metadata_order_key
// parameter is specified.
// Optional.
Order string
Order Order
// MetadataOrderKey specifies the key of an item in metadata. When a value of
// the order parameter is set to metadata_value_alphabetical, the results are
// alphabetically sorted by the value of the item specified by the key.
Expand Down Expand Up @@ -292,7 +293,7 @@ func listChannelRequestToMap(lcr ListGroupChannelRequest) map[string]string {
}

if lcr.Order != "" {
m["order"] = lcr.Order
m["order"] = string(lcr.Order)
}

if lcr.MetadataOrderKey != "" {
Expand Down
10 changes: 6 additions & 4 deletions pkg/channel/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ const (
SuperModeNonSuper SuperMode = "nonsuper"
)

type Order string

const (
OrderChronological string = "chronological"
OrderLatestLastMessage string = "latest_last_message"
OderChannelNameAlphabetical string = "channel_name_alphabetical"
OrderMetadataValueAlphabetical string = "metadata_value_alphabetical"
OrderChronological Order = "chronological"
OrderLatestLastMessage Order = "latest_last_message"
OrderChannelNameAlphabetical Order = "channel_name_alphabetical"
OrderMetadataValueAlphabetical Order = "metadata_value_alphabetical"
)

const (
Expand Down

0 comments on commit 7ce89dc

Please sign in to comment.