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

import (
	"encoding/json"
	stderrors "errors"
	"fmt"
	"io"

	"code.tnxs.net/vernonkeenan/lib/api/members/members_models"
	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"
)

// GetEmailMessagesReader is a Reader for the GetEmailMessages structure.
type GetEmailMessagesReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetEmailMessagesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewGetEmailMessagesOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewGetEmailMessagesUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewGetEmailMessagesForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewGetEmailMessagesNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewGetEmailMessagesUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewGetEmailMessagesInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /emailmessages] getEmailMessages", response, response.Code())
	}
}

// NewGetEmailMessagesOK creates a GetEmailMessagesOK with default headers values
func NewGetEmailMessagesOK() *GetEmailMessagesOK {
	return &GetEmailMessagesOK{}
}

// GetEmailMessagesOK describes a response with status code 200, with default header values.
//
// Array of Email Messages
type GetEmailMessagesOK struct {
	Payload *members_models.EmailMessagesResponse
}

// IsSuccess returns true when this get email messages o k response has a 2xx status code
func (o *GetEmailMessagesOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this get email messages o k response has a 3xx status code
func (o *GetEmailMessagesOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get email messages o k response has a 4xx status code
func (o *GetEmailMessagesOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this get email messages o k response has a 5xx status code
func (o *GetEmailMessagesOK) IsServerError() bool {
	return false
}

// IsCode returns true when this get email messages o k response a status code equal to that given
func (o *GetEmailMessagesOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the get email messages o k response
func (o *GetEmailMessagesOK) Code() int {
	return 200
}

func (o *GetEmailMessagesOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesOK %s", 200, payload)
}

func (o *GetEmailMessagesOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesOK %s", 200, payload)
}

func (o *GetEmailMessagesOK) GetPayload() *members_models.EmailMessagesResponse {
	return o.Payload
}

func (o *GetEmailMessagesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(members_models.EmailMessagesResponse)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) {
		return err
	}

	return nil
}

// NewGetEmailMessagesUnauthorized creates a GetEmailMessagesUnauthorized with default headers values
func NewGetEmailMessagesUnauthorized() *GetEmailMessagesUnauthorized {
	return &GetEmailMessagesUnauthorized{}
}

// GetEmailMessagesUnauthorized describes a response with status code 401, with default header values.
//
// Access Unauthorized, invalid API-KEY was used
type GetEmailMessagesUnauthorized struct {
	Payload *members_models.Error
}

// IsSuccess returns true when this get email messages unauthorized response has a 2xx status code
func (o *GetEmailMessagesUnauthorized) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get email messages unauthorized response has a 3xx status code
func (o *GetEmailMessagesUnauthorized) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get email messages unauthorized response has a 4xx status code
func (o *GetEmailMessagesUnauthorized) IsClientError() bool {
	return true
}

// IsServerError returns true when this get email messages unauthorized response has a 5xx status code
func (o *GetEmailMessagesUnauthorized) IsServerError() bool {
	return false
}

// IsCode returns true when this get email messages unauthorized response a status code equal to that given
func (o *GetEmailMessagesUnauthorized) IsCode(code int) bool {
	return code == 401
}

// Code gets the status code for the get email messages unauthorized response
func (o *GetEmailMessagesUnauthorized) Code() int {
	return 401
}

func (o *GetEmailMessagesUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesUnauthorized %s", 401, payload)
}

func (o *GetEmailMessagesUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesUnauthorized %s", 401, payload)
}

func (o *GetEmailMessagesUnauthorized) GetPayload() *members_models.Error {
	return o.Payload
}

func (o *GetEmailMessagesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(members_models.Error)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) {
		return err
	}

	return nil
}

// NewGetEmailMessagesForbidden creates a GetEmailMessagesForbidden with default headers values
func NewGetEmailMessagesForbidden() *GetEmailMessagesForbidden {
	return &GetEmailMessagesForbidden{}
}

// GetEmailMessagesForbidden describes a response with status code 403, with default header values.
//
// Access forbidden, account lacks access
type GetEmailMessagesForbidden struct {
	AccessControlAllowOrigin string

	Payload *members_models.Error
}

// IsSuccess returns true when this get email messages forbidden response has a 2xx status code
func (o *GetEmailMessagesForbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get email messages forbidden response has a 3xx status code
func (o *GetEmailMessagesForbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get email messages forbidden response has a 4xx status code
func (o *GetEmailMessagesForbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this get email messages forbidden response has a 5xx status code
func (o *GetEmailMessagesForbidden) IsServerError() bool {
	return false
}

// IsCode returns true when this get email messages forbidden response a status code equal to that given
func (o *GetEmailMessagesForbidden) IsCode(code int) bool {
	return code == 403
}

// Code gets the status code for the get email messages forbidden response
func (o *GetEmailMessagesForbidden) Code() int {
	return 403
}

func (o *GetEmailMessagesForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesForbidden %s", 403, payload)
}

func (o *GetEmailMessagesForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesForbidden %s", 403, payload)
}

func (o *GetEmailMessagesForbidden) GetPayload() *members_models.Error {
	return o.Payload
}

func (o *GetEmailMessagesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	// hydrates response header Access-Control-Allow-Origin
	hdrAccessControlAllowOrigin := response.GetHeader("Access-Control-Allow-Origin")

	if hdrAccessControlAllowOrigin != "" {
		o.AccessControlAllowOrigin = hdrAccessControlAllowOrigin
	}

	o.Payload = new(members_models.Error)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) {
		return err
	}

	return nil
}

// NewGetEmailMessagesNotFound creates a GetEmailMessagesNotFound with default headers values
func NewGetEmailMessagesNotFound() *GetEmailMessagesNotFound {
	return &GetEmailMessagesNotFound{}
}

// GetEmailMessagesNotFound describes a response with status code 404, with default header values.
//
// Resource was not found
type GetEmailMessagesNotFound struct {
	Payload *members_models.Error
}

// IsSuccess returns true when this get email messages not found response has a 2xx status code
func (o *GetEmailMessagesNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get email messages not found response has a 3xx status code
func (o *GetEmailMessagesNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get email messages not found response has a 4xx status code
func (o *GetEmailMessagesNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this get email messages not found response has a 5xx status code
func (o *GetEmailMessagesNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this get email messages not found response a status code equal to that given
func (o *GetEmailMessagesNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the get email messages not found response
func (o *GetEmailMessagesNotFound) Code() int {
	return 404
}

func (o *GetEmailMessagesNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesNotFound %s", 404, payload)
}

func (o *GetEmailMessagesNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesNotFound %s", 404, payload)
}

func (o *GetEmailMessagesNotFound) GetPayload() *members_models.Error {
	return o.Payload
}

func (o *GetEmailMessagesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(members_models.Error)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) {
		return err
	}

	return nil
}

// NewGetEmailMessagesUnprocessableEntity creates a GetEmailMessagesUnprocessableEntity with default headers values
func NewGetEmailMessagesUnprocessableEntity() *GetEmailMessagesUnprocessableEntity {
	return &GetEmailMessagesUnprocessableEntity{}
}

// GetEmailMessagesUnprocessableEntity describes a response with status code 422, with default header values.
//
// Unprocessable Entity, likely a bad parameter
type GetEmailMessagesUnprocessableEntity struct {
	Payload *members_models.Error
}

// IsSuccess returns true when this get email messages unprocessable entity response has a 2xx status code
func (o *GetEmailMessagesUnprocessableEntity) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get email messages unprocessable entity response has a 3xx status code
func (o *GetEmailMessagesUnprocessableEntity) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get email messages unprocessable entity response has a 4xx status code
func (o *GetEmailMessagesUnprocessableEntity) IsClientError() bool {
	return true
}

// IsServerError returns true when this get email messages unprocessable entity response has a 5xx status code
func (o *GetEmailMessagesUnprocessableEntity) IsServerError() bool {
	return false
}

// IsCode returns true when this get email messages unprocessable entity response a status code equal to that given
func (o *GetEmailMessagesUnprocessableEntity) IsCode(code int) bool {
	return code == 422
}

// Code gets the status code for the get email messages unprocessable entity response
func (o *GetEmailMessagesUnprocessableEntity) Code() int {
	return 422
}

func (o *GetEmailMessagesUnprocessableEntity) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesUnprocessableEntity %s", 422, payload)
}

func (o *GetEmailMessagesUnprocessableEntity) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesUnprocessableEntity %s", 422, payload)
}

func (o *GetEmailMessagesUnprocessableEntity) GetPayload() *members_models.Error {
	return o.Payload
}

func (o *GetEmailMessagesUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(members_models.Error)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) {
		return err
	}

	return nil
}

// NewGetEmailMessagesInternalServerError creates a GetEmailMessagesInternalServerError with default headers values
func NewGetEmailMessagesInternalServerError() *GetEmailMessagesInternalServerError {
	return &GetEmailMessagesInternalServerError{}
}

// GetEmailMessagesInternalServerError describes a response with status code 500, with default header values.
//
// Server Internal Error
type GetEmailMessagesInternalServerError struct {
	Payload *members_models.Error
}

// IsSuccess returns true when this get email messages internal server error response has a 2xx status code
func (o *GetEmailMessagesInternalServerError) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get email messages internal server error response has a 3xx status code
func (o *GetEmailMessagesInternalServerError) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get email messages internal server error response has a 4xx status code
func (o *GetEmailMessagesInternalServerError) IsClientError() bool {
	return false
}

// IsServerError returns true when this get email messages internal server error response has a 5xx status code
func (o *GetEmailMessagesInternalServerError) IsServerError() bool {
	return true
}

// IsCode returns true when this get email messages internal server error response a status code equal to that given
func (o *GetEmailMessagesInternalServerError) IsCode(code int) bool {
	return code == 500
}

// Code gets the status code for the get email messages internal server error response
func (o *GetEmailMessagesInternalServerError) Code() int {
	return 500
}

func (o *GetEmailMessagesInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesInternalServerError %s", 500, payload)
}

func (o *GetEmailMessagesInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /emailmessages][%d] getEmailMessagesInternalServerError %s", 500, payload)
}

func (o *GetEmailMessagesInternalServerError) GetPayload() *members_models.Error {
	return o.Payload
}

func (o *GetEmailMessagesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(members_models.Error)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) {
		return err
	}

	return nil
}
