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

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

import (
	"context"
	"strconv"

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

// 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"`

	// 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 Products
	CompanyProducts []*CompanyProduct `json:"CompanyProducts"`

	// 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"`

	// Similar Companies
	IndustryCompanies []*IndustryCompany `json:"IndustryCompanies"`

	// 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"`

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

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

	// 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.validateCompanyProducts(formats); err != nil {
		res = append(res, err)
	}

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

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

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

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

func (m *Company) validateCompanyProducts(formats strfmt.Registry) error {
	if swag.IsZero(m.CompanyProducts) { // not required
		return nil
	}

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

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

	}

	return nil
}

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

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

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

	}

	return nil
}

func (m *Company) validateIndustryCompanies(formats strfmt.Registry) error {
	if swag.IsZero(m.IndustryCompanies) { // not required
		return nil
	}

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

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

	}

	return nil
}

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

	if m.ListingAddress != nil {
		if err := m.ListingAddress.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ListingAddress")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ListingAddress")
			}
			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.contextValidateCompanyProducts(ctx, formats); err != nil {
		res = append(res, err)
	}

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

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

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

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

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

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

		if m.CompanyProducts[i] != nil {
			if err := m.CompanyProducts[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("CompanyProducts" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("CompanyProducts" + "." + 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 err := m.FinancialStatements[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("FinancialStatements" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("FinancialStatements" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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

		if m.IndustryCompanies[i] != nil {
			if err := m.IndustryCompanies[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("IndustryCompanies" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("IndustryCompanies" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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

	return nil
}

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

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