// 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 (
	strfmt "github.com/go-openapi/strfmt"

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

// GetCharactersCharacterIDMailOKBodyItems get_characters_character_id_mail_200_ok
//
// 200 ok object
// swagger:model getCharactersCharacterIdMailOKBodyItems

type GetCharactersCharacterIDMailOKBodyItems struct {

	// get_characters_character_id_mail_from
	//
	// From whom the mail was sent
	From int32 `json:"from,omitempty"`

	// get_characters_character_id_mail_is_read
	//
	// is_read boolean
	IsRead bool `json:"is_read,omitempty"`

	// get_characters_character_id_mail_labels
	//
	// labels array
	// Minimum: 0
	// Max Items: 25
	// Unique: true
	Labels []int64 `json:"labels"`

	// get_characters_character_id_mail_mail_id
	//
	// mail_id integer
	MailID int64 `json:"mail_id,omitempty"`

	// recipients
	Recipients GetCharactersCharacterIDMailOKBodyItemsRecipients `json:"recipients"`

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

	// get_characters_character_id_mail_timestamp
	//
	// When the mail was sent
	Timestamp strfmt.DateTime `json:"timestamp,omitempty"`
}

/* polymorph getCharactersCharacterIdMailOKBodyItems from false */

/* polymorph getCharactersCharacterIdMailOKBodyItems is_read false */

/* polymorph getCharactersCharacterIdMailOKBodyItems labels false */

/* polymorph getCharactersCharacterIdMailOKBodyItems mail_id false */

/* polymorph getCharactersCharacterIdMailOKBodyItems recipients false */

/* polymorph getCharactersCharacterIdMailOKBodyItems subject false */

/* polymorph getCharactersCharacterIdMailOKBodyItems timestamp false */

// Validate validates this get characters character Id mail o k body items
func (m *GetCharactersCharacterIDMailOKBodyItems) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *GetCharactersCharacterIDMailOKBodyItems) validateLabels(formats strfmt.Registry) error {

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

	iLabelsSize := int64(len(m.Labels))

	if err := validate.MaxItems("labels", "body", iLabelsSize, 25); err != nil {
		return err
	}

	if err := validate.UniqueItems("labels", "body", m.Labels); err != nil {
		return err
	}

	return nil
}

func (m *GetCharactersCharacterIDMailOKBodyItems) validateRecipients(formats strfmt.Registry) error {

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

	return nil
}

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

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