// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// AdminAccountInfo AdminAccountInfo models the admin view of an account's details.
//
// swagger:model AdminAccountInfo
type AdminAccountInfo struct {

	// Whether the account is currently approved.
	Approved bool `json:"approved,omitempty"`

	// Whether the account has confirmed their email address.
	Confirmed bool `json:"confirmed,omitempty"`

	// When the account was first discovered. (ISO 8601 Datetime)
	// Example: 2021-07-30T09:20:25+00:00
	CreatedAt string `json:"created_at,omitempty"`

	// The ID of the application that created this account.
	CreatedByApplicationID string `json:"created_by_application_id,omitempty"`

	// Whether the account is currently disabled.
	Disabled bool `json:"disabled,omitempty"`

	// The domain of the account.
	// Null for local accounts.
	// Example: example.org
	Domain string `json:"domain,omitempty"`

	// The email address associated with the account.
	// Empty string for remote accounts or accounts with
	// no known email address.
	// Example: someone@somewhere.com
	Email string `json:"email,omitempty"`

	// The ID of the account in the database.
	// Example: 01GQ4PHNT622DQ9X95XQX4KKNR
	ID string `json:"id,omitempty"`

	// The IP address last used to login to this account.
	// Null if not known.
	// Example: 192.0.2.1
	IP string `json:"ip,omitempty"`

	// All known IP addresses associated with this account.
	// NOT IMPLEMENTED (will always be empty array).
	// Example: []
	IPs []interface{} `json:"ips"`

	// The reason given when signing up.
	// Null if no reason / remote account.
	// Example: Pleaaaaaaaaaaaaaaase!!
	InviteRequest string `json:"invite_request,omitempty"`

	// The ID of the account that invited this user
	InvitedByAccountID string `json:"invited_by_account_id,omitempty"`

	// The locale of the account. (ISO 639 Part 1 two-letter language code)
	// Example: en
	Locale string `json:"locale,omitempty"`

	// Whether the account is currently silenced
	Silenced bool `json:"silenced,omitempty"`

	// Whether the account is currently suspended.
	Suspended bool `json:"suspended,omitempty"`

	// The username of the account.
	// Example: dril
	Username string `json:"username,omitempty"`

	// account
	Account *Account `json:"account,omitempty"`

	// role
	Role *AccountRole `json:"role,omitempty"`
}

// Validate validates this admin account info
func (m *AdminAccountInfo) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateAccount(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateRole(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *AdminAccountInfo) validateAccount(formats strfmt.Registry) error {
	if swag.IsZero(m.Account) { // not required
		return nil
	}

	if m.Account != nil {
		if err := m.Account.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("account")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("account")
			}
			return err
		}
	}

	return nil
}

func (m *AdminAccountInfo) validateRole(formats strfmt.Registry) error {
	if swag.IsZero(m.Role) { // not required
		return nil
	}

	if m.Role != nil {
		if err := m.Role.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("role")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("role")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this admin account info based on the context it is used
func (m *AdminAccountInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateAccount(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateRole(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *AdminAccountInfo) contextValidateAccount(ctx context.Context, formats strfmt.Registry) error {

	if m.Account != nil {

		if swag.IsZero(m.Account) { // not required
			return nil
		}

		if err := m.Account.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("account")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("account")
			}
			return err
		}
	}

	return nil
}

func (m *AdminAccountInfo) contextValidateRole(ctx context.Context, formats strfmt.Registry) error {

	if m.Role != nil {

		if swag.IsZero(m.Role) { // not required
			return nil
		}

		if err := m.Role.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("role")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("role")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (m *AdminAccountInfo) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *AdminAccountInfo) UnmarshalBinary(b []byte) error {
	var res AdminAccountInfo
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
