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

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

// GetCompaniesObservableReader is a Reader for the GetCompaniesObservable structure.
type GetCompaniesObservableReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetCompaniesObservableReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetCompaniesObservableOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewGetCompaniesObservableUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewGetCompaniesObservableForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewGetCompaniesObservableNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewGetCompaniesObservableUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewGetCompaniesObservableInternalServerError()
		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())
	}
}

// NewGetCompaniesObservableOK creates a GetCompaniesObservableOK with default headers values
func NewGetCompaniesObservableOK() *GetCompaniesObservableOK {
	return &GetCompaniesObservableOK{}
}

/*GetCompaniesObservableOK handles this case with default header values.

Taxnexus Response with an array of Company objects
*/
type GetCompaniesObservableOK struct {
	AccessControlAllowOrigin string

	CacheControl string

	Payload []*crm_models.Company
}

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

func (o *GetCompaniesObservableOK) GetPayload() []*crm_models.Company {
	return o.Payload
}

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

// NewGetCompaniesObservableUnauthorized creates a GetCompaniesObservableUnauthorized with default headers values
func NewGetCompaniesObservableUnauthorized() *GetCompaniesObservableUnauthorized {
	return &GetCompaniesObservableUnauthorized{}
}

/*GetCompaniesObservableUnauthorized handles this case with default header values.

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

	Payload *crm_models.Error
}

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

func (o *GetCompaniesObservableUnauthorized) GetPayload() *crm_models.Error {
	return o.Payload
}

func (o *GetCompaniesObservableUnauthorized) 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(crm_models.Error)

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

	return nil
}

// NewGetCompaniesObservableForbidden creates a GetCompaniesObservableForbidden with default headers values
func NewGetCompaniesObservableForbidden() *GetCompaniesObservableForbidden {
	return &GetCompaniesObservableForbidden{}
}

/*GetCompaniesObservableForbidden handles this case with default header values.

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

	Payload *crm_models.Error
}

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

func (o *GetCompaniesObservableForbidden) GetPayload() *crm_models.Error {
	return o.Payload
}

func (o *GetCompaniesObservableForbidden) 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(crm_models.Error)

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

	return nil
}

// NewGetCompaniesObservableNotFound creates a GetCompaniesObservableNotFound with default headers values
func NewGetCompaniesObservableNotFound() *GetCompaniesObservableNotFound {
	return &GetCompaniesObservableNotFound{}
}

/*GetCompaniesObservableNotFound handles this case with default header values.

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

	Payload *crm_models.Error
}

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

func (o *GetCompaniesObservableNotFound) GetPayload() *crm_models.Error {
	return o.Payload
}

func (o *GetCompaniesObservableNotFound) 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(crm_models.Error)

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

	return nil
}

// NewGetCompaniesObservableUnprocessableEntity creates a GetCompaniesObservableUnprocessableEntity with default headers values
func NewGetCompaniesObservableUnprocessableEntity() *GetCompaniesObservableUnprocessableEntity {
	return &GetCompaniesObservableUnprocessableEntity{}
}

/*GetCompaniesObservableUnprocessableEntity handles this case with default header values.

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

	Payload *crm_models.Error
}

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

func (o *GetCompaniesObservableUnprocessableEntity) GetPayload() *crm_models.Error {
	return o.Payload
}

func (o *GetCompaniesObservableUnprocessableEntity) 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(crm_models.Error)

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

	return nil
}

// NewGetCompaniesObservableInternalServerError creates a GetCompaniesObservableInternalServerError with default headers values
func NewGetCompaniesObservableInternalServerError() *GetCompaniesObservableInternalServerError {
	return &GetCompaniesObservableInternalServerError{}
}

/*GetCompaniesObservableInternalServerError handles this case with default header values.

Server Internal Error
*/
type GetCompaniesObservableInternalServerError struct {
	AccessControlAllowOrigin string

	Payload *crm_models.Error
}

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

func (o *GetCompaniesObservableInternalServerError) GetPayload() *crm_models.Error {
	return o.Payload
}

func (o *GetCompaniesObservableInternalServerError) 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(crm_models.Error)

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

	return nil
}
