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

package org_tangled

// schema: org.tangled.temp.repo.listRecordOrigins

import (
	"context"

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

const (
	TempRepoListRecordOriginsNSID = "org.tangled.temp.repo.listRecordOrigins"
)

// TempRepoListRecordOrigins_Origin is a "origin" in the org.tangled.temp.repo.listRecordOrigins schema.
type TempRepoListRecordOrigins_Origin struct {
	// author: The DID of the account that opened the record, the editor of its first version.
	Author string `json:"author" cborgen:"author"`
	// changeId: Git Object ID of the change that opened the record.
	ChangeId string `json:"changeId" cborgen:"changeId"`
	// createdAt: When the knot wrote the opening change. Not the record's own `createdAt`.
	CreatedAt string `json:"createdAt" cborgen:"createdAt"`
	Rkey      string `json:"rkey" cborgen:"rkey"`
}

// TempRepoListRecordOrigins_Output is the output of a org.tangled.temp.repo.listRecordOrigins call.
type TempRepoListRecordOrigins_Output struct {
	Collection string `json:"collection" cborgen:"collection"`
	// cursor: Left out when the page already reaches the last record.
	Cursor  *string                             `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Origins []*TempRepoListRecordOrigins_Origin `json:"origins" cborgen:"origins"`
	Repo    string                              `json:"repo" cborgen:"repo"`
}

// TempRepoListRecordOrigins calls the XRPC method "org.tangled.temp.repo.listRecordOrigins".
//
// collection: A versioned collection, such as `org.tangled.track.ticket`.
// cursor: Pass the cursor from one page into the next query to keep walking records.
// repo: DID of the repository.
func TempRepoListRecordOrigins(ctx context.Context, c util.LexClient, collection string, cursor string, limit int64, repo string) (*TempRepoListRecordOrigins_Output, error) {
	var out TempRepoListRecordOrigins_Output

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

	return &out, nil
}
