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

package tangled

// schema: sh.tangled.spindle.listMembers

import (
	"context"

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

const (
	SpindleListMembersNSID = "sh.tangled.spindle.listMembers"
)

// SpindleListMembers_ListItem is a "listItem" in the sh.tangled.spindle.listMembers schema.
type SpindleListMembers_ListItem struct {
	Cid *string `json:"cid,omitempty" cborgen:"cid,omitempty"`
	Uri string  `json:"uri" cborgen:"uri"`
	// value: Embedded sh.tangled.spindle.member record
	Value *util.LexiconTypeDecoder `json:"value" cborgen:"value"`
}

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

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

	return &out, nil
}
