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

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

// PutObservationReader is a Reader for the PutObservation structure.
type PutObservationReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PutObservationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewPutObservationOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewPutObservationUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewPutObservationForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewPutObservationNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 409:
		result := NewPutObservationConflict()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewPutObservationUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewPutObservationInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[PUT /observations] putObservation", response, response.Code())
	}
}

// NewPutObservationOK creates a PutObservationOK with default headers values
func NewPutObservationOK() *PutObservationOK {
	return &PutObservationOK{}
}

// PutObservationOK describes a response with status code 200, with default header values.
//
// Response with Observation objects
type PutObservationOK struct {
	Payload *research_models.ObservationResponse
}

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

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

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

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

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

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

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

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

func (o *PutObservationOK) GetPayload() *research_models.ObservationResponse {
	return o.Payload
}

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

	o.Payload = new(research_models.ObservationResponse)

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

	return nil
}

// NewPutObservationUnauthorized creates a PutObservationUnauthorized with default headers values
func NewPutObservationUnauthorized() *PutObservationUnauthorized {
	return &PutObservationUnauthorized{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

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

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

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

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

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

// NewPutObservationForbidden creates a PutObservationForbidden with default headers values
func NewPutObservationForbidden() *PutObservationForbidden {
	return &PutObservationForbidden{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

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

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

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

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

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

// NewPutObservationNotFound creates a PutObservationNotFound with default headers values
func NewPutObservationNotFound() *PutObservationNotFound {
	return &PutObservationNotFound{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

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

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

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

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

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

// NewPutObservationConflict creates a PutObservationConflict with default headers values
func NewPutObservationConflict() *PutObservationConflict {
	return &PutObservationConflict{}
}

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

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

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

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

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

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

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

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

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

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

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

// NewPutObservationUnprocessableEntity creates a PutObservationUnprocessableEntity with default headers values
func NewPutObservationUnprocessableEntity() *PutObservationUnprocessableEntity {
	return &PutObservationUnprocessableEntity{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

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

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

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

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

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

// NewPutObservationInternalServerError creates a PutObservationInternalServerError with default headers values
func NewPutObservationInternalServerError() *PutObservationInternalServerError {
	return &PutObservationInternalServerError{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

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

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

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

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

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