// Code generated by go-swagger; DO NOT EDIT.

package 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"

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

// Billing20201105GetContractResponse GetContractResponse returns a Contract.
//
// swagger:model billing_20201105GetContractResponse
type Billing20201105GetContractResponse struct {

	// contract is the contract with the corresponding public ID.
	Contract *Billing20201105Contract `json:"contract,omitempty"`
}

// Validate validates this billing 20201105 get contract response
func (m *Billing20201105GetContractResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *Billing20201105GetContractResponse) validateContract(formats strfmt.Registry) error {
	if swag.IsZero(m.Contract) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this billing 20201105 get contract response based on the context it is used
func (m *Billing20201105GetContractResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *Billing20201105GetContractResponse) contextValidateContract(ctx context.Context, formats strfmt.Registry) error {

	if m.Contract != nil {

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

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

	return nil
}

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

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