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

package ozone

// schema: tools.ozone.moderation.getRepos

import (
	"context"
	"encoding/json"
	"fmt"

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

// ModerationGetRepos_Output is the output of a tools.ozone.moderation.getRepos call.
type ModerationGetRepos_Output struct {
	Repos []*ModerationGetRepos_Output_Repos_Elem `json:"repos" cborgen:"repos"`
}

type ModerationGetRepos_Output_Repos_Elem struct {
	ModerationDefs_RepoViewDetail   *ModerationDefs_RepoViewDetail
	ModerationDefs_RepoViewNotFound *ModerationDefs_RepoViewNotFound
}

func (t *ModerationGetRepos_Output_Repos_Elem) MarshalJSON() ([]byte, error) {
	if t.ModerationDefs_RepoViewDetail != nil {
		t.ModerationDefs_RepoViewDetail.LexiconTypeID = "tools.ozone.moderation.defs#repoViewDetail"
		return json.Marshal(t.ModerationDefs_RepoViewDetail)
	}
	if t.ModerationDefs_RepoViewNotFound != nil {
		t.ModerationDefs_RepoViewNotFound.LexiconTypeID = "tools.ozone.moderation.defs#repoViewNotFound"
		return json.Marshal(t.ModerationDefs_RepoViewNotFound)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *ModerationGetRepos_Output_Repos_Elem) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "tools.ozone.moderation.defs#repoViewDetail":
		t.ModerationDefs_RepoViewDetail = new(ModerationDefs_RepoViewDetail)
		return json.Unmarshal(b, t.ModerationDefs_RepoViewDetail)
	case "tools.ozone.moderation.defs#repoViewNotFound":
		t.ModerationDefs_RepoViewNotFound = new(ModerationDefs_RepoViewNotFound)
		return json.Unmarshal(b, t.ModerationDefs_RepoViewNotFound)

	default:
		return nil
	}
}

// ModerationGetRepos calls the XRPC method "tools.ozone.moderation.getRepos".
func ModerationGetRepos(ctx context.Context, c *xrpc.Client, dids []string) (*ModerationGetRepos_Output, error) {
	var out ModerationGetRepos_Output

	params := map[string]interface{}{
		"dids": dids,
	}
	if err := c.Do(ctx, xrpc.Query, "", "tools.ozone.moderation.getRepos", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
