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

package atproto

// schema: com.atproto.admin.updateSubjectStatus

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

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

// AdminUpdateSubjectStatus_Input is the input argument to a com.atproto.admin.updateSubjectStatus call.
type AdminUpdateSubjectStatus_Input struct {
	Deactivated *AdminDefs_StatusAttr                   `json:"deactivated,omitempty" cborgen:"deactivated,omitempty"`
	Subject     *AdminUpdateSubjectStatus_Input_Subject `json:"subject" cborgen:"subject"`
	Takedown    *AdminDefs_StatusAttr                   `json:"takedown,omitempty" cborgen:"takedown,omitempty"`
}

type AdminUpdateSubjectStatus_Input_Subject struct {
	AdminDefs_RepoRef     *AdminDefs_RepoRef
	RepoStrongRef         *RepoStrongRef
	AdminDefs_RepoBlobRef *AdminDefs_RepoBlobRef
}

func (t *AdminUpdateSubjectStatus_Input_Subject) MarshalJSON() ([]byte, error) {
	if t.AdminDefs_RepoRef != nil {
		t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
		return json.Marshal(t.AdminDefs_RepoRef)
	}
	if t.RepoStrongRef != nil {
		t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
		return json.Marshal(t.RepoStrongRef)
	}
	if t.AdminDefs_RepoBlobRef != nil {
		t.AdminDefs_RepoBlobRef.LexiconTypeID = "com.atproto.admin.defs#repoBlobRef"
		return json.Marshal(t.AdminDefs_RepoBlobRef)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *AdminUpdateSubjectStatus_Input_Subject) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "com.atproto.admin.defs#repoRef":
		t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
		return json.Unmarshal(b, t.AdminDefs_RepoRef)
	case "com.atproto.repo.strongRef":
		t.RepoStrongRef = new(RepoStrongRef)
		return json.Unmarshal(b, t.RepoStrongRef)
	case "com.atproto.admin.defs#repoBlobRef":
		t.AdminDefs_RepoBlobRef = new(AdminDefs_RepoBlobRef)
		return json.Unmarshal(b, t.AdminDefs_RepoBlobRef)

	default:
		return nil
	}
}

// AdminUpdateSubjectStatus_Output is the output of a com.atproto.admin.updateSubjectStatus call.
type AdminUpdateSubjectStatus_Output struct {
	Subject  *AdminUpdateSubjectStatus_Output_Subject `json:"subject" cborgen:"subject"`
	Takedown *AdminDefs_StatusAttr                    `json:"takedown,omitempty" cborgen:"takedown,omitempty"`
}

type AdminUpdateSubjectStatus_Output_Subject struct {
	AdminDefs_RepoRef     *AdminDefs_RepoRef
	RepoStrongRef         *RepoStrongRef
	AdminDefs_RepoBlobRef *AdminDefs_RepoBlobRef
}

func (t *AdminUpdateSubjectStatus_Output_Subject) MarshalJSON() ([]byte, error) {
	if t.AdminDefs_RepoRef != nil {
		t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
		return json.Marshal(t.AdminDefs_RepoRef)
	}
	if t.RepoStrongRef != nil {
		t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
		return json.Marshal(t.RepoStrongRef)
	}
	if t.AdminDefs_RepoBlobRef != nil {
		t.AdminDefs_RepoBlobRef.LexiconTypeID = "com.atproto.admin.defs#repoBlobRef"
		return json.Marshal(t.AdminDefs_RepoBlobRef)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *AdminUpdateSubjectStatus_Output_Subject) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "com.atproto.admin.defs#repoRef":
		t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
		return json.Unmarshal(b, t.AdminDefs_RepoRef)
	case "com.atproto.repo.strongRef":
		t.RepoStrongRef = new(RepoStrongRef)
		return json.Unmarshal(b, t.RepoStrongRef)
	case "com.atproto.admin.defs#repoBlobRef":
		t.AdminDefs_RepoBlobRef = new(AdminDefs_RepoBlobRef)
		return json.Unmarshal(b, t.AdminDefs_RepoBlobRef)

	default:
		return nil
	}
}

// AdminUpdateSubjectStatus calls the XRPC method "com.atproto.admin.updateSubjectStatus".
func AdminUpdateSubjectStatus(ctx context.Context, c util.LexClient, input *AdminUpdateSubjectStatus_Input) (*AdminUpdateSubjectStatus_Output, error) {
	var out AdminUpdateSubjectStatus_Output
	if err := c.LexDo(ctx, util.Procedure, "application/json", "com.atproto.admin.updateSubjectStatus", nil, input, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
