// 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 crm_models

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

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

// AccountBasic account basic
//
// swagger:model AccountBasic
type AccountBasic struct {

	// Taxnexus Account Number of the OEM/Reseller
	AccountNumber string `json:"AccountNumber,omitempty"`

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

	// Contact ID
	BillingContactID string `json:"BillingContactID,omitempty"`

	// Taxnexus OEM/Reseller Record Id
	CompanyID string `json:"CompanyID,omitempty"`

	// The id of the Coordinate of the business establishment
	CoordinateID string `json:"CoordinateID,omitempty"`

	// Taxpayer Customer Id designated by OEM/Reseller
	CustomerID string `json:"CustomerID,omitempty"`

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

	// Default Backend ID
	DefaultBackendID string `json:"DefaultBackendID,omitempty"`

	// Default Delivery Address Contact ID
	DefaultDeliveryContactID string `json:"DefaultDeliveryContactID,omitempty"`

	// Contact ID
	DefaultEndUserID string `json:"DefaultEndUserID,omitempty"`

	// Taxpayer Public Email Address
	Email string `json:"Email,omitempty"`

	// Taxpayer Fax Number
	Fax string `json:"Fax,omitempty"`

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

	// Taxpayer Account Name (ignored for Tax Processing)
	Name string `json:"Name,omitempty"`

	// UUID Reference the master record that owns this item
	ParentFK string `json:"ParentFK,omitempty"`

	// Taxpayer Public Phone Number
	Phone string `json:"Phone,omitempty"`

	// Contact ID
	PreparerID string `json:"PreparerID,omitempty"`

	// Source System identifier for this record, if any
	Ref string `json:"Ref,omitempty"`

	// Shipping Address
	ShippingAddress *Address `json:"ShippingAddress,omitempty"`

	// Contact ID
	ShippingConactID string `json:"ShippingConactID,omitempty"`

	// Taxpayer Location Designation
	Site string `json:"Site,omitempty"`

	// Tenant Identifier
	TenantID string `json:"TenantID,omitempty"`

	// Account Type
	Type string `json:"Type,omitempty"`

	// Taxpayer Website
	Website string `json:"Website,omitempty"`
}

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

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

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

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

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

func (m *AccountBasic) validateBillingAddress(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *AccountBasic) validateDefaultAddress(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *AccountBasic) validateShippingAddress(formats strfmt.Registry) error {

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

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

	return nil
}

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

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