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

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

package plex_models

import (
	"context"
	stderrors "errors"
	"strconv"

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

// Company company
//
// swagger:model Company
type Company struct {

	// Account Id
	AccountID *string `json:"AccountID,omitempty"`

	// Company Number
	AccountNumber *string `json:"AccountNumber,omitempty"`

	// The marketing origin of this Company
	AccountSource *string `json:"AccountSource,omitempty"`

	// active
	Active *bool `json:"Active,omitempty"`

	// Annual Revenue Estimate
	AnnualRevenue *float64 `json:"AnnualRevenue,omitempty"`

	// Salesforce AppExchange URL
	AppExchange *string `json:"AppExchange,omitempty"`

	// Company Categories
	Categories []*Category `json:"Categories"`

	// cloud revenue total
	CloudRevenueTotal *float64 `json:"CloudRevenueTotal,omitempty"`

	// The type of cloud company
	CloudType *string `json:"CloudType,omitempty"`

	// The year company started cloud revenue
	CloudYear *string `json:"CloudYear,omitempty"`

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

	// Description of the Company
	Description *string `json:"Description,omitempty"`

	// Earnings Call Date
	EarningsCall *string `json:"EarningsCall,omitempty"`

	// Main Company Email
	Email *string `json:"Email,omitempty"`

	// The amount of equity EquityFunding
	EquityFunding *float64 `json:"EquityFunding,omitempty"`

	// Company Facebook URL
	Facebook *string `json:"Facebook,omitempty"`

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

	// Financial Statements
	FinancialStatements []*FinancialStatement `json:"FinancialStatements"`

	// Date company founded
	FoundedDate *string `json:"FoundedDate,omitempty"`

	// Full Description of the Company
	FullDescription *string `json:"FullDescription,omitempty"`

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

	// IPO Date
	IPODate *string `json:"IPODate,omitempty"`

	// image alt text
	ImageAltText *string `json:"ImageAltText,omitempty"`

	// image URL
	ImageURL *string `json:"ImageURL,omitempty"`

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

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

	// Company LinkedIn URL
	LinkedIn *string `json:"LinkedIn,omitempty"`

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

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

	// Company Logo URL
	Logo *string `json:"Logo,omitempty"`

	// Market Capitalization
	MarketCapitalization *float64 `json:"MarketCapitalization,omitempty"`

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

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

	// Employee Count Estimate
	NumberOfEmployees *int64 `json:"NumberOfEmployees,omitempty"`

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

	// Parent Company
	ParentID *string `json:"ParentID,omitempty"`

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

	// Company Products
	Products []*Product `json:"Products"`

	// Publish this record?
	Publish *bool `json:"Publish,omitempty"`

	// A Salesforce-First company?
	SalesforceFirst *bool `json:"SalesforceFirst,omitempty"`

	// Company Services
	Services []*Service `json:"Services"`

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

	// Company tagline
	TagLine *string `json:"TagLine,omitempty"`

	// Ticker Symbol
	TickerSymbol *string `json:"TickerSymbol,omitempty"`

	// Twitter URL
	Twitter *string `json:"Twitter,omitempty"`

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

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

	// Year Started
	YearStarted *string `json:"YearStarted,omitempty"`
}

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

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

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

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

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

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

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

func (m *Company) validateCategories(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Categories) { // not required
		return nil
	}

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

		if m.Categories[i] != nil {
			if err := m.Categories[i].Validate(formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("Categories" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("Categories" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

func (m *Company) validateFinancialStatements(formats strfmt.Registry) error {
	if typeutils.IsZero(m.FinancialStatements) { // not required
		return nil
	}

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

		if m.FinancialStatements[i] != nil {
			if err := m.FinancialStatements[i].Validate(formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("FinancialStatements" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("FinancialStatements" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

func (m *Company) validateListingAddress(formats strfmt.Registry) error {
	if typeutils.IsZero(m.ListingAddress) { // not required
		return nil
	}

	if m.ListingAddress != nil {
		if err := m.ListingAddress.Validate(formats); err != nil {
			ve := new(errors.Validation)
			if stderrors.As(err, &ve) {
				return ve.ValidateName("ListingAddress")
			}
			ce := new(errors.CompositeError)
			if stderrors.As(err, &ce) {
				return ce.ValidateName("ListingAddress")
			}

			return err
		}
	}

	return nil
}

func (m *Company) validateProducts(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Products) { // not required
		return nil
	}

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

		if m.Products[i] != nil {
			if err := m.Products[i].Validate(formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("Products" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("Products" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

func (m *Company) validateServices(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Services) { // not required
		return nil
	}

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

		if m.Services[i] != nil {
			if err := m.Services[i].Validate(formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("Services" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("Services" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

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

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

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

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

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

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

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

func (m *Company) contextValidateCategories(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.Categories); i++ {

		if m.Categories[i] != nil {

			if typeutils.IsZero(m.Categories[i]) { // not required
				return nil
			}

			if err := m.Categories[i].ContextValidate(ctx, formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("Categories" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("Categories" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

func (m *Company) contextValidateFinancialStatements(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.FinancialStatements); i++ {

		if m.FinancialStatements[i] != nil {

			if typeutils.IsZero(m.FinancialStatements[i]) { // not required
				return nil
			}

			if err := m.FinancialStatements[i].ContextValidate(ctx, formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("FinancialStatements" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("FinancialStatements" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

func (m *Company) contextValidateListingAddress(ctx context.Context, formats strfmt.Registry) error {

	if m.ListingAddress != nil {

		if typeutils.IsZero(m.ListingAddress) { // not required
			return nil
		}

		if err := m.ListingAddress.ContextValidate(ctx, formats); err != nil {
			ve := new(errors.Validation)
			if stderrors.As(err, &ve) {
				return ve.ValidateName("ListingAddress")
			}
			ce := new(errors.CompositeError)
			if stderrors.As(err, &ce) {
				return ce.ValidateName("ListingAddress")
			}

			return err
		}
	}

	return nil
}

func (m *Company) contextValidateProducts(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.Products); i++ {

		if m.Products[i] != nil {

			if typeutils.IsZero(m.Products[i]) { // not required
				return nil
			}

			if err := m.Products[i].ContextValidate(ctx, formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("Products" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("Products" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

func (m *Company) contextValidateServices(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.Services); i++ {

		if m.Services[i] != nil {

			if typeutils.IsZero(m.Services[i]) { // not required
				return nil
			}

			if err := m.Services[i].ContextValidate(ctx, formats); err != nil {
				ve := new(errors.Validation)
				if stderrors.As(err, &ve) {
					return ve.ValidateName("Services" + "." + strconv.Itoa(i))
				}
				ce := new(errors.CompositeError)
				if stderrors.As(err, &ce) {
					return ce.ValidateName("Services" + "." + strconv.Itoa(i))
				}

				return err
			}
		}

	}

	return nil
}

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

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