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

package org_tangled

// schema: org.tangled.temp.git.listBranches

import (
	"context"

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

const (
	TempGitListBranchesNSID = "org.tangled.temp.git.listBranches"
)

// TempGitListBranches_BranchInfo is a "branchInfo" in the org.tangled.temp.git.listBranches schema.
type TempGitListBranches_BranchInfo struct {
	Author    *GitDefs_Signature `json:"author" cborgen:"author"`
	Committer *GitDefs_Signature `json:"committer" cborgen:"committer"`
	// message: Latest commit message
	Message string `json:"message" cborgen:"message"`
	// name: Branch name
	Name string `json:"name" cborgen:"name"`
	// oid: Latest commit oid on this branch
	Oid string `json:"oid" cborgen:"oid"`
}

// TempGitListBranches_Output is the output of a org.tangled.temp.git.listBranches call.
type TempGitListBranches_Output struct {
	Branches []*TempGitListBranches_BranchInfo `json:"branches" cborgen:"branches"`
	Cursor   *string                           `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	// defaultBranch: Name of the default branch
	DefaultBranch *string `json:"defaultBranch,omitempty" cborgen:"defaultBranch,omitempty"`
	// total: Total number of branches in the repository
	Total int64 `json:"total" cborgen:"total"`
}

// TempGitListBranches calls the XRPC method "org.tangled.temp.git.listBranches".
//
// cursor: Pagination cursor
// limit: Maximum number of branches to return
// repo: DID of the repository
func TempGitListBranches(ctx context.Context, c util.LexClient, cursor string, limit int64, repo string) (*TempGitListBranches_Output, error) {
	var out TempGitListBranches_Output

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

	return &out, nil
}
