// 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"
)

// UnannotatedEchoServiceEchoBodyReader is a Reader for the UnannotatedEchoServiceEchoBody structure.
type UnannotatedEchoServiceEchoBodyReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *UnannotatedEchoServiceEchoBodyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewUnannotatedEchoServiceEchoBodyOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewUnannotatedEchoServiceEchoBodyForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewUnannotatedEchoServiceEchoBodyNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		result := NewUnannotatedEchoServiceEchoBodyDefault(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
	}
}

// NewUnannotatedEchoServiceEchoBodyOK creates a UnannotatedEchoServiceEchoBodyOK with default headers values
func NewUnannotatedEchoServiceEchoBodyOK() *UnannotatedEchoServiceEchoBodyOK {
	return &UnannotatedEchoServiceEchoBodyOK{}
}

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

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

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

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

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

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

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

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

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

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

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

func (o *UnannotatedEchoServiceEchoBodyOK) 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
}

// NewUnannotatedEchoServiceEchoBodyForbidden creates a UnannotatedEchoServiceEchoBodyForbidden with default headers values
func NewUnannotatedEchoServiceEchoBodyForbidden() *UnannotatedEchoServiceEchoBodyForbidden {
	return &UnannotatedEchoServiceEchoBodyForbidden{}
}

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

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

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

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

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

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

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

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

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

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

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

func (o *UnannotatedEchoServiceEchoBodyForbidden) 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
}

// NewUnannotatedEchoServiceEchoBodyNotFound creates a UnannotatedEchoServiceEchoBodyNotFound with default headers values
func NewUnannotatedEchoServiceEchoBodyNotFound() *UnannotatedEchoServiceEchoBodyNotFound {
	return &UnannotatedEchoServiceEchoBodyNotFound{}
}

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

Returned when the resource does not exist.
*/
type UnannotatedEchoServiceEchoBodyNotFound struct {
	Payload string
}

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

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

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

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

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

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

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

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

func (o *UnannotatedEchoServiceEchoBodyNotFound) GetPayload() string {
	return o.Payload
}

func (o *UnannotatedEchoServiceEchoBodyNotFound) 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
}

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

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

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

	Payload *models.RPCStatus
}

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

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

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

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

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

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

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

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

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

func (o *UnannotatedEchoServiceEchoBodyDefault) 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
}
