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

// FilingType An array of FilingType Objects
//
// swagger:model FilingType
type FilingType struct {

	// Tax Authority
	AccountID string `json:"AccountID,omitempty"`

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

	// Created By
	CreatedByID string `json:"CreatedById,omitempty"`

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

	// due dates
	DueDates []*FilingScheduleItem `json:"DueDates"`

	// Filing City
	FilingCity string `json:"FilingCity,omitempty"`

	// Filing Country
	FilingCountry string `json:"FilingCountry,omitempty"`

	// Filing Postal Code
	FilingPostalCode string `json:"FilingPostalCode,omitempty"`

	// Filing State
	FilingState string `json:"FilingState,omitempty"`

	// Filing Street
	FilingStreet string `json:"FilingStreet,omitempty"`

	// Form Name
	FormName string `json:"FormName,omitempty"`

	// Form Version
	FormVersion string `json:"FormVersion,omitempty"`

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

	// Filing Full Name
	FullName string `json:"FullName,omitempty"`

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

	// instances
	Instances []*FilingTypeInstance `json:"Instances"`

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

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

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

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

	// Owner
	OwnerID string `json:"OwnerID,omitempty"`

	// Saga Type
	SagaType string `json:"SagaType,omitempty"`

	// Submission Method
	SubmissionMethod string `json:"SubmissionMethod,omitempty"`

	// Instructions Template
	TemplateInstructionsID string `json:"TemplateInstructionsID,omitempty"`

	// Return Template
	TemplateReturnID string `json:"TemplateReturnID,omitempty"`
}

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

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

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

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

func (m *FilingType) validateDueDates(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *FilingType) validateInstances(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

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

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