// 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 regs_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"
)

// LicenseType license type
//
// swagger:model LicenseType
type LicenseType struct {

	// Account ID
	AccountID string `json:"AccountID,omitempty"`

	// Agent ID
	AgentID string `json:"AgentID,omitempty"`

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

	// Cost
	Cost float64 `json:"Cost,omitempty"`

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

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

	// Domain
	DomainID string `json:"DomainID,omitempty"`

	// domains
	Domains []string `json:"Domains"`

	// Frequency
	Frequency string `json:"Frequency,omitempty"`

	// Taxnexus Record Id Only; not used in POST
	ID string `json:"ID,omitempty"`

	// jurisdictions
	Jurisdictions []*GeoLicenseTypeInstance `json:"Jurisdictions"`

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

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

	// Level
	Level string `json:"Level,omitempty"`

	// License Type Metrc Name
	MetrcName string `json:"MetrcName,omitempty"`

	// License Type Name
	Name string `json:"Name,omitempty"`

	// License Type Picklist Value
	PicklistValue string `json:"PicklistValue,omitempty"`

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

	// Restriction
	Restriction string `json:"Restriction,omitempty"`

	// Tier
	Tier string `json:"Tier,omitempty"`
}

// Validate validates this license type
func (m *LicenseType) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *LicenseType) validateJurisdictions(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

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

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