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

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

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

// PutFactorReader is a Reader for the PutFactor structure.
type PutFactorReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PutFactorReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewPutFactorOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewPutFactorUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewPutFactorForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewPutFactorNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 409:
		result := NewPutFactorConflict()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewPutFactorUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewPutFactorInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[PUT /factors] putFactor", response, response.Code())
	}
}

// NewPutFactorOK creates a PutFactorOK with default headers values
func NewPutFactorOK() *PutFactorOK {
	return &PutFactorOK{}
}

// PutFactorOK describes a response with status code 200, with default header values.
//
// Response with Factor objects
type PutFactorOK struct {
	Payload *research_models.FactorResponse
}

// IsSuccess returns true when this put factor o k response has a 2xx status code
func (o *PutFactorOK) IsSuccess() bool {
	return true
}

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

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

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

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

// Code gets the status code for the put factor o k response
func (o *PutFactorOK) Code() int {
	return 200
}

func (o *PutFactorOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorOK %s", 200, payload)
}

func (o *PutFactorOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorOK %s", 200, payload)
}

func (o *PutFactorOK) GetPayload() *research_models.FactorResponse {
	return o.Payload
}

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

	o.Payload = new(research_models.FactorResponse)

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

	return nil
}

// NewPutFactorUnauthorized creates a PutFactorUnauthorized with default headers values
func NewPutFactorUnauthorized() *PutFactorUnauthorized {
	return &PutFactorUnauthorized{}
}

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

	Payload *research_models.Error
}

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

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

// IsClientError returns true when this put factor unauthorized response has a 4xx status code
func (o *PutFactorUnauthorized) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the put factor unauthorized response
func (o *PutFactorUnauthorized) Code() int {
	return 401
}

func (o *PutFactorUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorUnauthorized %s", 401, payload)
}

func (o *PutFactorUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorUnauthorized %s", 401, payload)
}

func (o *PutFactorUnauthorized) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutFactorUnauthorized) 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(research_models.Error)

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

	return nil
}

// NewPutFactorForbidden creates a PutFactorForbidden with default headers values
func NewPutFactorForbidden() *PutFactorForbidden {
	return &PutFactorForbidden{}
}

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

	Payload *research_models.Error
}

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

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

// IsClientError returns true when this put factor forbidden response has a 4xx status code
func (o *PutFactorForbidden) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the put factor forbidden response
func (o *PutFactorForbidden) Code() int {
	return 403
}

func (o *PutFactorForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorForbidden %s", 403, payload)
}

func (o *PutFactorForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorForbidden %s", 403, payload)
}

func (o *PutFactorForbidden) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutFactorForbidden) 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(research_models.Error)

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

	return nil
}

// NewPutFactorNotFound creates a PutFactorNotFound with default headers values
func NewPutFactorNotFound() *PutFactorNotFound {
	return &PutFactorNotFound{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

// Code gets the status code for the put factor not found response
func (o *PutFactorNotFound) Code() int {
	return 404
}

func (o *PutFactorNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorNotFound %s", 404, payload)
}

func (o *PutFactorNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorNotFound %s", 404, payload)
}

func (o *PutFactorNotFound) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutFactorNotFound) 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(research_models.Error)

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

	return nil
}

// NewPutFactorConflict creates a PutFactorConflict with default headers values
func NewPutFactorConflict() *PutFactorConflict {
	return &PutFactorConflict{}
}

// PutFactorConflict describes a response with status code 409, with default header values.
//
// Optimistic version conflict
type PutFactorConflict struct {
	Payload *research_models.Error
}

// IsSuccess returns true when this put factor conflict response has a 2xx status code
func (o *PutFactorConflict) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this put factor conflict response has a 3xx status code
func (o *PutFactorConflict) IsRedirect() bool {
	return false
}

// IsClientError returns true when this put factor conflict response has a 4xx status code
func (o *PutFactorConflict) IsClientError() bool {
	return true
}

// IsServerError returns true when this put factor conflict response has a 5xx status code
func (o *PutFactorConflict) IsServerError() bool {
	return false
}

// IsCode returns true when this put factor conflict response a status code equal to that given
func (o *PutFactorConflict) IsCode(code int) bool {
	return code == 409
}

// Code gets the status code for the put factor conflict response
func (o *PutFactorConflict) Code() int {
	return 409
}

func (o *PutFactorConflict) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorConflict %s", 409, payload)
}

func (o *PutFactorConflict) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorConflict %s", 409, payload)
}

func (o *PutFactorConflict) GetPayload() *research_models.Error {
	return o.Payload
}

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

	o.Payload = new(research_models.Error)

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

	return nil
}

// NewPutFactorUnprocessableEntity creates a PutFactorUnprocessableEntity with default headers values
func NewPutFactorUnprocessableEntity() *PutFactorUnprocessableEntity {
	return &PutFactorUnprocessableEntity{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

// Code gets the status code for the put factor unprocessable entity response
func (o *PutFactorUnprocessableEntity) Code() int {
	return 422
}

func (o *PutFactorUnprocessableEntity) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorUnprocessableEntity %s", 422, payload)
}

func (o *PutFactorUnprocessableEntity) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorUnprocessableEntity %s", 422, payload)
}

func (o *PutFactorUnprocessableEntity) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutFactorUnprocessableEntity) 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(research_models.Error)

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

	return nil
}

// NewPutFactorInternalServerError creates a PutFactorInternalServerError with default headers values
func NewPutFactorInternalServerError() *PutFactorInternalServerError {
	return &PutFactorInternalServerError{}
}

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

	Payload *research_models.Error
}

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

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

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

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

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

// Code gets the status code for the put factor internal server error response
func (o *PutFactorInternalServerError) Code() int {
	return 500
}

func (o *PutFactorInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorInternalServerError %s", 500, payload)
}

func (o *PutFactorInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /factors][%d] putFactorInternalServerError %s", 500, payload)
}

func (o *PutFactorInternalServerError) GetPayload() *research_models.Error {
	return o.Payload
}

func (o *PutFactorInternalServerError) 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(research_models.Error)

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

	return nil
}
