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

package a_bit_of_everything

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

// ABitOfEverythingServiceCreateBookReader is a Reader for the ABitOfEverythingServiceCreateBook structure.
type ABitOfEverythingServiceCreateBookReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *ABitOfEverythingServiceCreateBookReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewABitOfEverythingServiceCreateBookOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewABitOfEverythingServiceCreateBookForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewABitOfEverythingServiceCreateBookNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 418:
		result := NewABitOfEverythingServiceCreateBookIMATeapot()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewABitOfEverythingServiceCreateBookInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		result := NewABitOfEverythingServiceCreateBookDefault(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
	}
}

// NewABitOfEverythingServiceCreateBookOK creates a ABitOfEverythingServiceCreateBookOK with default headers values
func NewABitOfEverythingServiceCreateBookOK() *ABitOfEverythingServiceCreateBookOK {
	return &ABitOfEverythingServiceCreateBookOK{}
}

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

A successful response.
*/
type ABitOfEverythingServiceCreateBookOK struct {
	Payload *models.ExamplepbBook
}

// IsSuccess returns true when this a bit of everything service create book o k response has a 2xx status code
func (o *ABitOfEverythingServiceCreateBookOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this a bit of everything service create book o k response has a 3xx status code
func (o *ABitOfEverythingServiceCreateBookOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service create book o k response has a 4xx status code
func (o *ABitOfEverythingServiceCreateBookOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this a bit of everything service create book o k response has a 5xx status code
func (o *ABitOfEverythingServiceCreateBookOK) IsServerError() bool {
	return false
}

// IsCode returns true when this a bit of everything service create book o k response a status code equal to that given
func (o *ABitOfEverythingServiceCreateBookOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the a bit of everything service create book o k response
func (o *ABitOfEverythingServiceCreateBookOK) Code() int {
	return 200
}

func (o *ABitOfEverythingServiceCreateBookOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookOK %s", 200, payload)
}

func (o *ABitOfEverythingServiceCreateBookOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookOK %s", 200, payload)
}

func (o *ABitOfEverythingServiceCreateBookOK) GetPayload() *models.ExamplepbBook {
	return o.Payload
}

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

	o.Payload = new(models.ExamplepbBook)

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

	return nil
}

// NewABitOfEverythingServiceCreateBookForbidden creates a ABitOfEverythingServiceCreateBookForbidden with default headers values
func NewABitOfEverythingServiceCreateBookForbidden() *ABitOfEverythingServiceCreateBookForbidden {
	return &ABitOfEverythingServiceCreateBookForbidden{}
}

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

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

// IsSuccess returns true when this a bit of everything service create book forbidden response has a 2xx status code
func (o *ABitOfEverythingServiceCreateBookForbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service create book forbidden response has a 3xx status code
func (o *ABitOfEverythingServiceCreateBookForbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service create book forbidden response has a 4xx status code
func (o *ABitOfEverythingServiceCreateBookForbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this a bit of everything service create book forbidden response has a 5xx status code
func (o *ABitOfEverythingServiceCreateBookForbidden) IsServerError() bool {
	return false
}

// IsCode returns true when this a bit of everything service create book forbidden response a status code equal to that given
func (o *ABitOfEverythingServiceCreateBookForbidden) IsCode(code int) bool {
	return code == 403
}

// Code gets the status code for the a bit of everything service create book forbidden response
func (o *ABitOfEverythingServiceCreateBookForbidden) Code() int {
	return 403
}

func (o *ABitOfEverythingServiceCreateBookForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookForbidden %s", 403, payload)
}

func (o *ABitOfEverythingServiceCreateBookForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookForbidden %s", 403, payload)
}

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

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

// NewABitOfEverythingServiceCreateBookNotFound creates a ABitOfEverythingServiceCreateBookNotFound with default headers values
func NewABitOfEverythingServiceCreateBookNotFound() *ABitOfEverythingServiceCreateBookNotFound {
	return &ABitOfEverythingServiceCreateBookNotFound{}
}

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

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

// IsSuccess returns true when this a bit of everything service create book not found response has a 2xx status code
func (o *ABitOfEverythingServiceCreateBookNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service create book not found response has a 3xx status code
func (o *ABitOfEverythingServiceCreateBookNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service create book not found response has a 4xx status code
func (o *ABitOfEverythingServiceCreateBookNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this a bit of everything service create book not found response has a 5xx status code
func (o *ABitOfEverythingServiceCreateBookNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this a bit of everything service create book not found response a status code equal to that given
func (o *ABitOfEverythingServiceCreateBookNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the a bit of everything service create book not found response
func (o *ABitOfEverythingServiceCreateBookNotFound) Code() int {
	return 404
}

func (o *ABitOfEverythingServiceCreateBookNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookNotFound %s", 404, payload)
}

func (o *ABitOfEverythingServiceCreateBookNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookNotFound %s", 404, payload)
}

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

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

// NewABitOfEverythingServiceCreateBookIMATeapot creates a ABitOfEverythingServiceCreateBookIMATeapot with default headers values
func NewABitOfEverythingServiceCreateBookIMATeapot() *ABitOfEverythingServiceCreateBookIMATeapot {
	return &ABitOfEverythingServiceCreateBookIMATeapot{}
}

/*
ABitOfEverythingServiceCreateBookIMATeapot describes a response with status code 418, with default header values.

I'm a teapot.
*/
type ABitOfEverythingServiceCreateBookIMATeapot struct {
	Payload models.ExamplepbNumericEnum
}

// IsSuccess returns true when this a bit of everything service create book i m a teapot response has a 2xx status code
func (o *ABitOfEverythingServiceCreateBookIMATeapot) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service create book i m a teapot response has a 3xx status code
func (o *ABitOfEverythingServiceCreateBookIMATeapot) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service create book i m a teapot response has a 4xx status code
func (o *ABitOfEverythingServiceCreateBookIMATeapot) IsClientError() bool {
	return true
}

// IsServerError returns true when this a bit of everything service create book i m a teapot response has a 5xx status code
func (o *ABitOfEverythingServiceCreateBookIMATeapot) IsServerError() bool {
	return false
}

// IsCode returns true when this a bit of everything service create book i m a teapot response a status code equal to that given
func (o *ABitOfEverythingServiceCreateBookIMATeapot) IsCode(code int) bool {
	return code == 418
}

// Code gets the status code for the a bit of everything service create book i m a teapot response
func (o *ABitOfEverythingServiceCreateBookIMATeapot) Code() int {
	return 418
}

func (o *ABitOfEverythingServiceCreateBookIMATeapot) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookIMATeapot %s", 418, payload)
}

func (o *ABitOfEverythingServiceCreateBookIMATeapot) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookIMATeapot %s", 418, payload)
}

func (o *ABitOfEverythingServiceCreateBookIMATeapot) GetPayload() models.ExamplepbNumericEnum {
	return o.Payload
}

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

// NewABitOfEverythingServiceCreateBookInternalServerError creates a ABitOfEverythingServiceCreateBookInternalServerError with default headers values
func NewABitOfEverythingServiceCreateBookInternalServerError() *ABitOfEverythingServiceCreateBookInternalServerError {
	return &ABitOfEverythingServiceCreateBookInternalServerError{}
}

/*
ABitOfEverythingServiceCreateBookInternalServerError describes a response with status code 500, with default header values.

Server error
*/
type ABitOfEverythingServiceCreateBookInternalServerError struct {
	Payload *models.ExamplepbErrorResponse
}

// IsSuccess returns true when this a bit of everything service create book internal server error response has a 2xx status code
func (o *ABitOfEverythingServiceCreateBookInternalServerError) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service create book internal server error response has a 3xx status code
func (o *ABitOfEverythingServiceCreateBookInternalServerError) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service create book internal server error response has a 4xx status code
func (o *ABitOfEverythingServiceCreateBookInternalServerError) IsClientError() bool {
	return false
}

// IsServerError returns true when this a bit of everything service create book internal server error response has a 5xx status code
func (o *ABitOfEverythingServiceCreateBookInternalServerError) IsServerError() bool {
	return true
}

// IsCode returns true when this a bit of everything service create book internal server error response a status code equal to that given
func (o *ABitOfEverythingServiceCreateBookInternalServerError) IsCode(code int) bool {
	return code == 500
}

// Code gets the status code for the a bit of everything service create book internal server error response
func (o *ABitOfEverythingServiceCreateBookInternalServerError) Code() int {
	return 500
}

func (o *ABitOfEverythingServiceCreateBookInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookInternalServerError %s", 500, payload)
}

func (o *ABitOfEverythingServiceCreateBookInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/{parent}/books][%d] aBitOfEverythingServiceCreateBookInternalServerError %s", 500, payload)
}

func (o *ABitOfEverythingServiceCreateBookInternalServerError) GetPayload() *models.ExamplepbErrorResponse {
	return o.Payload
}

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

	o.Payload = new(models.ExamplepbErrorResponse)

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

	return nil
}

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

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

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

	Payload *models.GoogleRPCStatus
}

// IsSuccess returns true when this a bit of everything service create book default response has a 2xx status code
func (o *ABitOfEverythingServiceCreateBookDefault) IsSuccess() bool {
	return o._statusCode/100 == 2
}

// IsRedirect returns true when this a bit of everything service create book default response has a 3xx status code
func (o *ABitOfEverythingServiceCreateBookDefault) IsRedirect() bool {
	return o._statusCode/100 == 3
}

// IsClientError returns true when this a bit of everything service create book default response has a 4xx status code
func (o *ABitOfEverythingServiceCreateBookDefault) IsClientError() bool {
	return o._statusCode/100 == 4
}

// IsServerError returns true when this a bit of everything service create book default response has a 5xx status code
func (o *ABitOfEverythingServiceCreateBookDefault) IsServerError() bool {
	return o._statusCode/100 == 5
}

// IsCode returns true when this a bit of everything service create book default response a status code equal to that given
func (o *ABitOfEverythingServiceCreateBookDefault) IsCode(code int) bool {
	return o._statusCode == code
}

// Code gets the status code for the a bit of everything service create book default response
func (o *ABitOfEverythingServiceCreateBookDefault) Code() int {
	return o._statusCode
}

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

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

func (o *ABitOfEverythingServiceCreateBookDefault) GetPayload() *models.GoogleRPCStatus {
	return o.Payload
}

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

	o.Payload = new(models.GoogleRPCStatus)

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

	return nil
}
