// 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 (
	dailyStatsFieldDate            = big.NewInt(1 << 0)
	dailyStatsFieldLogins          = big.NewInt(1 << 1)
	dailyStatsFieldSignups         = big.NewInt(1 << 2)
	dailyStatsFieldLeakedPasswords = big.NewInt(1 << 3)
	dailyStatsFieldUpdatedAt       = big.NewInt(1 << 4)
	dailyStatsFieldCreatedAt       = big.NewInt(1 << 5)
)

type DailyStats struct {
	// Date these events occurred in ISO 8601 format.
	Date *string `json:"date,omitempty" url:"date,omitempty"`
	// Number of logins on this date.
	Logins *int `json:"logins,omitempty" url:"logins,omitempty"`
	// Number of signups on this date.
	Signups *int `json:"signups,omitempty" url:"signups,omitempty"`
	// Number of breached-password detections on this date (subscription required).
	LeakedPasswords *int `json:"leaked_passwords,omitempty" url:"leaked_passwords,omitempty"`
	// Date and time this stats entry was last updated in ISO 8601 format.
	UpdatedAt *string `json:"updated_at,omitempty" url:"updated_at,omitempty"`
	// Approximate date and time the first event occurred in ISO 8601 format.
	CreatedAt *string `json:"created_at,omitempty" url:"created_at,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 (d *DailyStats) GetDate() string {
	if d == nil || d.Date == nil {
		return ""
	}
	return *d.Date
}

func (d *DailyStats) GetLogins() int {
	if d == nil || d.Logins == nil {
		return 0
	}
	return *d.Logins
}

func (d *DailyStats) GetSignups() int {
	if d == nil || d.Signups == nil {
		return 0
	}
	return *d.Signups
}

func (d *DailyStats) GetLeakedPasswords() int {
	if d == nil || d.LeakedPasswords == nil {
		return 0
	}
	return *d.LeakedPasswords
}

func (d *DailyStats) GetUpdatedAt() string {
	if d == nil || d.UpdatedAt == nil {
		return ""
	}
	return *d.UpdatedAt
}

func (d *DailyStats) GetCreatedAt() string {
	if d == nil || d.CreatedAt == nil {
		return ""
	}
	return *d.CreatedAt
}

func (d *DailyStats) GetExtraProperties() map[string]interface{} {
	return d.ExtraProperties
}

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

// SetDate sets the Date field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (d *DailyStats) SetDate(date *string) {
	d.Date = date
	d.require(dailyStatsFieldDate)
}

// SetLogins sets the Logins field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (d *DailyStats) SetLogins(logins *int) {
	d.Logins = logins
	d.require(dailyStatsFieldLogins)
}

// SetSignups sets the Signups field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (d *DailyStats) SetSignups(signups *int) {
	d.Signups = signups
	d.require(dailyStatsFieldSignups)
}

// SetLeakedPasswords sets the LeakedPasswords field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (d *DailyStats) SetLeakedPasswords(leakedPasswords *int) {
	d.LeakedPasswords = leakedPasswords
	d.require(dailyStatsFieldLeakedPasswords)
}

// SetUpdatedAt sets the UpdatedAt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (d *DailyStats) SetUpdatedAt(updatedAt *string) {
	d.UpdatedAt = updatedAt
	d.require(dailyStatsFieldUpdatedAt)
}

// SetCreatedAt sets the CreatedAt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (d *DailyStats) SetCreatedAt(createdAt *string) {
	d.CreatedAt = createdAt
	d.require(dailyStatsFieldCreatedAt)
}

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

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

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

// Number of active users in the last 30 days.
type GetActiveUsersCountStatsResponseContent = float64
