Skip to content

Commit

Permalink
fix: Adds missing params for listing SAML connections
Browse files Browse the repository at this point in the history
Listing SAML connections also supports query and
order_by.
This commit includes these two options.
  • Loading branch information
alex-ntousias committed Mar 2, 2024
1 parent ab5b551 commit 06760da
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
11 changes: 10 additions & 1 deletion samlconnection/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,20 @@ func (c *Client) Delete(ctx context.Context, id string) (*clerk.DeletedResource,
type ListParams struct {
clerk.APIParams
clerk.ListParams
Query *string `json:"query,omitempty"`
OrderBy *string `json:"order_by,omitempty"`
}

// ToQuery returns query string values from the params.
func (params *ListParams) ToQuery() url.Values {
return params.ListParams.ToQuery()
q := params.ListParams.ToQuery()
if params.Query != nil {
q.Set("query", *params.Query)
}
if params.OrderBy != nil {
q.Set("order_by", *params.OrderBy)
}
return q
}

// List returns a list of SAML Connections.
Expand Down
13 changes: 10 additions & 3 deletions samlconnection/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,20 @@ func TestSAMLConnectionClientList(t *testing.T) {
Method: http.MethodGet,
Path: "/v1/saml_connections",
Query: &url.Values{
"limit": []string{"1"},
"limit": []string{"1"},
"query": []string{"Acme"},
"order_by": []string{"-created_at"},
},
},
}
client := NewClient(config)
params := &ListParams{}
params.Limit = clerk.Int64(1)
params := &ListParams{
ListParams: clerk.ListParams{
Limit: clerk.Int64(1),
},
Query: clerk.String("Acme"),
OrderBy: clerk.String("-created_at"),
}
list, err := client.List(context.Background(), params)
require.NoError(t, err)
require.Equal(t, int64(1), list.TotalCount)
Expand Down

0 comments on commit 06760da

Please sign in to comment.