// 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 (
	getSupplementalSignalsResponseContentFieldAkamaiEnabled = big.NewInt(1 << 0)
)

type GetSupplementalSignalsResponseContent struct {
	// Indicates if incoming Akamai Headers should be processed
	AkamaiEnabled *bool `json:"akamai_enabled,omitempty" url:"akamai_enabled,omitempty"`

	// 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 (g *GetSupplementalSignalsResponseContent) GetAkamaiEnabled() bool {
	if g == nil || g.AkamaiEnabled == nil {
		return false
	}
	return *g.AkamaiEnabled
}

func (g *GetSupplementalSignalsResponseContent) GetExtraProperties() map[string]interface{} {
	return g.ExtraProperties
}

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

// SetAkamaiEnabled sets the AkamaiEnabled field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (g *GetSupplementalSignalsResponseContent) SetAkamaiEnabled(akamaiEnabled *bool) {
	g.AkamaiEnabled = akamaiEnabled
	g.require(getSupplementalSignalsResponseContentFieldAkamaiEnabled)
}

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

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

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

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

type PatchSupplementalSignalsResponseContent struct {
	// Indicates if incoming Akamai Headers should be processed
	AkamaiEnabled *bool `json:"akamai_enabled,omitempty" url:"akamai_enabled,omitempty"`

	// 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 (p *PatchSupplementalSignalsResponseContent) GetAkamaiEnabled() bool {
	if p == nil || p.AkamaiEnabled == nil {
		return false
	}
	return *p.AkamaiEnabled
}

func (p *PatchSupplementalSignalsResponseContent) GetExtraProperties() map[string]interface{} {
	return p.ExtraProperties
}

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

// SetAkamaiEnabled sets the AkamaiEnabled field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PatchSupplementalSignalsResponseContent) SetAkamaiEnabled(akamaiEnabled *bool) {
	p.AkamaiEnabled = akamaiEnabled
	p.require(patchSupplementalSignalsResponseContentFieldAkamaiEnabled)
}

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

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

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