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

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

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

// GetCompaniesReader is a Reader for the GetCompanies structure.
type GetCompaniesReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetCompaniesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewGetCompaniesOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewGetCompaniesUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewGetCompaniesForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewGetCompaniesNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewGetCompaniesUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewGetCompaniesInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /companies] getCompanies", response, response.Code())
	}
}

// NewGetCompaniesOK creates a GetCompaniesOK with default headers values
func NewGetCompaniesOK() *GetCompaniesOK {
	return &GetCompaniesOK{}
}

// GetCompaniesOK describes a response with status code 200, with default header values.
//
// The SalesforceDevops.net Company Object
type GetCompaniesOK struct {
	Payload *plex_models.CompanyResponse
}

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

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

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

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

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

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

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

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

func (o *GetCompaniesOK) GetPayload() *plex_models.CompanyResponse {
	return o.Payload
}

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

	o.Payload = new(plex_models.CompanyResponse)

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

	return nil
}

// NewGetCompaniesUnauthorized creates a GetCompaniesUnauthorized with default headers values
func NewGetCompaniesUnauthorized() *GetCompaniesUnauthorized {
	return &GetCompaniesUnauthorized{}
}

// GetCompaniesUnauthorized describes a response with status code 401, with default header values.
//
// Access unauthorized, invalid API-KEY was used
type GetCompaniesUnauthorized struct {
	Payload *plex_models.Error
}

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

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

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

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

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

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

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

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

func (o *GetCompaniesUnauthorized) GetPayload() *plex_models.Error {
	return o.Payload
}

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

	o.Payload = new(plex_models.Error)

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

	return nil
}

// NewGetCompaniesForbidden creates a GetCompaniesForbidden with default headers values
func NewGetCompaniesForbidden() *GetCompaniesForbidden {
	return &GetCompaniesForbidden{}
}

// GetCompaniesForbidden describes a response with status code 403, with default header values.
//
// Access forbidden, Company lacks access
type GetCompaniesForbidden struct {
	Payload *plex_models.Error
}

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

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

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

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

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

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

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

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

func (o *GetCompaniesForbidden) GetPayload() *plex_models.Error {
	return o.Payload
}

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

	o.Payload = new(plex_models.Error)

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

	return nil
}

// NewGetCompaniesNotFound creates a GetCompaniesNotFound with default headers values
func NewGetCompaniesNotFound() *GetCompaniesNotFound {
	return &GetCompaniesNotFound{}
}

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

	Payload *plex_models.Error
}

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

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

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

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

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

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

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

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

func (o *GetCompaniesNotFound) GetPayload() *plex_models.Error {
	return o.Payload
}

func (o *GetCompaniesNotFound) 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(plex_models.Error)

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

	return nil
}

// NewGetCompaniesUnprocessableEntity creates a GetCompaniesUnprocessableEntity with default headers values
func NewGetCompaniesUnprocessableEntity() *GetCompaniesUnprocessableEntity {
	return &GetCompaniesUnprocessableEntity{}
}

// GetCompaniesUnprocessableEntity describes a response with status code 422, with default header values.
//
// Unprocessable Entity, likely a bad parameter
type GetCompaniesUnprocessableEntity struct {
	Payload *plex_models.Error
}

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

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

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

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

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

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

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

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

func (o *GetCompaniesUnprocessableEntity) GetPayload() *plex_models.Error {
	return o.Payload
}

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

	o.Payload = new(plex_models.Error)

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

	return nil
}

// NewGetCompaniesInternalServerError creates a GetCompaniesInternalServerError with default headers values
func NewGetCompaniesInternalServerError() *GetCompaniesInternalServerError {
	return &GetCompaniesInternalServerError{}
}

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

	Payload *plex_models.Error
}

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

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

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

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

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

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

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

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

func (o *GetCompaniesInternalServerError) GetPayload() *plex_models.Error {
	return o.Payload
}

func (o *GetCompaniesInternalServerError) 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(plex_models.Error)

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

	return nil
}
