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

// (c) 2012-2023 by Vernon Keenan
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package sfgate_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"
)

// Contact contact
//
// swagger:model Contact
type Contact struct {

	// The primary account ID of this contact
	AccountID *string `json:"AccountID,omitempty"`

	// Assistant Name
	AssistantName *string `json:"AssistantName,omitempty"`

	// Asst. Phone
	AssistantPhone *string `json:"AssistantPhone,omitempty"`

	// Birthdate
	BirthDate *string `json:"BirthDate,omitempty"`

	// Created By User ID
	CreatedByID *string `json:"CreatedByID,omitempty"`

	// Created Date
	CreatedDate *string `json:"CreatedDate,omitempty"`

	// Crunchbase URL
	CrunchbaseURL *string `json:"CrunchbaseURL,omitempty"`

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

	// Description
	Description *string `json:"Description,omitempty"`

	// Do Not Call?
	DoNotCall *bool `json:"DoNotCall,omitempty"`

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

	// Email Bounce Date
	EmailBounceDate *string `json:"EmailBounceDate,omitempty"`

	// Email Bounce Reason
	EmailBounceReason *string `json:"EmailBounceReason,omitempty"`

	// Fax Number
	Facebook *string `json:"Facebook,omitempty"`

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

	// First Name
	FirstName *string `json:"FirstName,omitempty"`

	// Email Opt Out
	HasOptedOutOfEmail *bool `json:"HasOptedOutOfEmail,omitempty"`

	// Fax Opt Out
	HasOptedOutOfFax *bool `json:"HasOptedOutOfFax,omitempty"`

	// Home Phone
	HomePhone *string `json:"HomePhone,omitempty"`

	// Record Id
	ID string `json:"ID,omitempty"`

	// Does this contact have bounced emails?
	IsEmailBounced *bool `json:"IsEmailBounced,omitempty"`

	// Last Modified By User ID
	LastModifiedByID *string `json:"LastModifiedByID,omitempty"`

	// Last Modified Date
	LastModifiedDate *string `json:"LastModifiedDate,omitempty"`

	// Last Name
	LastName *string `json:"LastName,omitempty"`

	// Lead Source
	LeadSource *string `json:"LeadSource,omitempty"`

	// LinkedIn Page
	LinkedIn *string `json:"LinkedIn,omitempty"`

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

	// Mobile Phone
	MobilePhone *string `json:"MobilePhone,omitempty"`

	// Full Name
	Name *string `json:"Name,omitempty"`

	// Number of Investments
	NumberInvestments *float64 `json:"NumberInvestments,omitempty"`

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

	// Other Phone
	OtherPhone *string `json:"OtherPhone,omitempty"`

	// The User ID of the user who owns this Contact
	OwnerID *string `json:"OwnerID,omitempty"`

	// Personal Email Address for this Contact
	PersonalEmail *string `json:"PersonalEmail,omitempty"`

	// Phone Number
	Phone *string `json:"Phone,omitempty"`

	// URL of a photograph of this User
	PhotoURL *string `json:"PhotoURL,omitempty"`

	// Reports To User ID
	ReportsToID *string `json:"ReportsToID,omitempty"`

	// Salutation
	Salutation *string `json:"Salutation,omitempty"`

	// Slug
	Slug *string `json:"Slug,omitempty"`

	// tenant identifier
	TenantID *string `json:"TenantID,omitempty"`

	// Contact Title
	Title *string `json:"Title,omitempty"`

	// twitter
	Twitter *string `json:"Twitter,omitempty"`
}

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

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

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

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

func (m *Contact) validateMailingAddress(formats strfmt.Registry) error {
	if swag.IsZero(m.MailingAddress) { // not required
		return nil
	}

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

	return nil
}

func (m *Contact) validateOtherAddress(formats strfmt.Registry) error {
	if swag.IsZero(m.OtherAddress) { // not required
		return nil
	}

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

	return nil
}

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

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

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

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

func (m *Contact) contextValidateMailingAddress(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *Contact) contextValidateOtherAddress(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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