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

// All Code Copyright(c) 2018-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package auth0_models

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

import (
	"strconv"

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

// User user
//
// swagger:model User
type User struct {

	// app metadata
	AppMetadata *UserAppMetadata `json:"app_metadata,omitempty"`

	// created at
	CreatedAt string `json:"created_at,omitempty"`

	// email
	Email string `json:"email,omitempty"`

	// email verified
	EmailVerified bool `json:"email_verified,omitempty"`

	// family name
	FamilyName string `json:"family_name,omitempty"`

	// given name
	GivenName string `json:"given_name,omitempty"`

	// identities
	Identities []*UserIdentitiesItems0 `json:"identities"`

	// last ip
	LastIP string `json:"last_ip,omitempty"`

	// last login
	LastLogin string `json:"last_login,omitempty"`

	// last password reset
	LastPasswordReset string `json:"last_password_reset,omitempty"`

	// logins count
	LoginsCount int64 `json:"logins_count,omitempty"`

	// multifactor last modified
	MultifactorLastModified string `json:"multifactor_last_modified,omitempty"`

	// name
	Name string `json:"name,omitempty"`

	// nickname
	Nickname string `json:"nickname,omitempty"`

	// picture
	Picture string `json:"picture,omitempty"`

	// updated at
	UpdatedAt string `json:"updated_at,omitempty"`

	// user id
	UserID string `json:"user_id,omitempty"`

	// user metadata
	UserMetadata *UserUserMetadata `json:"user_metadata,omitempty"`
}

// Validate validates this user
func (m *User) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *User) validateAppMetadata(formats strfmt.Registry) error {

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

	if m.AppMetadata != nil {
		if err := m.AppMetadata.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("app_metadata")
			}
			return err
		}
	}

	return nil
}

func (m *User) validateIdentities(formats strfmt.Registry) error {

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

	for i := 0; i < len(m.Identities); i++ {
		if swag.IsZero(m.Identities[i]) { // not required
			continue
		}

		if m.Identities[i] != nil {
			if err := m.Identities[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("identities" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *User) validateUserMetadata(formats strfmt.Registry) error {

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

	if m.UserMetadata != nil {
		if err := m.UserMetadata.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("user_metadata")
			}
			return err
		}
	}

	return nil
}

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

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

// UserAppMetadata user app metadata
//
// swagger:model UserAppMetadata
type UserAppMetadata struct {

	// roles
	Roles []string `json:"roles"`

	// taxnexus account id
	TaxnexusAccountID string `json:"taxnexus_account_id,omitempty"`

	// taxnexus contact id
	TaxnexusContactID string `json:"taxnexus_contact_id,omitempty"`

	// taxnexus user id
	TaxnexusUserID string `json:"taxnexus_user_id,omitempty"`
}

// Validate validates this user app metadata
func (m *UserAppMetadata) Validate(formats strfmt.Registry) error {
	return nil
}

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

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

// UserIdentitiesItems0 user identities items0
//
// swagger:model UserIdentitiesItems0
type UserIdentitiesItems0 struct {

	// connection
	Connection string `json:"connection,omitempty"`

	// is social
	IsSocial bool `json:"isSocial,omitempty"`

	// provider
	Provider string `json:"provider,omitempty"`

	// user id
	UserID string `json:"user_id,omitempty"`
}

// Validate validates this user identities items0
func (m *UserIdentitiesItems0) Validate(formats strfmt.Registry) error {
	return nil
}

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

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

// UserUserMetadata user user metadata
//
// swagger:model UserUserMetadata
type UserUserMetadata struct {

	// taxnexus email
	TaxnexusEmail string `json:"taxnexus_email,omitempty"`

	// taxnexus firstname
	TaxnexusFirstname string `json:"taxnexus_firstname,omitempty"`

	// taxnexus fullname
	TaxnexusFullname string `json:"taxnexus_fullname,omitempty"`

	// taxnexus lastname
	TaxnexusLastname string `json:"taxnexus_lastname,omitempty"`

	// taxnexus phone
	TaxnexusPhone string `json:"taxnexus_phone,omitempty"`
}

// Validate validates this user user metadata
func (m *UserUserMetadata) Validate(formats strfmt.Registry) error {
	return nil
}

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

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