// 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 sf_gate_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 {

	// About Me
	Aboutme string `json:"aboutme,omitempty"`

	// Account ID
	Accountid string `json:"accountid,omitempty"`

	// address
	Address *Address `json:"address,omitempty"`

	// Alias
	Alias string `json:"alias,omitempty"`

	// API Key
	Apikey string `json:"apikey,omitempty"`

	// Auth0 User ID
	Auth0userid string `json:"auth0userid,omitempty"`

	// Nickname
	Communitynickname string `json:"communitynickname,omitempty"`

	// Company Name
	Companyname string `json:"companyname,omitempty"`

	// Contact
	Contactid string `json:"contactid,omitempty"`

	// Created User ID
	Createdbyid string `json:"createdbyid,omitempty"`

	// Date Created
	Createddate string `json:"createddate,omitempty"`

	// Delegated Approver
	Delegatedapproverid string `json:"delegatedapproverid,omitempty"`

	// Department
	Department string `json:"department,omitempty"`

	// Division
	Division string `json:"division,omitempty"`

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

	// Employee Number
	Employeenumber string `json:"employeenumber,omitempty"`

	// Time day ends
	Endday string `json:"endday,omitempty"`

	// Environment
	Environment string `json:"environment,omitempty"`

	// Extension
	Extension string `json:"extension,omitempty"`

	// Fabric API Key
	Fabricapikey string `json:"fabricapikey,omitempty"`

	// Fax
	Fax string `json:"fax,omitempty"`

	// The first name
	Firstname string `json:"firstname,omitempty"`

	// Allow Forecasting
	Forecastenabled bool `json:"forecastenabled,omitempty"`

	// Full Photo URL
	Fullphotourl string `json:"fullphotourl,omitempty"`

	// Taxnexus ID
	ID string `json:"id,omitempty"`

	// Active
	Isactive bool `json:"isactive,omitempty"`

	// Is the user enabled for Communities?
	Isportalenabled bool `json:"isportalenabled,omitempty"`

	// Has Profile Photo
	Isprofilephotoactive bool `json:"isprofilephotoactive,omitempty"`

	// issystemcontrolled
	Issystemcontrolled bool `json:"issystemcontrolled,omitempty"`

	// ip address of last login
	Lastip string `json:"lastip,omitempty"`

	// last login time
	Lastlogin string `json:"lastlogin,omitempty"`

	// Last Modified User ID
	Lastmodifiedbyid string `json:"lastmodifiedbyid,omitempty"`

	// Last Modified Date
	Lastmodifieddate string `json:"lastmodifieddate,omitempty"`

	// The Last Name
	Lastname string `json:"lastname,omitempty"`

	// number of times user has logged in
	Logincount int64 `json:"logincount,omitempty"`

	// Manager
	Managerid string `json:"managerid,omitempty"`

	// Mobile
	Mobilephone string `json:"mobilephone,omitempty"`

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

	// Out of office message
	Outofofficemessage string `json:"outofofficemessage,omitempty"`

	// Phone
	Phone string `json:"phone,omitempty"`

	// Portal Role Level
	Portalrole string `json:"portalrole,omitempty"`

	// Profile
	Profileid string `json:"profileid,omitempty"`

	// Admin Info Emails
	Receivesadmininfoemails bool `json:"receivesadmininfoemails,omitempty"`

	// Info Emails
	Receivesinfoemails bool `json:"receivesinfoemails,omitempty"`

	// Email Sender Address
	Senderemail string `json:"senderemail,omitempty"`

	// Email Sender Name
	Sendername string `json:"sendername,omitempty"`

	// Email Signature
	Signature string `json:"signature,omitempty"`

	// Small Photo URL
	Smallphotourl string `json:"smallphotourl,omitempty"`

	// The time day starts
	Startday string `json:"startday,omitempty"`

	// Taxnexus Account
	Taxnexusaccount string `json:"taxnexusaccount,omitempty"`

	// tenantid
	Tenantid string `json:"tenantid,omitempty"`

	// tenantusers
	Tenantusers []*TenantUser `json:"tenantusers"`

	// Time Zone
	Timezonesidkey string `json:"timezonesidkey,omitempty"`

	// Title
	Title string `json:"title,omitempty"`

	// Username
	Username string `json:"username,omitempty"`

	// Role
	Userroleid string `json:"userroleid,omitempty"`

	// userroles
	Userroles []*UserRole `json:"userroles"`

	// User Type
	Usertype string `json:"usertype,omitempty"`
}

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

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

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

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

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

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

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

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

	return nil
}

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

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

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

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

	}

	return nil
}

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

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

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

		if m.Userroles[i] != nil {
			if err := m.Userroles[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("userroles" + "." + strconv.Itoa(i))
				}
				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
}
