Skip to content

Commit

Permalink
fix(invitations): Support multiple statuses (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
kostaspt authored Sep 10, 2024
1 parent 9f458ce commit 807c124
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions invitation/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func NewClient(config *clerk.ClientConfig) *Client {
type ListParams struct {
clerk.APIParams
clerk.ListParams
OrderBy *string `json:"order_by,omitempty"`
Query *string `json:"query,omitempty"`
Status *string `json:"status,omitempty"`
OrderBy *string `json:"order_by,omitempty"`
Query *string `json:"query,omitempty"`
Statuses []string `json:"status,omitempty"`
}

// ToQuery returns query string values from the params.
Expand All @@ -42,8 +42,8 @@ func (params *ListParams) ToQuery() url.Values {
if params.Query != nil {
q.Set("query", *params.Query)
}
if params.Status != nil {
q.Set("status", *params.Status)
for _, status := range params.Statuses {
q.Add("status", status)
}
return q
}
Expand Down
11 changes: 6 additions & 5 deletions invitation/invitation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func TestInvitationListWithParams(t *testing.T) {
offset := int64(20)
orderBy := "-created_at"
query := "[email protected]"
status := "pending"
status1 := "pending"
status2 := "accepted"

clerk.SetBackend(clerk.NewBackend(&clerk.BackendConfig{
HTTPClient: &http.Client{
Expand All @@ -61,7 +62,7 @@ func TestInvitationListWithParams(t *testing.T) {
"offset": []string{fmt.Sprintf("%d", offset)},
"order_by": []string{orderBy},
"query": []string{query},
"status": []string{status},
"status": []string{status1, status2},
"paginated": []string{"true"},
},
},
Expand All @@ -73,9 +74,9 @@ func TestInvitationListWithParams(t *testing.T) {
Limit: &limit,
Offset: &offset,
},
OrderBy: &orderBy,
Query: &query,
Status: &status,
OrderBy: &orderBy,
Query: &query,
Statuses: []string{status1, status2},
})
require.NoError(t, err)
require.Equal(t, int64(2), list.TotalCount)
Expand Down

0 comments on commit 807c124

Please sign in to comment.