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

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

// PostPurchaseOrdersReader is a Reader for the PostPurchaseOrders structure.
type PostPurchaseOrdersReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostPurchaseOrdersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewPostPurchaseOrdersOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewPostPurchaseOrdersUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewPostPurchaseOrdersForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewPostPurchaseOrdersNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewPostPurchaseOrdersUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewPostPurchaseOrdersInternalServerError()
		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())
	}
}

// NewPostPurchaseOrdersOK creates a PostPurchaseOrdersOK with default headers values
func NewPostPurchaseOrdersOK() *PostPurchaseOrdersOK {
	return &PostPurchaseOrdersOK{}
}

/*PostPurchaseOrdersOK handles this case with default header values.

Taxnexus Response with an array of Purchase Order objects
*/
type PostPurchaseOrdersOK struct {
	AccessControlAllowOrigin string

	CacheControl string

	Payload *ops_models.PurchaseOrderResponse
}

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

func (o *PostPurchaseOrdersOK) GetPayload() *ops_models.PurchaseOrderResponse {
	return o.Payload
}

func (o *PostPurchaseOrdersOK) 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.PurchaseOrderResponse)

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

	return nil
}

// NewPostPurchaseOrdersUnauthorized creates a PostPurchaseOrdersUnauthorized with default headers values
func NewPostPurchaseOrdersUnauthorized() *PostPurchaseOrdersUnauthorized {
	return &PostPurchaseOrdersUnauthorized{}
}

/*PostPurchaseOrdersUnauthorized handles this case with default header values.

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

	Payload *ops_models.Error
}

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

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

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

// NewPostPurchaseOrdersForbidden creates a PostPurchaseOrdersForbidden with default headers values
func NewPostPurchaseOrdersForbidden() *PostPurchaseOrdersForbidden {
	return &PostPurchaseOrdersForbidden{}
}

/*PostPurchaseOrdersForbidden handles this case with default header values.

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

	Payload *ops_models.Error
}

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

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

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

// NewPostPurchaseOrdersNotFound creates a PostPurchaseOrdersNotFound with default headers values
func NewPostPurchaseOrdersNotFound() *PostPurchaseOrdersNotFound {
	return &PostPurchaseOrdersNotFound{}
}

/*PostPurchaseOrdersNotFound handles this case with default header values.

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

	Payload *ops_models.Error
}

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

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

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

// NewPostPurchaseOrdersUnprocessableEntity creates a PostPurchaseOrdersUnprocessableEntity with default headers values
func NewPostPurchaseOrdersUnprocessableEntity() *PostPurchaseOrdersUnprocessableEntity {
	return &PostPurchaseOrdersUnprocessableEntity{}
}

/*PostPurchaseOrdersUnprocessableEntity handles this case with default header values.

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

	Payload *ops_models.Error
}

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

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

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

// NewPostPurchaseOrdersInternalServerError creates a PostPurchaseOrdersInternalServerError with default headers values
func NewPostPurchaseOrdersInternalServerError() *PostPurchaseOrdersInternalServerError {
	return &PostPurchaseOrdersInternalServerError{}
}

/*PostPurchaseOrdersInternalServerError handles this case with default header values.

Server Internal Error
*/
type PostPurchaseOrdersInternalServerError struct {
	AccessControlAllowOrigin string

	Payload *ops_models.Error
}

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

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

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