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

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

// PostContactsReader is a Reader for the PostContacts structure.
type PostContactsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostContactsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewPostContactsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewPostContactsUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewPostContactsForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewPostContactsNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewPostContactsUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewPostContactsInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /contacts] postContacts", response, response.Code())
	}
}

// NewPostContactsOK creates a PostContactsOK with default headers values
func NewPostContactsOK() *PostContactsOK {
	return &PostContactsOK{}
}

// PostContactsOK describes a response with status code 200, with default header values.
//
// Response with an array of Contact objects
type PostContactsOK struct {
	AccessControlAllowOrigin string
	CacheControl             string

	Payload *crm_models.ContactResponse
}

// IsSuccess returns true when this post contacts o k response has a 2xx status code
func (o *PostContactsOK) IsSuccess() bool {
	return true
}

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

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

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

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

// Code gets the status code for the post contacts o k response
func (o *PostContactsOK) Code() int {
	return 200
}

func (o *PostContactsOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsOK %s", 200, payload)
}

func (o *PostContactsOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsOK %s", 200, payload)
}

func (o *PostContactsOK) GetPayload() *crm_models.ContactResponse {
	return o.Payload
}

func (o *PostContactsOK) 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.ContactResponse)

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

	return nil
}

// NewPostContactsUnauthorized creates a PostContactsUnauthorized with default headers values
func NewPostContactsUnauthorized() *PostContactsUnauthorized {
	return &PostContactsUnauthorized{}
}

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

	Payload *crm_models.Error
}

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

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

// IsClientError returns true when this post contacts unauthorized response has a 4xx status code
func (o *PostContactsUnauthorized) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the post contacts unauthorized response
func (o *PostContactsUnauthorized) Code() int {
	return 401
}

func (o *PostContactsUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsUnauthorized %s", 401, payload)
}

func (o *PostContactsUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsUnauthorized %s", 401, payload)
}

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

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

// NewPostContactsForbidden creates a PostContactsForbidden with default headers values
func NewPostContactsForbidden() *PostContactsForbidden {
	return &PostContactsForbidden{}
}

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

	Payload *crm_models.Error
}

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

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

// IsClientError returns true when this post contacts forbidden response has a 4xx status code
func (o *PostContactsForbidden) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the post contacts forbidden response
func (o *PostContactsForbidden) Code() int {
	return 403
}

func (o *PostContactsForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsForbidden %s", 403, payload)
}

func (o *PostContactsForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsForbidden %s", 403, payload)
}

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

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

// NewPostContactsNotFound creates a PostContactsNotFound with default headers values
func NewPostContactsNotFound() *PostContactsNotFound {
	return &PostContactsNotFound{}
}

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

	Payload *crm_models.Error
}

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

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

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

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

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

// Code gets the status code for the post contacts not found response
func (o *PostContactsNotFound) Code() int {
	return 404
}

func (o *PostContactsNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsNotFound %s", 404, payload)
}

func (o *PostContactsNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsNotFound %s", 404, payload)
}

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

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

// NewPostContactsUnprocessableEntity creates a PostContactsUnprocessableEntity with default headers values
func NewPostContactsUnprocessableEntity() *PostContactsUnprocessableEntity {
	return &PostContactsUnprocessableEntity{}
}

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

	Payload *crm_models.Error
}

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

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

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

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

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

// Code gets the status code for the post contacts unprocessable entity response
func (o *PostContactsUnprocessableEntity) Code() int {
	return 422
}

func (o *PostContactsUnprocessableEntity) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsUnprocessableEntity %s", 422, payload)
}

func (o *PostContactsUnprocessableEntity) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsUnprocessableEntity %s", 422, payload)
}

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

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

// NewPostContactsInternalServerError creates a PostContactsInternalServerError with default headers values
func NewPostContactsInternalServerError() *PostContactsInternalServerError {
	return &PostContactsInternalServerError{}
}

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

	Payload *crm_models.Error
}

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

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

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

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

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

// Code gets the status code for the post contacts internal server error response
func (o *PostContactsInternalServerError) Code() int {
	return 500
}

func (o *PostContactsInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsInternalServerError %s", 500, payload)
}

func (o *PostContactsInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /contacts][%d] postContactsInternalServerError %s", 500, payload)
}

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

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