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

package org_tangled

// schema: org.tangled.repo.listRecordVersions

import (
	"context"

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

const (
	RepoListRecordVersionsNSID = "org.tangled.repo.listRecordVersions"
)

// RepoListRecordVersions_Output is the output of a org.tangled.repo.listRecordVersions call.
type RepoListRecordVersions_Output struct {
	// cursor: Cursor for the next page, left out when the page already reaches the newest version
	Cursor   *string                           `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Uri      string                            `json:"uri" cborgen:"uri"`
	Versions []*RepoListRecordVersions_Version `json:"versions" cborgen:"versions"`
}

// RepoListRecordVersions_Version is a "version" in the org.tangled.repo.listRecordVersions schema.
type RepoListRecordVersions_Version struct {
	// changeId: Object ID of the git change that produced this version
	ChangeId string `json:"changeId" cborgen:"changeId"`
	// cid: Content id of this version. Missing when the version was removed or 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 account that authored the change
	Editor string `json:"editor" cborgen:"editor"`
}

// RepoListRecordVersions calls the XRPC method "org.tangled.repo.listRecordVersions".
//
// cursor: Pagination cursor
// order: asc lists the oldest version first, desc the newest.
// uri: Record in a repo this knot hosts
func RepoListRecordVersions(ctx context.Context, c util.LexClient, cursor string, limit int64, order string, uri string) (*RepoListRecordVersions_Output, error) {
	var out RepoListRecordVersions_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, "", "org.tangled.repo.listRecordVersions", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
