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

package kbmodel

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"strconv"

	strfmt "github.com/go-openapi/strfmt"

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

// ComboPaymentTransaction combo payment transaction
// swagger:model ComboPaymentTransaction
type ComboPaymentTransaction struct {

	// account
	Account *Account `json:"account,omitempty"`

	// audit logs
	AuditLogs []*AuditLog `json:"auditLogs"`

	// payment method
	PaymentMethod *PaymentMethod `json:"paymentMethod,omitempty"`

	// payment method plugin properties
	PaymentMethodPluginProperties []*PluginProperty `json:"paymentMethodPluginProperties"`

	// transaction
	Transaction *PaymentTransaction `json:"transaction,omitempty"`

	// transaction plugin properties
	TransactionPluginProperties []*PluginProperty `json:"transactionPluginProperties"`
}

// Validate validates this combo payment transaction
func (m *ComboPaymentTransaction) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

func (m *ComboPaymentTransaction) validateAccount(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *ComboPaymentTransaction) validateAuditLogs(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *ComboPaymentTransaction) validatePaymentMethod(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *ComboPaymentTransaction) validatePaymentMethodPluginProperties(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *ComboPaymentTransaction) validateTransaction(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *ComboPaymentTransaction) validateTransactionPluginProperties(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

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

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