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

// 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/ops/ops_models"
)

// PostProductsReader is a Reader for the PostProducts structure.
type PostProductsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostProductsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewPostProductsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewPostProductsUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewPostProductsForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewPostProductsNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewPostProductsUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewPostProductsInternalServerError()
		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())
	}
}

// NewPostProductsOK creates a PostProductsOK with default headers values
func NewPostProductsOK() *PostProductsOK {
	return &PostProductsOK{}
}

/*PostProductsOK handles this case with default header values.

Taxnexus Response with an array of Product objects
*/
type PostProductsOK struct {
	AccessControlAllowOrigin string

	CacheControl string

	Payload *ops_models.ProductResponse
}

func (o *PostProductsOK) Error() string {
	return fmt.Sprintf("[POST /products][%d] postProductsOK  %+v", 200, o.Payload)
}

func (o *PostProductsOK) GetPayload() *ops_models.ProductResponse {
	return o.Payload
}

func (o *PostProductsOK) 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")

	o.Payload = new(ops_models.ProductResponse)

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

	return nil
}

// NewPostProductsUnauthorized creates a PostProductsUnauthorized with default headers values
func NewPostProductsUnauthorized() *PostProductsUnauthorized {
	return &PostProductsUnauthorized{}
}

/*PostProductsUnauthorized handles this case with default header values.

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

	Payload *ops_models.Error
}

func (o *PostProductsUnauthorized) Error() string {
	return fmt.Sprintf("[POST /products][%d] postProductsUnauthorized  %+v", 401, o.Payload)
}

func (o *PostProductsUnauthorized) GetPayload() *ops_models.Error {
	return o.Payload
}

func (o *PostProductsUnauthorized) 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(ops_models.Error)

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

	return nil
}

// NewPostProductsForbidden creates a PostProductsForbidden with default headers values
func NewPostProductsForbidden() *PostProductsForbidden {
	return &PostProductsForbidden{}
}

/*PostProductsForbidden handles this case with default header values.

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

	Payload *ops_models.Error
}

func (o *PostProductsForbidden) Error() string {
	return fmt.Sprintf("[POST /products][%d] postProductsForbidden  %+v", 403, o.Payload)
}

func (o *PostProductsForbidden) GetPayload() *ops_models.Error {
	return o.Payload
}

func (o *PostProductsForbidden) 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(ops_models.Error)

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

	return nil
}

// NewPostProductsNotFound creates a PostProductsNotFound with default headers values
func NewPostProductsNotFound() *PostProductsNotFound {
	return &PostProductsNotFound{}
}

/*PostProductsNotFound handles this case with default header values.

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

	Payload *ops_models.Error
}

func (o *PostProductsNotFound) Error() string {
	return fmt.Sprintf("[POST /products][%d] postProductsNotFound  %+v", 404, o.Payload)
}

func (o *PostProductsNotFound) GetPayload() *ops_models.Error {
	return o.Payload
}

func (o *PostProductsNotFound) 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(ops_models.Error)

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

	return nil
}

// NewPostProductsUnprocessableEntity creates a PostProductsUnprocessableEntity with default headers values
func NewPostProductsUnprocessableEntity() *PostProductsUnprocessableEntity {
	return &PostProductsUnprocessableEntity{}
}

/*PostProductsUnprocessableEntity handles this case with default header values.

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

	Payload *ops_models.Error
}

func (o *PostProductsUnprocessableEntity) Error() string {
	return fmt.Sprintf("[POST /products][%d] postProductsUnprocessableEntity  %+v", 422, o.Payload)
}

func (o *PostProductsUnprocessableEntity) GetPayload() *ops_models.Error {
	return o.Payload
}

func (o *PostProductsUnprocessableEntity) 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(ops_models.Error)

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

	return nil
}

// NewPostProductsInternalServerError creates a PostProductsInternalServerError with default headers values
func NewPostProductsInternalServerError() *PostProductsInternalServerError {
	return &PostProductsInternalServerError{}
}

/*PostProductsInternalServerError handles this case with default header values.

Server Internal Error
*/
type PostProductsInternalServerError struct {
	AccessControlAllowOrigin string

	Payload *ops_models.Error
}

func (o *PostProductsInternalServerError) Error() string {
	return fmt.Sprintf("[POST /products][%d] postProductsInternalServerError  %+v", 500, o.Payload)
}

func (o *PostProductsInternalServerError) GetPayload() *ops_models.Error {
	return o.Payload
}

func (o *PostProductsInternalServerError) 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(ops_models.Error)

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

	return nil
}
