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

package tangled

// schema: sh.tangled.repo.listCobVersions

import (
	"context"

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

const (
	RepoListCobVersionsNSID = "sh.tangled.repo.listCobVersions"
)

// RepoListCobVersions_Output is the output of a sh.tangled.repo.listCobVersions call.
type RepoListCobVersions_Output struct {
	// cursor: Left out when the page already reaches the last version in the requested order.
	Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	// total: How many versions the record has, whatever the page.
	Total    *int64                         `json:"total,omitempty" cborgen:"total,omitempty"`
	Uri      string                         `json:"uri" cborgen:"uri"`
	Versions []*RepoListCobVersions_Version `json:"versions" cborgen:"versions"`
}

// RepoListCobVersions_Version is a "version" in the sh.tangled.repo.listCobVersions schema.
type RepoListCobVersions_Version struct {
	// changeId: Git Object ID of the change associated with this version.
	ChangeId string `json:"changeId" cborgen:"changeId"`
	// cid: Missing once the version is removed, or when the change is a deletion.
	Cid *string `json:"cid,omitempty" cborgen:"cid,omitempty"`
	// createdAt: When this knot wrote the commit this version rides in. Not the record's own `createdAt`.
	CreatedAt string `json:"createdAt" cborgen:"createdAt"`
	// editor: The DID of the account that made this version.
	Editor string `json:"editor" cborgen:"editor"`
}

// RepoListCobVersions calls the XRPC method "sh.tangled.repo.listCobVersions".
//
// cursor: Pass the cursor from one page into the next query to keep walking versions.
// order: Which end the walk starts from. `desc` puts the newest version first, which is where the version you just wrote is.
// uri: AT-URI of a record in a repository this knot hosts, its repository authority a DID.
func RepoListCobVersions(ctx context.Context, c util.LexClient, cursor string, limit int64, order string, uri string) (*RepoListCobVersions_Output, error) {
	var out RepoListCobVersions_Output

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

	return &out, nil
}
