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

package tangled

// schema: sh.tangled.spindle.listSpindles

import (
	"context"

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

const (
	SpindleListSpindlesNSID = "sh.tangled.spindle.listSpindles"
)

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

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

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

	return &out, nil
}
