Skip to content

Commit

Permalink
fix: Pagination parameters for samlconnection.List
Browse files Browse the repository at this point in the history
The List operation of the SAML connections API supports pagination with
limit and offset query string parameters.
  • Loading branch information
gkats committed Mar 1, 2024
1 parent 29c1e6b commit d07bc51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions samlconnection/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package samlconnection
import (
"context"
"net/http"
"net/url"

"github.com/clerk/clerk-sdk-go/v2"
)
Expand Down Expand Up @@ -107,6 +108,12 @@ func (c *Client) Delete(ctx context.Context, id string) (*clerk.DeletedResource,

type ListParams struct {
clerk.APIParams
clerk.ListParams
}

// ToQuery returns query string values from the params.
func (params *ListParams) ToQuery() url.Values {
return params.ListParams.ToQuery()
}

// List returns a list of SAML Connections.
Expand Down
8 changes: 7 additions & 1 deletion samlconnection/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"testing"

"github.com/clerk/clerk-sdk-go/v2"
Expand Down Expand Up @@ -174,10 +175,15 @@ func TestSAMLConnectionClientList(t *testing.T) {
}`, id, name, domain, provider)),
Method: http.MethodGet,
Path: "/v1/saml_connections",
Query: &url.Values{
"limit": []string{"1"},
},
},
}
client := NewClient(config)
list, err := client.List(context.Background(), &ListParams{})
params := &ListParams{}
params.Limit = clerk.Int64(1)
list, err := client.List(context.Background(), params)
require.NoError(t, err)
require.Equal(t, int64(1), list.TotalCount)
require.Equal(t, 1, len(list.SAMLConnections))
Expand Down

0 comments on commit d07bc51

Please sign in to comment.