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

// SalesDelivery sales delivery
//
// swagger:model SalesDelivery
type SalesDelivery struct {

	// driver name
	DriverName string `json:"DriverName,omitempty"`

	// driver occupational license number
	DriverOccupationalLicenseNumber string `json:"DriverOccupationalLicenseNumber,omitempty"`

	// driver vehicle license number
	DriverVehicleLicenseNumber string `json:"DriverVehicleLicenseNumber,omitempty"`

	// estimated arrival date time
	EstimatedArrivalDateTime string `json:"EstimatedArrivalDateTime,omitempty"`

	// estimated departure date time
	EstimatedDepartureDateTime string `json:"EstimatedDepartureDateTime,omitempty"`

	// Id
	ID float64 `json:"Id,omitempty"`

	// phone number for questions
	PhoneNumberForQuestions string `json:"PhoneNumberForQuestions,omitempty"`

	// planned route
	PlannedRoute string `json:"PlannedRoute,omitempty"`

	// recipient address city
	RecipientAddressCity string `json:"RecipientAddressCity,omitempty"`

	// recipient address postal code
	RecipientAddressPostalCode string `json:"RecipientAddressPostalCode,omitempty"`

	// recipient address state
	RecipientAddressState string `json:"RecipientAddressState,omitempty"`

	// recipient address street1
	RecipientAddressStreet1 string `json:"RecipientAddressStreet1,omitempty"`

	// recipient address street2
	RecipientAddressStreet2 string `json:"RecipientAddressStreet2,omitempty"`

	// sales customer type
	SalesCustomerType string `json:"SalesCustomerType,omitempty"`

	// sales date time
	SalesDateTime string `json:"SalesDateTime,omitempty"`

	// transactions
	Transactions []*Transaction `json:"Transactions"`

	// vehicle license plate number
	VehicleLicensePlateNumber string `json:"VehicleLicensePlateNumber,omitempty"`

	// vehicle make
	VehicleMake string `json:"VehicleMake,omitempty"`

	// vehicle model
	VehicleModel string `json:"VehicleModel,omitempty"`
}

// Validate validates this sales delivery
func (m *SalesDelivery) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *SalesDelivery) validateTransactions(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

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

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