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

// All Code Copyright(c) 2018-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package product

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"fmt"
	"io"

	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"

	"github.com/taxnexus/go/lib/api/ops/ops_models"
)

// GetProductsObservableReader is a Reader for the GetProductsObservable structure.
type GetProductsObservableReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetProductsObservableReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetProductsObservableOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewGetProductsObservableUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewGetProductsObservableForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewGetProductsObservableNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewGetProductsObservableUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewGetProductsObservableInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result

	default:
		return nil, runtime.NewAPIError("unknown error", response, response.Code())
	}
}

// NewGetProductsObservableOK creates a GetProductsObservableOK with default headers values
func NewGetProductsObservableOK() *GetProductsObservableOK {
	return &GetProductsObservableOK{}
}

/*GetProductsObservableOK handles this case with default header values.

Simple array of products
*/
type GetProductsObservableOK struct {
	AccessControlAllowOrigin string

	CacheControl string

	Payload []*ops_models.Product
}

func (o *GetProductsObservableOK) Error() string {
	return fmt.Sprintf("[GET /products/observable][%d] getProductsObservableOK  %+v", 200, o.Payload)
}

func (o *GetProductsObservableOK) GetPayload() []*ops_models.Product {
	return o.Payload
}

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

	// response header Access-Control-Allow-Origin
	o.AccessControlAllowOrigin = response.GetHeader("Access-Control-Allow-Origin")

	// response header Cache-Control
	o.CacheControl = response.GetHeader("Cache-Control")

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

	return nil
}

// NewGetProductsObservableUnauthorized creates a GetProductsObservableUnauthorized with default headers values
func NewGetProductsObservableUnauthorized() *GetProductsObservableUnauthorized {
	return &GetProductsObservableUnauthorized{}
}

/*GetProductsObservableUnauthorized handles this case with default header values.

Access unauthorized, invalid API-KEY was used
*/
type GetProductsObservableUnauthorized struct {
	AccessControlAllowOrigin string

	Payload *ops_models.Error
}

func (o *GetProductsObservableUnauthorized) Error() string {
	return fmt.Sprintf("[GET /products/observable][%d] getProductsObservableUnauthorized  %+v", 401, o.Payload)
}

func (o *GetProductsObservableUnauthorized) GetPayload() *ops_models.Error {
	return o.Payload
}

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

	// response header Access-Control-Allow-Origin
	o.AccessControlAllowOrigin = response.GetHeader("Access-Control-Allow-Origin")

	o.Payload = new(ops_models.Error)

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

	return nil
}

// NewGetProductsObservableForbidden creates a GetProductsObservableForbidden with default headers values
func NewGetProductsObservableForbidden() *GetProductsObservableForbidden {
	return &GetProductsObservableForbidden{}
}

/*GetProductsObservableForbidden handles this case with default header values.

Access forbidden, account lacks access
*/
type GetProductsObservableForbidden struct {
	AccessControlAllowOrigin string

	Payload *ops_models.Error
}

func (o *GetProductsObservableForbidden) Error() string {
	return fmt.Sprintf("[GET /products/observable][%d] getProductsObservableForbidden  %+v", 403, o.Payload)
}

func (o *GetProductsObservableForbidden) GetPayload() *ops_models.Error {
	return o.Payload
}

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

	// response header Access-Control-Allow-Origin
	o.AccessControlAllowOrigin = response.GetHeader("Access-Control-Allow-Origin")

	o.Payload = new(ops_models.Error)

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

	return nil
}

// NewGetProductsObservableNotFound creates a GetProductsObservableNotFound with default headers values
func NewGetProductsObservableNotFound() *GetProductsObservableNotFound {
	return &GetProductsObservableNotFound{}
}

/*GetProductsObservableNotFound handles this case with default header values.

Resource was not found
*/
type GetProductsObservableNotFound struct {
	AccessControlAllowOrigin string

	Payload *ops_models.Error
}

func (o *GetProductsObservableNotFound) Error() string {
	return fmt.Sprintf("[GET /products/observable][%d] getProductsObservableNotFound  %+v", 404, o.Payload)
}

func (o *GetProductsObservableNotFound) GetPayload() *ops_models.Error {
	return o.Payload
}

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

	// response header Access-Control-Allow-Origin
	o.AccessControlAllowOrigin = response.GetHeader("Access-Control-Allow-Origin")

	o.Payload = new(ops_models.Error)

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

	return nil
}

// NewGetProductsObservableUnprocessableEntity creates a GetProductsObservableUnprocessableEntity with default headers values
func NewGetProductsObservableUnprocessableEntity() *GetProductsObservableUnprocessableEntity {
	return &GetProductsObservableUnprocessableEntity{}
}

/*GetProductsObservableUnprocessableEntity handles this case with default header values.

Unprocessable Entity, likely a bad parameter
*/
type GetProductsObservableUnprocessableEntity struct {
	AccessControlAllowOrigin string

	Payload *ops_models.Error
}

func (o *GetProductsObservableUnprocessableEntity) Error() string {
	return fmt.Sprintf("[GET /products/observable][%d] getProductsObservableUnprocessableEntity  %+v", 422, o.Payload)
}

func (o *GetProductsObservableUnprocessableEntity) GetPayload() *ops_models.Error {
	return o.Payload
}

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

	// response header Access-Control-Allow-Origin
	o.AccessControlAllowOrigin = response.GetHeader("Access-Control-Allow-Origin")

	o.Payload = new(ops_models.Error)

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

	return nil
}

// NewGetProductsObservableInternalServerError creates a GetProductsObservableInternalServerError with default headers values
func NewGetProductsObservableInternalServerError() *GetProductsObservableInternalServerError {
	return &GetProductsObservableInternalServerError{}
}

/*GetProductsObservableInternalServerError handles this case with default header values.

Server Internal Error
*/
type GetProductsObservableInternalServerError struct {
	AccessControlAllowOrigin string

	Payload *ops_models.Error
}

func (o *GetProductsObservableInternalServerError) Error() string {
	return fmt.Sprintf("[GET /products/observable][%d] getProductsObservableInternalServerError  %+v", 500, o.Payload)
}

func (o *GetProductsObservableInternalServerError) GetPayload() *ops_models.Error {
	return o.Payload
}

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

	// response header Access-Control-Allow-Origin
	o.AccessControlAllowOrigin = response.GetHeader("Access-Control-Allow-Origin")

	o.Payload = new(ops_models.Error)

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

	return nil
}
