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

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

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

// GetAssetsReader is a Reader for the GetAssets structure.
type GetAssetsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetAssetsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewGetAssetsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewGetAssetsUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewGetAssetsForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewGetAssetsNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewGetAssetsUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewGetAssetsInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /assets] getAssets", response, response.Code())
	}
}

// NewGetAssetsOK creates a GetAssetsOK with default headers values
func NewGetAssetsOK() *GetAssetsOK {
	return &GetAssetsOK{}
}

// GetAssetsOK describes a response with status code 200, with default header values.
//
// Response with Asset objects with Contacts
type GetAssetsOK struct {
	AccessControlAllowOrigin string
	CacheControl             string

	Payload *crm_models.AssetResponse
}

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

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

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

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

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

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

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

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

func (o *GetAssetsOK) GetPayload() *crm_models.AssetResponse {
	return o.Payload
}

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

	// hydrates response header Cache-Control
	hdrCacheControl := response.GetHeader("Cache-Control")

	if hdrCacheControl != "" {
		o.CacheControl = hdrCacheControl
	}

	o.Payload = new(crm_models.AssetResponse)

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

	return nil
}

// NewGetAssetsUnauthorized creates a GetAssetsUnauthorized with default headers values
func NewGetAssetsUnauthorized() *GetAssetsUnauthorized {
	return &GetAssetsUnauthorized{}
}

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

	Payload *crm_models.Error
}

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

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

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

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

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

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

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

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

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

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

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

	return nil
}

// NewGetAssetsForbidden creates a GetAssetsForbidden with default headers values
func NewGetAssetsForbidden() *GetAssetsForbidden {
	return &GetAssetsForbidden{}
}

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

	Payload *crm_models.Error
}

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

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

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

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

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

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

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

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

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

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

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

	return nil
}

// NewGetAssetsNotFound creates a GetAssetsNotFound with default headers values
func NewGetAssetsNotFound() *GetAssetsNotFound {
	return &GetAssetsNotFound{}
}

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

	Payload *crm_models.Error
}

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

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

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

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

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

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

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

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

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

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

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

	return nil
}

// NewGetAssetsUnprocessableEntity creates a GetAssetsUnprocessableEntity with default headers values
func NewGetAssetsUnprocessableEntity() *GetAssetsUnprocessableEntity {
	return &GetAssetsUnprocessableEntity{}
}

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

	Payload *crm_models.Error
}

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

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

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

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

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

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

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

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

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

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

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

	return nil
}

// NewGetAssetsInternalServerError creates a GetAssetsInternalServerError with default headers values
func NewGetAssetsInternalServerError() *GetAssetsInternalServerError {
	return &GetAssetsInternalServerError{}
}

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

	Payload *crm_models.Error
}

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

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

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

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

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

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

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

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

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

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

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

	return nil
}
