package models

import (
	"encoding/json"
	"strconv"

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

type CallbackBasic struct {

	AfterCallWork *AfterCallWork `json:"afterCallWork,omitempty"`

	AfterCallWorkRequired bool `json:"afterCallWorkRequired"`

	AutomatedCallbackConfigID string `json:"automatedCallbackConfigId,omitempty"`

	CallbackNumbers []string `json:"callbackNumbers"`

	CallbackScheduledTime strfmt.DateTime `json:"callbackScheduledTime,omitempty"`

	CallbackUserName string `json:"callbackUserName,omitempty"`

	CallerID string `json:"callerId,omitempty"`

	CallerIDName string `json:"callerIdName,omitempty"`

	ConnectedTime strfmt.DateTime `json:"connectedTime,omitempty"`

	DialerPreview *DialerPreview `json:"dialerPreview,omitempty"`

	Direction string `json:"direction,omitempty"`

	DisconnectType string `json:"disconnectType,omitempty"`

	DisconnectedTime strfmt.DateTime `json:"disconnectedTime,omitempty"`

	ExternalCampaign bool `json:"externalCampaign"`

	Held bool `json:"held"`

	ID string `json:"id,omitempty"`

	PeerID string `json:"peerId,omitempty"`

	Provider string `json:"provider,omitempty"`

	ScriptID string `json:"scriptId,omitempty"`

	Segments []*Segment `json:"segments"`

	SkipEnabled bool `json:"skipEnabled"`

	StartAlertingTime strfmt.DateTime `json:"startAlertingTime,omitempty"`

	StartHoldTime strfmt.DateTime `json:"startHoldTime,omitempty"`

	State string `json:"state,omitempty"`

	TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`

	Voicemail *Voicemail `json:"voicemail,omitempty"`

	Wrapup *Wrapup `json:"wrapup,omitempty"`
}

func (m *CallbackBasic) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *CallbackBasic) validateAfterCallWork(formats strfmt.Registry) error {

	if swag.IsZero(m.AfterCallWork) { 
		return nil
	}

	if m.AfterCallWork != nil {
		if err := m.AfterCallWork.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("afterCallWork")
			}
			return err
		}
	}

	return nil
}

func (m *CallbackBasic) validateCallbackScheduledTime(formats strfmt.Registry) error {

	if swag.IsZero(m.CallbackScheduledTime) { 
		return nil
	}

	if err := validate.FormatOf("callbackScheduledTime", "body", "date-time", m.CallbackScheduledTime.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateConnectedTime(formats strfmt.Registry) error {

	if swag.IsZero(m.ConnectedTime) { 
		return nil
	}

	if err := validate.FormatOf("connectedTime", "body", "date-time", m.ConnectedTime.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateDialerPreview(formats strfmt.Registry) error {

	if swag.IsZero(m.DialerPreview) { 
		return nil
	}

	if m.DialerPreview != nil {
		if err := m.DialerPreview.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("dialerPreview")
			}
			return err
		}
	}

	return nil
}

var callbackBasicTypeDirectionPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["inbound","outbound"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		callbackBasicTypeDirectionPropEnum = append(callbackBasicTypeDirectionPropEnum, v)
	}
}

const (

	CallbackBasicDirectionInbound string = "inbound"

	CallbackBasicDirectionOutbound string = "outbound"
)

func (m *CallbackBasic) validateDirectionEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, callbackBasicTypeDirectionPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CallbackBasic) validateDirection(formats strfmt.Registry) error {

	if swag.IsZero(m.Direction) { 
		return nil
	}

	if err := m.validateDirectionEnum("direction", "body", m.Direction); err != nil {
		return err
	}

	return nil
}

var callbackBasicTypeDisconnectTypePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["endpoint","client","system","timeout","transfer","transfer.conference","transfer.consult","transfer.forward","transfer.noanswer","transfer.notavailable","transport.failure","error","peer","other","spam","uncallable"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		callbackBasicTypeDisconnectTypePropEnum = append(callbackBasicTypeDisconnectTypePropEnum, v)
	}
}

const (

	CallbackBasicDisconnectTypeEndpoint string = "endpoint"

	CallbackBasicDisconnectTypeClient string = "client"

	CallbackBasicDisconnectTypeSystem string = "system"

	CallbackBasicDisconnectTypeTimeout string = "timeout"

	CallbackBasicDisconnectTypeTransfer string = "transfer"

	CallbackBasicDisconnectTypeTransferConference string = "transfer.conference"

	CallbackBasicDisconnectTypeTransferConsult string = "transfer.consult"

	CallbackBasicDisconnectTypeTransferForward string = "transfer.forward"

	CallbackBasicDisconnectTypeTransferNoanswer string = "transfer.noanswer"

	CallbackBasicDisconnectTypeTransferNotavailable string = "transfer.notavailable"

	CallbackBasicDisconnectTypeTransportFailure string = "transport.failure"

	CallbackBasicDisconnectTypeError string = "error"

	CallbackBasicDisconnectTypePeer string = "peer"

	CallbackBasicDisconnectTypeOther string = "other"

	CallbackBasicDisconnectTypeSpam string = "spam"

	CallbackBasicDisconnectTypeUncallable string = "uncallable"
)

func (m *CallbackBasic) validateDisconnectTypeEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, callbackBasicTypeDisconnectTypePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CallbackBasic) validateDisconnectType(formats strfmt.Registry) error {

	if swag.IsZero(m.DisconnectType) { 
		return nil
	}

	if err := m.validateDisconnectTypeEnum("disconnectType", "body", m.DisconnectType); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateDisconnectedTime(formats strfmt.Registry) error {

	if swag.IsZero(m.DisconnectedTime) { 
		return nil
	}

	if err := validate.FormatOf("disconnectedTime", "body", "date-time", m.DisconnectedTime.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateSegments(formats strfmt.Registry) error {

	if swag.IsZero(m.Segments) { 
		return nil
	}

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

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

	}

	return nil
}

func (m *CallbackBasic) validateStartAlertingTime(formats strfmt.Registry) error {

	if swag.IsZero(m.StartAlertingTime) { 
		return nil
	}

	if err := validate.FormatOf("startAlertingTime", "body", "date-time", m.StartAlertingTime.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateStartHoldTime(formats strfmt.Registry) error {

	if swag.IsZero(m.StartHoldTime) { 
		return nil
	}

	if err := validate.FormatOf("startHoldTime", "body", "date-time", m.StartHoldTime.String(), formats); err != nil {
		return err
	}

	return nil
}

var callbackBasicTypeStatePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["alerting","dialing","contacting","offering","connected","disconnected","terminated","scheduled","none"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		callbackBasicTypeStatePropEnum = append(callbackBasicTypeStatePropEnum, v)
	}
}

const (

	CallbackBasicStateAlerting string = "alerting"

	CallbackBasicStateDialing string = "dialing"

	CallbackBasicStateContacting string = "contacting"

	CallbackBasicStateOffering string = "offering"

	CallbackBasicStateConnected string = "connected"

	CallbackBasicStateDisconnected string = "disconnected"

	CallbackBasicStateTerminated string = "terminated"

	CallbackBasicStateScheduled string = "scheduled"

	CallbackBasicStateNone string = "none"
)

func (m *CallbackBasic) validateStateEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, callbackBasicTypeStatePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CallbackBasic) validateState(formats strfmt.Registry) error {

	if swag.IsZero(m.State) { 
		return nil
	}

	if err := m.validateStateEnum("state", "body", m.State); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateVoicemail(formats strfmt.Registry) error {

	if swag.IsZero(m.Voicemail) { 
		return nil
	}

	if m.Voicemail != nil {
		if err := m.Voicemail.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("voicemail")
			}
			return err
		}
	}

	return nil
}

func (m *CallbackBasic) validateWrapup(formats strfmt.Registry) error {

	if swag.IsZero(m.Wrapup) { 
		return nil
	}

	if m.Wrapup != nil {
		if err := m.Wrapup.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("wrapup")
			}
			return err
		}
	}

	return nil
}

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

func (m *CallbackBasic) UnmarshalBinary(b []byte) error {
	var res CallbackBasic
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
// 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 (
	"encoding/json"
	"strconv"

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

// CallbackBasic callback basic
//
// swagger:model CallbackBasic
type CallbackBasic struct {

	// After-call work for the communication.
	AfterCallWork *AfterCallWork `json:"afterCallWork,omitempty"`

	// Indicates if after-call work is required for a communication. Only used when the ACW Setting is Agent Requested.
	AfterCallWorkRequired bool `json:"afterCallWorkRequired"`

	// The id of the config for automatically placing the callback (and handling the disposition). If null, the callback will not be placed automatically but routed to an agent as per normal.
	AutomatedCallbackConfigID string `json:"automatedCallbackConfigId,omitempty"`

	// The phone number(s) to use to place the callback.
	CallbackNumbers []string `json:"callbackNumbers"`

	// The timestamp when this communication is scheduled in the provider clock. If this value is missing it indicates the callback will be placed immediately. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
	// Format: date-time
	CallbackScheduledTime strfmt.DateTime `json:"callbackScheduledTime,omitempty"`

	// The name of the user requesting a callback.
	CallbackUserName string `json:"callbackUserName,omitempty"`

	// The phone number displayed to recipients of the phone call. The value should conform to the E164 format.
	CallerID string `json:"callerId,omitempty"`

	// The name displayed to recipients of the phone call.
	CallerIDName string `json:"callerIdName,omitempty"`

	// The timestamp when this communication was connected in the cloud clock. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
	// Format: date-time
	ConnectedTime strfmt.DateTime `json:"connectedTime,omitempty"`

	// The preview data to be used when this callback is a Preview.
	DialerPreview *DialerPreview `json:"dialerPreview,omitempty"`

	// The direction of the call
	// Enum: [inbound outbound]
	Direction string `json:"direction,omitempty"`

	// System defined string indicating what caused the communication to disconnect. Will be null until the communication disconnects.
	// Enum: [endpoint client system timeout transfer transfer.conference transfer.consult transfer.forward transfer.noanswer transfer.notavailable transport.failure error peer other spam uncallable]
	DisconnectType string `json:"disconnectType,omitempty"`

	// The timestamp when this communication disconnected from the conversation in the provider clock. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
	// Format: date-time
	DisconnectedTime strfmt.DateTime `json:"disconnectedTime,omitempty"`

	// True if the call for the callback uses external dialing.
	ExternalCampaign bool `json:"externalCampaign"`

	// True if this call is held and the person on this side hears silence.
	Held bool `json:"held"`

	// A globally unique identifier for this communication.
	ID string `json:"id,omitempty"`

	// The id of the peer communication corresponding to a matching leg for this communication.
	PeerID string `json:"peerId,omitempty"`

	// The source provider for the callback.
	Provider string `json:"provider,omitempty"`

	// The UUID of the script to use.
	ScriptID string `json:"scriptId,omitempty"`

	// The time line of the participant's callback, divided into activity segments.
	Segments []*Segment `json:"segments"`

	// True if the ability to skip a callback should be enabled.
	SkipEnabled bool `json:"skipEnabled"`

	// The timestamp the communication has when it is first put into an alerting state. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
	// Format: date-time
	StartAlertingTime strfmt.DateTime `json:"startAlertingTime,omitempty"`

	// The timestamp the callback was placed on hold in the cloud clock if the callback is currently on hold. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
	// Format: date-time
	StartHoldTime strfmt.DateTime `json:"startHoldTime,omitempty"`

	// The connection state of this communication.
	// Enum: [alerting dialing contacting offering connected disconnected terminated scheduled none]
	State string `json:"state,omitempty"`

	// The number of seconds before the system automatically places a call for a callback.  0 means the automatic placement is disabled.
	TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`

	// The voicemail data to be used when this callback is an ACD voicemail.
	Voicemail *Voicemail `json:"voicemail,omitempty"`

	// Call wrap up or disposition data.
	Wrapup *Wrapup `json:"wrapup,omitempty"`
}

// Validate validates this callback basic
func (m *CallbackBasic) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *CallbackBasic) validateAfterCallWork(formats strfmt.Registry) error {

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

	if m.AfterCallWork != nil {
		if err := m.AfterCallWork.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("afterCallWork")
			}
			return err
		}
	}

	return nil
}

func (m *CallbackBasic) validateCallbackScheduledTime(formats strfmt.Registry) error {

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

	if err := validate.FormatOf("callbackScheduledTime", "body", "date-time", m.CallbackScheduledTime.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateConnectedTime(formats strfmt.Registry) error {

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

	if err := validate.FormatOf("connectedTime", "body", "date-time", m.ConnectedTime.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateDialerPreview(formats strfmt.Registry) error {

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

	if m.DialerPreview != nil {
		if err := m.DialerPreview.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("dialerPreview")
			}
			return err
		}
	}

	return nil
}

var callbackBasicTypeDirectionPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["inbound","outbound"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		callbackBasicTypeDirectionPropEnum = append(callbackBasicTypeDirectionPropEnum, v)
	}
}

const (

	// CallbackBasicDirectionInbound captures enum value "inbound"
	CallbackBasicDirectionInbound string = "inbound"

	// CallbackBasicDirectionOutbound captures enum value "outbound"
	CallbackBasicDirectionOutbound string = "outbound"
)

// prop value enum
func (m *CallbackBasic) validateDirectionEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, callbackBasicTypeDirectionPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CallbackBasic) validateDirection(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateDirectionEnum("direction", "body", m.Direction); err != nil {
		return err
	}

	return nil
}

var callbackBasicTypeDisconnectTypePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["endpoint","client","system","timeout","transfer","transfer.conference","transfer.consult","transfer.forward","transfer.noanswer","transfer.notavailable","transport.failure","error","peer","other","spam","uncallable"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		callbackBasicTypeDisconnectTypePropEnum = append(callbackBasicTypeDisconnectTypePropEnum, v)
	}
}

const (

	// CallbackBasicDisconnectTypeEndpoint captures enum value "endpoint"
	CallbackBasicDisconnectTypeEndpoint string = "endpoint"

	// CallbackBasicDisconnectTypeClient captures enum value "client"
	CallbackBasicDisconnectTypeClient string = "client"

	// CallbackBasicDisconnectTypeSystem captures enum value "system"
	CallbackBasicDisconnectTypeSystem string = "system"

	// CallbackBasicDisconnectTypeTimeout captures enum value "timeout"
	CallbackBasicDisconnectTypeTimeout string = "timeout"

	// CallbackBasicDisconnectTypeTransfer captures enum value "transfer"
	CallbackBasicDisconnectTypeTransfer string = "transfer"

	// CallbackBasicDisconnectTypeTransferConference captures enum value "transfer.conference"
	CallbackBasicDisconnectTypeTransferConference string = "transfer.conference"

	// CallbackBasicDisconnectTypeTransferConsult captures enum value "transfer.consult"
	CallbackBasicDisconnectTypeTransferConsult string = "transfer.consult"

	// CallbackBasicDisconnectTypeTransferForward captures enum value "transfer.forward"
	CallbackBasicDisconnectTypeTransferForward string = "transfer.forward"

	// CallbackBasicDisconnectTypeTransferNoanswer captures enum value "transfer.noanswer"
	CallbackBasicDisconnectTypeTransferNoanswer string = "transfer.noanswer"

	// CallbackBasicDisconnectTypeTransferNotavailable captures enum value "transfer.notavailable"
	CallbackBasicDisconnectTypeTransferNotavailable string = "transfer.notavailable"

	// CallbackBasicDisconnectTypeTransportFailure captures enum value "transport.failure"
	CallbackBasicDisconnectTypeTransportFailure string = "transport.failure"

	// CallbackBasicDisconnectTypeError captures enum value "error"
	CallbackBasicDisconnectTypeError string = "error"

	// CallbackBasicDisconnectTypePeer captures enum value "peer"
	CallbackBasicDisconnectTypePeer string = "peer"

	// CallbackBasicDisconnectTypeOther captures enum value "other"
	CallbackBasicDisconnectTypeOther string = "other"

	// CallbackBasicDisconnectTypeSpam captures enum value "spam"
	CallbackBasicDisconnectTypeSpam string = "spam"

	// CallbackBasicDisconnectTypeUncallable captures enum value "uncallable"
	CallbackBasicDisconnectTypeUncallable string = "uncallable"
)

// prop value enum
func (m *CallbackBasic) validateDisconnectTypeEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, callbackBasicTypeDisconnectTypePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CallbackBasic) validateDisconnectType(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateDisconnectTypeEnum("disconnectType", "body", m.DisconnectType); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateDisconnectedTime(formats strfmt.Registry) error {

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

	if err := validate.FormatOf("disconnectedTime", "body", "date-time", m.DisconnectedTime.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateSegments(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *CallbackBasic) validateStartAlertingTime(formats strfmt.Registry) error {

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

	if err := validate.FormatOf("startAlertingTime", "body", "date-time", m.StartAlertingTime.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateStartHoldTime(formats strfmt.Registry) error {

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

	if err := validate.FormatOf("startHoldTime", "body", "date-time", m.StartHoldTime.String(), formats); err != nil {
		return err
	}

	return nil
}

var callbackBasicTypeStatePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["alerting","dialing","contacting","offering","connected","disconnected","terminated","scheduled","none"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		callbackBasicTypeStatePropEnum = append(callbackBasicTypeStatePropEnum, v)
	}
}

const (

	// CallbackBasicStateAlerting captures enum value "alerting"
	CallbackBasicStateAlerting string = "alerting"

	// CallbackBasicStateDialing captures enum value "dialing"
	CallbackBasicStateDialing string = "dialing"

	// CallbackBasicStateContacting captures enum value "contacting"
	CallbackBasicStateContacting string = "contacting"

	// CallbackBasicStateOffering captures enum value "offering"
	CallbackBasicStateOffering string = "offering"

	// CallbackBasicStateConnected captures enum value "connected"
	CallbackBasicStateConnected string = "connected"

	// CallbackBasicStateDisconnected captures enum value "disconnected"
	CallbackBasicStateDisconnected string = "disconnected"

	// CallbackBasicStateTerminated captures enum value "terminated"
	CallbackBasicStateTerminated string = "terminated"

	// CallbackBasicStateScheduled captures enum value "scheduled"
	CallbackBasicStateScheduled string = "scheduled"

	// CallbackBasicStateNone captures enum value "none"
	CallbackBasicStateNone string = "none"
)

// prop value enum
func (m *CallbackBasic) validateStateEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, callbackBasicTypeStatePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *CallbackBasic) validateState(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateStateEnum("state", "body", m.State); err != nil {
		return err
	}

	return nil
}

func (m *CallbackBasic) validateVoicemail(formats strfmt.Registry) error {

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

	if m.Voicemail != nil {
		if err := m.Voicemail.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("voicemail")
			}
			return err
		}
	}

	return nil
}

func (m *CallbackBasic) validateWrapup(formats strfmt.Registry) error {

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

	if m.Wrapup != nil {
		if err := m.Wrapup.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("wrapup")
			}
			return err
		}
	}

	return nil
}

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

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