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

package org_tangled

// schema: org.tangled.track.defs

import (
	"encoding/json"
	"fmt"

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

const ()

// TrackDefs_TicketViewDetailed is a "ticketViewDetailed" in the org.tangled.track.defs schema.
type TrackDefs_TicketViewDetailed struct {
	Assignees []string `json:"assignees,omitempty" cborgen:"assignees,omitempty"`
	// author: The account that opened the ticket, the editor of its first version. Not the account that last edited or closed it.
	Author        *ActorDefs_ProfileViewBasic                        `json:"author" cborgen:"author"`
	Body          *TrackDefs_TicketViewDetailed_Body                 `json:"body,omitempty" cborgen:"body,omitempty"`
	Cid           string                                             `json:"cid" cborgen:"cid"`
	CreatedAt     string                                             `json:"createdAt" cborgen:"createdAt"`
	Repo          *RepoDefs_RepoViewBasic                            `json:"repo" cborgen:"repo"`
	State         *string                                            `json:"state" cborgen:"state"`
	TangledLabels []*TrackDefs_TicketViewDetailed_TangledLabels_Elem `json:"tangledLabels,omitempty" cborgen:"tangledLabels,omitempty"`
	// targetBranch: Present when the ticket is a pull request.
	TargetBranch *string                             `json:"targetBranch,omitempty" cborgen:"targetBranch,omitempty"`
	Title        *TrackDefs_TicketViewDetailed_Title `json:"title" cborgen:"title"`
	Uri          string                              `json:"uri" cborgen:"uri"`
}

type TrackDefs_TicketViewDetailed_Body struct {
	MarkupMarkdown *MarkupMarkdown
}

func (t *TrackDefs_TicketViewDetailed_Body) MarshalJSON() ([]byte, error) {
	if t.MarkupMarkdown != nil {
		t.MarkupMarkdown.LexiconTypeID = "org.tangled.markup.markdown"
		return json.Marshal(t.MarkupMarkdown)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *TrackDefs_TicketViewDetailed_Body) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "org.tangled.markup.markdown":
		t.MarkupMarkdown = new(MarkupMarkdown)
		return json.Unmarshal(b, t.MarkupMarkdown)

	default:
		return nil
	}
}

type TrackDefs_TicketViewDetailed_TangledLabels_Elem struct {
	LabelDefs_LabelToken *LabelDefs_LabelToken
}

func (t *TrackDefs_TicketViewDetailed_TangledLabels_Elem) MarshalJSON() ([]byte, error) {
	if t.LabelDefs_LabelToken != nil {
		t.LabelDefs_LabelToken.LexiconTypeID = "org.tangled.label.defs#labelToken"
		return json.Marshal(t.LabelDefs_LabelToken)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *TrackDefs_TicketViewDetailed_TangledLabels_Elem) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "org.tangled.label.defs#labelToken":
		t.LabelDefs_LabelToken = new(LabelDefs_LabelToken)
		return json.Unmarshal(b, t.LabelDefs_LabelToken)

	default:
		return nil
	}
}

type TrackDefs_TicketViewDetailed_Title struct {
	MarkupMarkdown_Inline *MarkupMarkdown_Inline
}

func (t *TrackDefs_TicketViewDetailed_Title) MarshalJSON() ([]byte, error) {
	if t.MarkupMarkdown_Inline != nil {
		t.MarkupMarkdown_Inline.LexiconTypeID = "org.tangled.markup.markdown#inline"
		return json.Marshal(t.MarkupMarkdown_Inline)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *TrackDefs_TicketViewDetailed_Title) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "org.tangled.markup.markdown#inline":
		t.MarkupMarkdown_Inline = new(MarkupMarkdown_Inline)
		return json.Unmarshal(b, t.MarkupMarkdown_Inline)

	default:
		return nil
	}
}
