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

package tangled

// schema: sh.tangled.knot.listMembers

import (
	"context"

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

const (
	KnotListMembersNSID = "sh.tangled.knot.listMembers"
)

// KnotListMembers_ListItem is a "listItem" in the sh.tangled.knot.listMembers schema.
type KnotListMembers_ListItem struct {
	// addedBy: DID that added this member
	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 member was added
	CreatedAt string `json:"createdAt" cborgen:"createdAt"`
	// subject: DID of the member
	Subject string `json:"subject" cborgen:"subject"`
	// uri: Optional record AT-URI for record-backed indexers
	Uri *string `json:"uri,omitempty" cborgen:"uri,omitempty"`
}

// KnotListMembers_Output is the output of a sh.tangled.knot.listMembers call.
type KnotListMembers_Output struct {
	Cursor *string                     `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Items  []*KnotListMembers_ListItem `json:"items" cborgen:"items"`
}

// KnotListMembers calls the XRPC method "sh.tangled.knot.listMembers".
//
// cursor: Pagination cursor
// order: Sort direction by createdAt.
// subject: Knot identifier whose member records to list.
func KnotListMembers(ctx context.Context, c util.LexClient, cursor string, limit int64, order string, subject string) (*KnotListMembers_Output, error) {
	var out KnotListMembers_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.knot.listMembers", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
