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

	// duedates
	Duedates []*FilingDueDate `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
}
