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

package org_tangled

// schema: org.tangled.repo.listCollaborators

import (
	"context"

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

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

// RepoListCollaborators_ListItem is a "listItem" in the org.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 repository offered collaboration
	CreatedAt string `json:"createdAt" cborgen:"createdAt"`
	// effectiveSince: When the collaboration took effect. This listing sorts and pages on it.
	EffectiveSince string `json:"effectiveSince" cborgen:"effectiveSince"`
	// 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"`
	// verifiedAt: When the knot resolved the collaborator's own acceptance record. Absent on a grant that predates the consent model.
	VerifiedAt *string `json:"verifiedAt,omitempty" cborgen:"verifiedAt,omitempty"`
}

// RepoListCollaborators_Output is the output of a org.tangled.repo.listCollaborators call.
type RepoListCollaborators_Output struct {
	Cursor *string                           `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Items  []*RepoListCollaborators_ListItem `json:"items" cborgen:"items"`
	// total: Total items in the full list; omitted for filtered or merged views
	Total *int64 `json:"total,omitempty" cborgen:"total,omitempty"`
}

// RepoListCollaborators calls the XRPC method "org.tangled.repo.listCollaborators".
//
// cursor: Pagination cursor
// offset: Absolute offset for random-access pagination. Mutually exclusive with cursor; offsets drift under concurrent writes, so follow up with the returned cursor.
// order: Sort direction by effectiveSince.
// subject: Repo DID whose collaborator records to list.
func RepoListCollaborators(ctx context.Context, c util.LexClient, cursor string, limit int64, offset 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 offset != 0 {
		params["offset"] = offset
	}
	if order != "" {
		params["order"] = order
	}
	params["subject"] = subject
	if err := c.LexDo(ctx, util.Query, "", "org.tangled.repo.listCollaborators", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
