// 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 workflow_models

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

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

// EmailMessage email message
//
// swagger:model EmailMessage
type EmailMessage struct {

	// activity ID
	ActivityID string `json:"ActivityID,omitempty"`

	// b c c address
	BCCAddress string `json:"BCCAddress,omitempty"`

	// c c address
	CCAddress string `json:"CCAddress,omitempty"`

	// created by ID
	CreatedByID string `json:"CreatedByID,omitempty"`

	// created date
	CreatedDate string `json:"CreatedDate,omitempty"`

	// email message ID
	EmailMessageID string `json:"EmailMessageID,omitempty"`

	// from address
	FromAddress string `json:"FromAddress,omitempty"`

	// from name
	FromName string `json:"FromName,omitempty"`

	// HTML
	// Format: byte
	HTML strfmt.Base64 `json:"HTML,omitempty"`

	// has attachment
	HasAttachment bool `json:"HasAttachment,omitempty"`

	// headers
	Headers *Headers `json:"Headers,omitempty"`

	// ID
	ID string `json:"ID,omitempty"`

	// incoming
	Incoming bool `json:"Incoming,omitempty"`

	// is client managed
	IsClientManaged bool `json:"IsClientManaged,omitempty"`

	// is externally managed
	IsExternallyManaged bool `json:"IsExternallyManaged,omitempty"`

	// last modified by ID
	LastModifiedByID string `json:"LastModifiedByID,omitempty"`

	// last modified date
	LastModifiedDate string `json:"LastModifiedDate,omitempty"`

	// message date
	MessageDate string `json:"MessageDate,omitempty"`

	// message identifier
	MessageIdentifier string `json:"MessageIdentifier,omitempty"`

	// parent ID
	ParentID string `json:"ParentID,omitempty"`

	// related to ID
	RelatedToID string `json:"RelatedToID,omitempty"`

	// relation address
	RelationAddress string `json:"RelationAddress,omitempty"`

	// relation ID
	RelationID string `json:"RelationID,omitempty"`

	// relation object type
	RelationObjectType string `json:"RelationObjectType,omitempty"`

	// relation type
	RelationType string `json:"RelationType,omitempty"`

	// reply to email message ID
	ReplyToEmailMessageID string `json:"ReplyToEmailMessageID,omitempty"`

	// status
	Status string `json:"Status,omitempty"`

	// subject
	Subject string `json:"Subject,omitempty"`

	// text
	// Format: byte
	Text strfmt.Base64 `json:"Text,omitempty"`

	// thread identifier
	ThreadIdentifier string `json:"ThreadIdentifier,omitempty"`

	// to address
	ToAddress string `json:"ToAddress,omitempty"`

	// validated from address
	ValidatedFromAddress string `json:"ValidatedFromAddress,omitempty"`
}

// Validate validates this email message
func (m *EmailMessage) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *EmailMessage) validateHeaders(formats strfmt.Registry) error {

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

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

	return nil
}

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

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