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

// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package sfgate_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"
)

// UserRequest user request
//
// swagger:model UserRequest
type UserRequest struct {

	// API key
	APIKey string `json:"APIKey,omitempty"`

	// address
	Address *Address `json:"Address,omitempty"`

	// email
	Email string `json:"Email,omitempty"`

	// environment
	Environment string `json:"Environment,omitempty"`

	// first name
	FirstName string `json:"FirstName,omitempty"`

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

	// last name
	LastName string `json:"LastName,omitempty"`

	// taxnexus account
	TaxnexusAccount string `json:"TaxnexusAccount,omitempty"`

	// title
	Title string `json:"Title,omitempty"`
}

// Validate validates this user request
func (m *UserRequest) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *UserRequest) validateAddress(formats strfmt.Registry) error {
	if swag.IsZero(m.Address) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *UserRequest) contextValidateAddress(ctx context.Context, formats strfmt.Registry) error {

	if m.Address != nil {
		if err := m.Address.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("Address")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("Address")
			}
			return err
		}
	}

	return nil
}

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

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