Skip to content

Commit

Permalink
lots more tests, prep for lots more
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Gealer committed Sep 10, 2022
1 parent 7cdd224 commit 1db0bdc
Show file tree
Hide file tree
Showing 9 changed files with 424 additions and 41 deletions.
42 changes: 21 additions & 21 deletions categories_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (t ClientCategoryChannelsTokens) Delete(ctx context.Context, projectId, id
// Create is used to create a new channel token. State is the map of the state of the token (this can be nil), and
// projectId is the project ID to associate the token with (this can be empty unless it is bearer or PAT auth).
func (t ClientCategoryChannelsTokens) Create(ctx context.Context, projectId string, state map[string]any) (*types.ChannelToken, error) {
if projectId == "" && t.c.tokenType != "ptk" {
if projectId == "" && t.c.getTokenType() != "ptk" {
return nil, types.InvalidToken("project ID must be specified when creating a channel token with bearer or PAT auth")
}
if state == nil {
Expand Down
9 changes: 8 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type responseBody struct {
Data json.RawMessage `json:"data"`
}

func (c *Client) getTokenType() string { return c.tokenType }

// Does the specified HTTP request.
func (c *Client) do(ctx context.Context, a clientArgs) error {
// Handle getting the body bytes.
Expand Down Expand Up @@ -238,9 +240,14 @@ func (c *Client) do(ctx context.Context, a clientArgs) error {
return nil
}

type clientDoer interface {
do(ctx context.Context, a clientArgs) error
getTokenType() string
}

// Paginator is used to create a way to access paginated API routes.
type Paginator[T any] struct {
c *Client
c clientDoer
pageIndex int
count int
total int // should be set to -1 on init.
Expand Down
Loading

0 comments on commit 1db0bdc

Please sign in to comment.