// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package tangled

// schema: sh.tangled.repo.listCollaborators

import (
	"context"

	"github.com/bluesky-social/indigo/lex/util"
)

const (
	RepoListCollaboratorsNSID = "sh.tangled.repo.listCollaborators"
)

// RepoListCollaborators_ListItem is a "listItem" in the sh.tangled.repo.listCollaborators schema.
type RepoListCollaborators_ListItem struct {
	// addedBy: DID that added this collaborator
	AddedBy string `json:"addedBy" cborgen:"addedBy"`
	// cid: Optional record CID for record-backed indexers
	Cid *string `json:"cid,omitempty" cborgen:"cid,omitempty"`
	// createdAt: When the collaborator was added
	CreatedAt string `json:"createdAt" cborgen:"createdAt"`
	// subject: DID of the collaborator
	Subject string `json:"subject" cborgen:"subject"`
	// uri: Optional record AT-URI for record-backed indexers
	Uri *string `json:"uri,omitempty" cborgen:"uri,omitempty"`
}

// RepoListCollaborators_Output is the output of a sh.tangled.repo.listCollaborators call.
type RepoListCollaborators_Output struct {
	Cursor *string                           `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Items  []*RepoListCollaborators_ListItem `json:"items" cborgen:"items"`
}

// RepoListCollaborators calls the XRPC method "sh.tangled.repo.listCollaborators".
//
// cursor: Pagination cursor
// order: Sort direction by createdAt.
// subject: Repo DID whose collaborator records to list.
func RepoListCollaborators(ctx context.Context, c util.LexClient, cursor string, limit int64, order string, subject string) (*RepoListCollaborators_Output, error) {
	var out RepoListCollaborators_Output

	params := map[string]interface{}{}
	if cursor != "" {
		params["cursor"] = cursor
	}
	if limit != 0 {
		params["limit"] = limit
	}
	if order != "" {
		params["order"] = order
	}
	params["subject"] = subject
	if err := c.LexDo(ctx, util.Query, "", "sh.tangled.repo.listCollaborators", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
