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

package tangled

// schema: sh.tangled.repo.blob

import (
	"context"

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

const (
	RepoBlobNSID = "sh.tangled.repo.blob"
)

// RepoBlob_LastCommit is a "lastCommit" in the sh.tangled.repo.blob schema.
type RepoBlob_LastCommit struct {
	Author *RepoBlob_Signature `json:"author,omitempty" cborgen:"author,omitempty"`
	// hash: Commit hash
	Hash string `json:"hash" cborgen:"hash"`
	// message: Commit message
	Message string `json:"message" cborgen:"message"`
	// when: Commit timestamp
	When string `json:"when" cborgen:"when"`
}

// RepoBlob_Output is the output of a sh.tangled.repo.blob call.
type RepoBlob_Output struct {
	// content: File content (base64 encoded for binary files)
	Content *string `json:"content,omitempty" cborgen:"content,omitempty"`
	// encoding: Content encoding
	Encoding *string `json:"encoding,omitempty" cborgen:"encoding,omitempty"`
	// isBinary: Whether the file is binary
	IsBinary   *bool                `json:"isBinary,omitempty" cborgen:"isBinary,omitempty"`
	LastCommit *RepoBlob_LastCommit `json:"lastCommit,omitempty" cborgen:"lastCommit,omitempty"`
	// mimeType: MIME type of the file
	MimeType *string `json:"mimeType,omitempty" cborgen:"mimeType,omitempty"`
	// path: The file path
	Path string `json:"path" cborgen:"path"`
	// ref: The git reference used
	Ref string `json:"ref" cborgen:"ref"`
	// size: File size in bytes
	Size *int64 `json:"size,omitempty" cborgen:"size,omitempty"`
	// submodule: Submodule information if path is a submodule
	Submodule *RepoBlob_Submodule `json:"submodule,omitempty" cborgen:"submodule,omitempty"`
}

// RepoBlob_Signature is a "signature" in the sh.tangled.repo.blob schema.
type RepoBlob_Signature struct {
	// email: Author email
	Email string `json:"email" cborgen:"email"`
	// name: Author name
	Name string `json:"name" cborgen:"name"`
	// when: Author timestamp
	When string `json:"when" cborgen:"when"`
}

// RepoBlob_Submodule is a "submodule" in the sh.tangled.repo.blob schema.
type RepoBlob_Submodule struct {
	// branch: Branch to track in the submodule
	Branch *string `json:"branch,omitempty" cborgen:"branch,omitempty"`
	// name: Submodule name
	Name string `json:"name" cborgen:"name"`
	// url: Submodule repository URL
	Url string `json:"url" cborgen:"url"`
}

// RepoBlob calls the XRPC method "sh.tangled.repo.blob".
//
// path: Path to the file within the repository
// raw: Return raw file content instead of JSON response
// ref: Git reference (branch, tag, or commit SHA)
// repo: Repository identifier in format 'did:plc:.../repoName'
func RepoBlob(ctx context.Context, c util.LexClient, path string, raw bool, ref string, repo string) (*RepoBlob_Output, error) {
	var out RepoBlob_Output

	params := map[string]interface{}{}
	params["path"] = path
	if raw {
		params["raw"] = raw
	}
	params["ref"] = ref
	params["repo"] = repo
	if err := c.LexDo(ctx, util.Query, "", "sh.tangled.repo.blob", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
