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

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

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

// PutTopicReader is a Reader for the PutTopic structure.
type PutTopicReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PutTopicReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewPutTopicOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewPutTopicUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewPutTopicForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewPutTopicNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 409:
		result := NewPutTopicConflict()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewPutTopicUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewPutTopicInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[PUT /topics] putTopic", response, response.Code())
	}
}

// NewPutTopicOK creates a PutTopicOK with default headers values
func NewPutTopicOK() *PutTopicOK {
	return &PutTopicOK{}
}

// PutTopicOK describes a response with status code 200, with default header values.
//
// Response with Topic objects
type PutTopicOK struct {
	Payload *research_models.TopicResponse
}

// IsSuccess returns true when this put topic o k response has a 2xx status code
func (o *PutTopicOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this put topic o k response has a 3xx status code
func (o *PutTopicOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this put topic o k response has a 4xx status code
func (o *PutTopicOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this put topic o k response has a 5xx status code
func (o *PutTopicOK) IsServerError() bool {
	return false
}

// IsCode returns true when this put topic o k response a status code equal to that given
func (o *PutTopicOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the put topic o k response
func (o *PutTopicOK) Code() int {
	return 200
}

func (o *PutTopicOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicOK %s", 200, payload)
}

func (o *PutTopicOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicOK %s", 200, payload)
}

func (o *PutTopicOK) GetPayload() *research_models.TopicResponse {
	return o.Payload
}

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

	o.Payload = new(research_models.TopicResponse)

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

	return nil
}

// NewPutTopicUnauthorized creates a PutTopicUnauthorized with default headers values
func NewPutTopicUnauthorized() *PutTopicUnauthorized {
	return &PutTopicUnauthorized{}
}

// PutTopicUnauthorized describes a response with status code 401, with default header values.
//
// Access unauthorized, invalid API-KEY was used
type PutTopicUnauthorized struct {
	AccessControlAllowOrigin string

	Payload *research_models.Error
}

// IsSuccess returns true when this put topic unauthorized response has a 2xx status code
func (o *PutTopicUnauthorized) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this put topic unauthorized response has a 3xx status code
func (o *PutTopicUnauthorized) IsRedirect() bool {
	return false
}

// IsClientError returns true when this put topic unauthorized response has a 4xx status code
func (o *PutTopicUnauthorized) IsClientError() bool {
	return true
}

// IsServerError returns true when this put topic unauthorized response has a 5xx status code
func (o *PutTopicUnauthorized) IsServerError() bool {
	return false
}

// IsCode returns true when this put topic unauthorized response a status code equal to that given
func (o *PutTopicUnauthorized) IsCode(code int) bool {
	return code == 401
}

// Code gets the status code for the put topic unauthorized response
func (o *PutTopicUnauthorized) Code() int {
	return 401
}

func (o *PutTopicUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicUnauthorized %s", 401, payload)
}

func (o *PutTopicUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicUnauthorized %s", 401, payload)
}

func (o *PutTopicUnauthorized) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutTopicUnauthorized) 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(research_models.Error)

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

	return nil
}

// NewPutTopicForbidden creates a PutTopicForbidden with default headers values
func NewPutTopicForbidden() *PutTopicForbidden {
	return &PutTopicForbidden{}
}

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

	Payload *research_models.Error
}

// IsSuccess returns true when this put topic forbidden response has a 2xx status code
func (o *PutTopicForbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this put topic forbidden response has a 3xx status code
func (o *PutTopicForbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this put topic forbidden response has a 4xx status code
func (o *PutTopicForbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this put topic forbidden response has a 5xx status code
func (o *PutTopicForbidden) IsServerError() bool {
	return false
}

// IsCode returns true when this put topic forbidden response a status code equal to that given
func (o *PutTopicForbidden) IsCode(code int) bool {
	return code == 403
}

// Code gets the status code for the put topic forbidden response
func (o *PutTopicForbidden) Code() int {
	return 403
}

func (o *PutTopicForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicForbidden %s", 403, payload)
}

func (o *PutTopicForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicForbidden %s", 403, payload)
}

func (o *PutTopicForbidden) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutTopicForbidden) 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(research_models.Error)

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

	return nil
}

// NewPutTopicNotFound creates a PutTopicNotFound with default headers values
func NewPutTopicNotFound() *PutTopicNotFound {
	return &PutTopicNotFound{}
}

// PutTopicNotFound describes a response with status code 404, with default header values.
//
// Resource was not found
type PutTopicNotFound struct {
	AccessControlAllowOrigin string

	Payload *research_models.Error
}

// IsSuccess returns true when this put topic not found response has a 2xx status code
func (o *PutTopicNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this put topic not found response has a 3xx status code
func (o *PutTopicNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this put topic not found response has a 4xx status code
func (o *PutTopicNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this put topic not found response has a 5xx status code
func (o *PutTopicNotFound) IsServerError() bool {
	return false
}

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

// Code gets the status code for the put topic not found response
func (o *PutTopicNotFound) Code() int {
	return 404
}

func (o *PutTopicNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicNotFound %s", 404, payload)
}

func (o *PutTopicNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicNotFound %s", 404, payload)
}

func (o *PutTopicNotFound) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutTopicNotFound) 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(research_models.Error)

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

	return nil
}

// NewPutTopicConflict creates a PutTopicConflict with default headers values
func NewPutTopicConflict() *PutTopicConflict {
	return &PutTopicConflict{}
}

// PutTopicConflict describes a response with status code 409, with default header values.
//
// Optimistic version conflict
type PutTopicConflict struct {
	Payload *research_models.Error
}

// IsSuccess returns true when this put topic conflict response has a 2xx status code
func (o *PutTopicConflict) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this put topic conflict response has a 3xx status code
func (o *PutTopicConflict) IsRedirect() bool {
	return false
}

// IsClientError returns true when this put topic conflict response has a 4xx status code
func (o *PutTopicConflict) IsClientError() bool {
	return true
}

// IsServerError returns true when this put topic conflict response has a 5xx status code
func (o *PutTopicConflict) IsServerError() bool {
	return false
}

// IsCode returns true when this put topic conflict response a status code equal to that given
func (o *PutTopicConflict) IsCode(code int) bool {
	return code == 409
}

// Code gets the status code for the put topic conflict response
func (o *PutTopicConflict) Code() int {
	return 409
}

func (o *PutTopicConflict) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicConflict %s", 409, payload)
}

func (o *PutTopicConflict) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicConflict %s", 409, payload)
}

func (o *PutTopicConflict) GetPayload() *research_models.Error {
	return o.Payload
}

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

	o.Payload = new(research_models.Error)

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

	return nil
}

// NewPutTopicUnprocessableEntity creates a PutTopicUnprocessableEntity with default headers values
func NewPutTopicUnprocessableEntity() *PutTopicUnprocessableEntity {
	return &PutTopicUnprocessableEntity{}
}

// PutTopicUnprocessableEntity describes a response with status code 422, with default header values.
//
// Unprocessable Entity, likely a bad parameter
type PutTopicUnprocessableEntity struct {
	AccessControlAllowOrigin string

	Payload *research_models.Error
}

// IsSuccess returns true when this put topic unprocessable entity response has a 2xx status code
func (o *PutTopicUnprocessableEntity) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this put topic unprocessable entity response has a 3xx status code
func (o *PutTopicUnprocessableEntity) IsRedirect() bool {
	return false
}

// IsClientError returns true when this put topic unprocessable entity response has a 4xx status code
func (o *PutTopicUnprocessableEntity) IsClientError() bool {
	return true
}

// IsServerError returns true when this put topic unprocessable entity response has a 5xx status code
func (o *PutTopicUnprocessableEntity) IsServerError() bool {
	return false
}

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

// Code gets the status code for the put topic unprocessable entity response
func (o *PutTopicUnprocessableEntity) Code() int {
	return 422
}

func (o *PutTopicUnprocessableEntity) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicUnprocessableEntity %s", 422, payload)
}

func (o *PutTopicUnprocessableEntity) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicUnprocessableEntity %s", 422, payload)
}

func (o *PutTopicUnprocessableEntity) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutTopicUnprocessableEntity) 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(research_models.Error)

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

	return nil
}

// NewPutTopicInternalServerError creates a PutTopicInternalServerError with default headers values
func NewPutTopicInternalServerError() *PutTopicInternalServerError {
	return &PutTopicInternalServerError{}
}

// PutTopicInternalServerError describes a response with status code 500, with default header values.
//
// Server Internal Error
type PutTopicInternalServerError struct {
	AccessControlAllowOrigin string

	Payload *research_models.Error
}

// IsSuccess returns true when this put topic internal server error response has a 2xx status code
func (o *PutTopicInternalServerError) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this put topic internal server error response has a 3xx status code
func (o *PutTopicInternalServerError) IsRedirect() bool {
	return false
}

// IsClientError returns true when this put topic internal server error response has a 4xx status code
func (o *PutTopicInternalServerError) IsClientError() bool {
	return false
}

// IsServerError returns true when this put topic internal server error response has a 5xx status code
func (o *PutTopicInternalServerError) IsServerError() bool {
	return true
}

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

// Code gets the status code for the put topic internal server error response
func (o *PutTopicInternalServerError) Code() int {
	return 500
}

func (o *PutTopicInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicInternalServerError %s", 500, payload)
}

func (o *PutTopicInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /topics][%d] putTopicInternalServerError %s", 500, payload)
}

func (o *PutTopicInternalServerError) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutTopicInternalServerError) 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(research_models.Error)

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

	return nil
}
