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

package unannotated_echo_service

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

	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"

	"github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/unannotatedecho/models"
)

// UnannotatedEchoServiceEchoReader is a Reader for the UnannotatedEchoServiceEcho structure.
type UnannotatedEchoServiceEchoReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *UnannotatedEchoServiceEchoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewUnannotatedEchoServiceEchoOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewUnannotatedEchoServiceEchoForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewUnannotatedEchoServiceEchoNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewUnannotatedEchoServiceEchoServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		result := NewUnannotatedEchoServiceEchoDefault(response.Code())
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		if response.Code()/100 == 2 {
			return result, nil
		}
		return nil, result
	}
}

// NewUnannotatedEchoServiceEchoOK creates a UnannotatedEchoServiceEchoOK with default headers values
func NewUnannotatedEchoServiceEchoOK() *UnannotatedEchoServiceEchoOK {
	return &UnannotatedEchoServiceEchoOK{}
}

/*
UnannotatedEchoServiceEchoOK describes a response with status code 200, with default header values.

A successful response.
*/
type UnannotatedEchoServiceEchoOK struct {
	Payload *models.ExamplepbUnannotatedSimpleMessage
}

// IsSuccess returns true when this unannotated echo service echo o k response has a 2xx status code
func (o *UnannotatedEchoServiceEchoOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this unannotated echo service echo o k response has a 3xx status code
func (o *UnannotatedEchoServiceEchoOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this unannotated echo service echo o k response has a 4xx status code
func (o *UnannotatedEchoServiceEchoOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this unannotated echo service echo o k response has a 5xx status code
func (o *UnannotatedEchoServiceEchoOK) IsServerError() bool {
	return false
}

// IsCode returns true when this unannotated echo service echo o k response a status code equal to that given
func (o *UnannotatedEchoServiceEchoOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the unannotated echo service echo o k response
func (o *UnannotatedEchoServiceEchoOK) Code() int {
	return 200
}

func (o *UnannotatedEchoServiceEchoOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] unannotatedEchoServiceEchoOK %s", 200, payload)
}

func (o *UnannotatedEchoServiceEchoOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] unannotatedEchoServiceEchoOK %s", 200, payload)
}

func (o *UnannotatedEchoServiceEchoOK) GetPayload() *models.ExamplepbUnannotatedSimpleMessage {
	return o.Payload
}

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

	o.Payload = new(models.ExamplepbUnannotatedSimpleMessage)

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

	return nil
}

// NewUnannotatedEchoServiceEchoForbidden creates a UnannotatedEchoServiceEchoForbidden with default headers values
func NewUnannotatedEchoServiceEchoForbidden() *UnannotatedEchoServiceEchoForbidden {
	return &UnannotatedEchoServiceEchoForbidden{}
}

/*
UnannotatedEchoServiceEchoForbidden describes a response with status code 403, with default header values.

Returned when the user does not have permission to access the resource.
*/
type UnannotatedEchoServiceEchoForbidden struct {
	Payload any
}

// IsSuccess returns true when this unannotated echo service echo forbidden response has a 2xx status code
func (o *UnannotatedEchoServiceEchoForbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this unannotated echo service echo forbidden response has a 3xx status code
func (o *UnannotatedEchoServiceEchoForbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this unannotated echo service echo forbidden response has a 4xx status code
func (o *UnannotatedEchoServiceEchoForbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this unannotated echo service echo forbidden response has a 5xx status code
func (o *UnannotatedEchoServiceEchoForbidden) IsServerError() bool {
	return false
}

// IsCode returns true when this unannotated echo service echo forbidden response a status code equal to that given
func (o *UnannotatedEchoServiceEchoForbidden) IsCode(code int) bool {
	return code == 403
}

// Code gets the status code for the unannotated echo service echo forbidden response
func (o *UnannotatedEchoServiceEchoForbidden) Code() int {
	return 403
}

func (o *UnannotatedEchoServiceEchoForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] unannotatedEchoServiceEchoForbidden %s", 403, payload)
}

func (o *UnannotatedEchoServiceEchoForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] unannotatedEchoServiceEchoForbidden %s", 403, payload)
}

func (o *UnannotatedEchoServiceEchoForbidden) GetPayload() any {
	return o.Payload
}

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

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

	return nil
}

// NewUnannotatedEchoServiceEchoNotFound creates a UnannotatedEchoServiceEchoNotFound with default headers values
func NewUnannotatedEchoServiceEchoNotFound() *UnannotatedEchoServiceEchoNotFound {
	return &UnannotatedEchoServiceEchoNotFound{}
}

/*
UnannotatedEchoServiceEchoNotFound describes a response with status code 404, with default header values.

Returned when the resource does not exist.
*/
type UnannotatedEchoServiceEchoNotFound struct {
	Payload int64
}

// IsSuccess returns true when this unannotated echo service echo not found response has a 2xx status code
func (o *UnannotatedEchoServiceEchoNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this unannotated echo service echo not found response has a 3xx status code
func (o *UnannotatedEchoServiceEchoNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this unannotated echo service echo not found response has a 4xx status code
func (o *UnannotatedEchoServiceEchoNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this unannotated echo service echo not found response has a 5xx status code
func (o *UnannotatedEchoServiceEchoNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this unannotated echo service echo not found response a status code equal to that given
func (o *UnannotatedEchoServiceEchoNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the unannotated echo service echo not found response
func (o *UnannotatedEchoServiceEchoNotFound) Code() int {
	return 404
}

func (o *UnannotatedEchoServiceEchoNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] unannotatedEchoServiceEchoNotFound %s", 404, payload)
}

func (o *UnannotatedEchoServiceEchoNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] unannotatedEchoServiceEchoNotFound %s", 404, payload)
}

func (o *UnannotatedEchoServiceEchoNotFound) GetPayload() int64 {
	return o.Payload
}

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

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

	return nil
}

// NewUnannotatedEchoServiceEchoServiceUnavailable creates a UnannotatedEchoServiceEchoServiceUnavailable with default headers values
func NewUnannotatedEchoServiceEchoServiceUnavailable() *UnannotatedEchoServiceEchoServiceUnavailable {
	return &UnannotatedEchoServiceEchoServiceUnavailable{}
}

/*
UnannotatedEchoServiceEchoServiceUnavailable describes a response with status code 503, with default header values.

Returned when the resource is temporarily unavailable.
*/
type UnannotatedEchoServiceEchoServiceUnavailable struct {
	Payload any
}

// IsSuccess returns true when this unannotated echo service echo service unavailable response has a 2xx status code
func (o *UnannotatedEchoServiceEchoServiceUnavailable) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this unannotated echo service echo service unavailable response has a 3xx status code
func (o *UnannotatedEchoServiceEchoServiceUnavailable) IsRedirect() bool {
	return false
}

// IsClientError returns true when this unannotated echo service echo service unavailable response has a 4xx status code
func (o *UnannotatedEchoServiceEchoServiceUnavailable) IsClientError() bool {
	return false
}

// IsServerError returns true when this unannotated echo service echo service unavailable response has a 5xx status code
func (o *UnannotatedEchoServiceEchoServiceUnavailable) IsServerError() bool {
	return true
}

// IsCode returns true when this unannotated echo service echo service unavailable response a status code equal to that given
func (o *UnannotatedEchoServiceEchoServiceUnavailable) IsCode(code int) bool {
	return code == 503
}

// Code gets the status code for the unannotated echo service echo service unavailable response
func (o *UnannotatedEchoServiceEchoServiceUnavailable) Code() int {
	return 503
}

func (o *UnannotatedEchoServiceEchoServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] unannotatedEchoServiceEchoServiceUnavailable %s", 503, payload)
}

func (o *UnannotatedEchoServiceEchoServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] unannotatedEchoServiceEchoServiceUnavailable %s", 503, payload)
}

func (o *UnannotatedEchoServiceEchoServiceUnavailable) GetPayload() any {
	return o.Payload
}

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

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

	return nil
}

// NewUnannotatedEchoServiceEchoDefault creates a UnannotatedEchoServiceEchoDefault with default headers values
func NewUnannotatedEchoServiceEchoDefault(code int) *UnannotatedEchoServiceEchoDefault {
	return &UnannotatedEchoServiceEchoDefault{
		_statusCode: code,
	}
}

/*
UnannotatedEchoServiceEchoDefault describes a response with status code -1, with default header values.

An unexpected error response.
*/
type UnannotatedEchoServiceEchoDefault struct {
	_statusCode int

	Payload *models.RPCStatus
}

// IsSuccess returns true when this unannotated echo service echo default response has a 2xx status code
func (o *UnannotatedEchoServiceEchoDefault) IsSuccess() bool {
	return o._statusCode/100 == 2
}

// IsRedirect returns true when this unannotated echo service echo default response has a 3xx status code
func (o *UnannotatedEchoServiceEchoDefault) IsRedirect() bool {
	return o._statusCode/100 == 3
}

// IsClientError returns true when this unannotated echo service echo default response has a 4xx status code
func (o *UnannotatedEchoServiceEchoDefault) IsClientError() bool {
	return o._statusCode/100 == 4
}

// IsServerError returns true when this unannotated echo service echo default response has a 5xx status code
func (o *UnannotatedEchoServiceEchoDefault) IsServerError() bool {
	return o._statusCode/100 == 5
}

// IsCode returns true when this unannotated echo service echo default response a status code equal to that given
func (o *UnannotatedEchoServiceEchoDefault) IsCode(code int) bool {
	return o._statusCode == code
}

// Code gets the status code for the unannotated echo service echo default response
func (o *UnannotatedEchoServiceEchoDefault) Code() int {
	return o._statusCode
}

func (o *UnannotatedEchoServiceEchoDefault) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] UnannotatedEchoService_Echo default %s", o._statusCode, payload)
}

func (o *UnannotatedEchoServiceEchoDefault) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/echo/{id}][%d] UnannotatedEchoService_Echo default %s", o._statusCode, payload)
}

func (o *UnannotatedEchoServiceEchoDefault) GetPayload() *models.RPCStatus {
	return o.Payload
}

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

	o.Payload = new(models.RPCStatus)

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

	return nil
}
