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

// GetObservationsReader is a Reader for the GetObservations structure.
type GetObservationsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetObservationsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewGetObservationsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewGetObservationsUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewGetObservationsForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewGetObservationsNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewGetObservationsUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewGetObservationsInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /observations] getObservations", response, response.Code())
	}
}

// NewGetObservationsOK creates a GetObservationsOK with default headers values
func NewGetObservationsOK() *GetObservationsOK {
	return &GetObservationsOK{}
}

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

// IsSuccess returns true when this get observations o k response has a 2xx status code
func (o *GetObservationsOK) IsSuccess() bool {
	return true
}

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

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

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

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

// Code gets the status code for the get observations o k response
func (o *GetObservationsOK) Code() int {
	return 200
}

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

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

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

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

// NewGetObservationsUnauthorized creates a GetObservationsUnauthorized with default headers values
func NewGetObservationsUnauthorized() *GetObservationsUnauthorized {
	return &GetObservationsUnauthorized{}
}

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

	Payload *research_models.Error
}

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

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

// IsClientError returns true when this get observations unauthorized response has a 4xx status code
func (o *GetObservationsUnauthorized) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the get observations unauthorized response
func (o *GetObservationsUnauthorized) Code() int {
	return 401
}

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

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

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

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

// NewGetObservationsForbidden creates a GetObservationsForbidden with default headers values
func NewGetObservationsForbidden() *GetObservationsForbidden {
	return &GetObservationsForbidden{}
}

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

	Payload *research_models.Error
}

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

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

// IsClientError returns true when this get observations forbidden response has a 4xx status code
func (o *GetObservationsForbidden) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the get observations forbidden response
func (o *GetObservationsForbidden) Code() int {
	return 403
}

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

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

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

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

// NewGetObservationsNotFound creates a GetObservationsNotFound with default headers values
func NewGetObservationsNotFound() *GetObservationsNotFound {
	return &GetObservationsNotFound{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

// Code gets the status code for the get observations not found response
func (o *GetObservationsNotFound) Code() int {
	return 404
}

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

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

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

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

// NewGetObservationsUnprocessableEntity creates a GetObservationsUnprocessableEntity with default headers values
func NewGetObservationsUnprocessableEntity() *GetObservationsUnprocessableEntity {
	return &GetObservationsUnprocessableEntity{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

// Code gets the status code for the get observations unprocessable entity response
func (o *GetObservationsUnprocessableEntity) Code() int {
	return 422
}

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

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

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

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

// NewGetObservationsInternalServerError creates a GetObservationsInternalServerError with default headers values
func NewGetObservationsInternalServerError() *GetObservationsInternalServerError {
	return &GetObservationsInternalServerError{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

// Code gets the status code for the get observations internal server error response
func (o *GetObservationsInternalServerError) Code() int {
	return 500
}

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

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

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

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