// Code generated by Fern. DO NOT EDIT.

package management

import (
	json "encoding/json"
	fmt "fmt"
	internal "github.com/auth0/go-auth0/v2/management/internal"
	big "math/big"
)

var (
	changePasswordTicketResponseContentFieldTicket = big.NewInt(1 << 0)
)

type ChangePasswordTicketResponseContent struct {
	// URL representing the ticket.
	Ticket string `json:"ticket" url:"ticket"`

	// Private bitmask of fields set to an explicit value and therefore not to be omitted
	explicitFields *big.Int `json:"-" url:"-"`

	ExtraProperties map[string]interface{} `json:"-" url:"-"`

	rawJSON json.RawMessage
}

func (c *ChangePasswordTicketResponseContent) GetTicket() string {
	if c == nil {
		return ""
	}
	return c.Ticket
}

func (c *ChangePasswordTicketResponseContent) GetExtraProperties() map[string]interface{} {
	return c.ExtraProperties
}

func (c *ChangePasswordTicketResponseContent) require(field *big.Int) {
	if c.explicitFields == nil {
		c.explicitFields = big.NewInt(0)
	}
	c.explicitFields.Or(c.explicitFields, field)
}

// SetTicket sets the Ticket field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (c *ChangePasswordTicketResponseContent) SetTicket(ticket string) {
	c.Ticket = ticket
	c.require(changePasswordTicketResponseContentFieldTicket)
}

func (c *ChangePasswordTicketResponseContent) UnmarshalJSON(data []byte) error {
	type embed ChangePasswordTicketResponseContent
	var unmarshaler = struct {
		embed
	}{
		embed: embed(*c),
	}
	if err := json.Unmarshal(data, &unmarshaler); err != nil {
		return err
	}
	*c = ChangePasswordTicketResponseContent(unmarshaler.embed)
	extraProperties, err := internal.ExtractExtraProperties(data, *c)
	if err != nil {
		return err
	}
	c.ExtraProperties = extraProperties
	c.rawJSON = json.RawMessage(data)
	return nil
}

func (c *ChangePasswordTicketResponseContent) MarshalJSON() ([]byte, error) {
	type embed ChangePasswordTicketResponseContent
	var marshaler = struct {
		embed
	}{
		embed: embed(*c),
	}
	explicitMarshaler := internal.HandleExplicitFields(marshaler, c.explicitFields)
	return internal.MarshalJSONWithExtraProperties(explicitMarshaler, c.ExtraProperties)
}

func (c *ChangePasswordTicketResponseContent) String() string {
	if len(c.rawJSON) > 0 {
		if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
			return value
		}
	}
	if value, err := internal.StringifyJSON(c); err == nil {
		return value
	}
	return fmt.Sprintf("%#v", c)
}

var (
	verifyEmailTicketResponseContentFieldTicket = big.NewInt(1 << 0)
)

type VerifyEmailTicketResponseContent struct {
	// URL representing the ticket.
	Ticket string `json:"ticket" url:"ticket"`

	// Private bitmask of fields set to an explicit value and therefore not to be omitted
	explicitFields *big.Int `json:"-" url:"-"`

	ExtraProperties map[string]interface{} `json:"-" url:"-"`

	rawJSON json.RawMessage
}

func (v *VerifyEmailTicketResponseContent) GetTicket() string {
	if v == nil {
		return ""
	}
	return v.Ticket
}

func (v *VerifyEmailTicketResponseContent) GetExtraProperties() map[string]interface{} {
	return v.ExtraProperties
}

func (v *VerifyEmailTicketResponseContent) require(field *big.Int) {
	if v.explicitFields == nil {
		v.explicitFields = big.NewInt(0)
	}
	v.explicitFields.Or(v.explicitFields, field)
}

// SetTicket sets the Ticket field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (v *VerifyEmailTicketResponseContent) SetTicket(ticket string) {
	v.Ticket = ticket
	v.require(verifyEmailTicketResponseContentFieldTicket)
}

func (v *VerifyEmailTicketResponseContent) UnmarshalJSON(data []byte) error {
	type embed VerifyEmailTicketResponseContent
	var unmarshaler = struct {
		embed
	}{
		embed: embed(*v),
	}
	if err := json.Unmarshal(data, &unmarshaler); err != nil {
		return err
	}
	*v = VerifyEmailTicketResponseContent(unmarshaler.embed)
	extraProperties, err := internal.ExtractExtraProperties(data, *v)
	if err != nil {
		return err
	}
	v.ExtraProperties = extraProperties
	v.rawJSON = json.RawMessage(data)
	return nil
}

func (v *VerifyEmailTicketResponseContent) MarshalJSON() ([]byte, error) {
	type embed VerifyEmailTicketResponseContent
	var marshaler = struct {
		embed
	}{
		embed: embed(*v),
	}
	explicitMarshaler := internal.HandleExplicitFields(marshaler, v.explicitFields)
	return internal.MarshalJSONWithExtraProperties(explicitMarshaler, v.ExtraProperties)
}

func (v *VerifyEmailTicketResponseContent) String() string {
	if len(v.rawJSON) > 0 {
		if value, err := internal.StringifyJSON(v.rawJSON); err == nil {
			return value
		}
	}
	if value, err := internal.StringifyJSON(v); err == nil {
		return value
	}
	return fmt.Sprintf("%#v", v)
}
