// 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"
	"github.com/go-openapi/validate"
)

// ReportRecipient report recipient
//
// swagger:model ReportRecipient
type ReportRecipient struct {

	// If the type is admin and the method is email, the field should indicate the actual email address of the admin
	// Read Only: true
	AdditionInfo string `json:"additionInfo,omitempty"`

	// This should be a username if type=admin, or an email address if type=arbitrary
	// Example: sarah
	// Required: true
	Addr *string `json:"addr"`

	// This should always be email
	// Example: email
	Method string `json:"method,omitempty"`

	// Where admin refers to a user in the account and arbitrary refers to an email address not associated with a user account.Acceptable values are: admin, arbitrary
	// Example: admin
	// Required: true
	Type *string `json:"type"`
}

// Validate validates this report recipient
func (m *ReportRecipient) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *ReportRecipient) validateAddr(formats strfmt.Registry) error {

	if err := validate.Required("addr", "body", m.Addr); err != nil {
		return err
	}

	return nil
}

func (m *ReportRecipient) validateType(formats strfmt.Registry) error {

	if err := validate.Required("type", "body", m.Type); err != nil {
		return err
	}

	return nil
}

// ContextValidate validate this report recipient based on the context it is used
func (m *ReportRecipient) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *ReportRecipient) contextValidateAdditionInfo(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "additionInfo", "body", string(m.AdditionInfo)); err != nil {
		return err
	}

	return nil
}

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

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