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

// GetPurchaseOrdersReader is a Reader for the GetPurchaseOrders structure.
type GetPurchaseOrdersReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetPurchaseOrdersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetPurchaseOrdersOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewGetPurchaseOrdersUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewGetPurchaseOrdersForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewGetPurchaseOrdersNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewGetPurchaseOrdersUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewGetPurchaseOrdersInternalServerError()
		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())
	}
}

// NewGetPurchaseOrdersOK creates a GetPurchaseOrdersOK with default headers values
func NewGetPurchaseOrdersOK() *GetPurchaseOrdersOK {
	return &GetPurchaseOrdersOK{}
}

/*GetPurchaseOrdersOK handles this case with default header values.

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

	CacheControl string

	Payload *ops_models.PurchaseOrderResponse
}

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

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

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

// NewGetPurchaseOrdersUnauthorized creates a GetPurchaseOrdersUnauthorized with default headers values
func NewGetPurchaseOrdersUnauthorized() *GetPurchaseOrdersUnauthorized {
	return &GetPurchaseOrdersUnauthorized{}
}

/*GetPurchaseOrdersUnauthorized handles this case with default header values.

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

	Payload *ops_models.Error
}

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

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

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

// NewGetPurchaseOrdersForbidden creates a GetPurchaseOrdersForbidden with default headers values
func NewGetPurchaseOrdersForbidden() *GetPurchaseOrdersForbidden {
	return &GetPurchaseOrdersForbidden{}
}

/*GetPurchaseOrdersForbidden handles this case with default header values.

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

	Payload *ops_models.Error
}

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

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

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

// NewGetPurchaseOrdersNotFound creates a GetPurchaseOrdersNotFound with default headers values
func NewGetPurchaseOrdersNotFound() *GetPurchaseOrdersNotFound {
	return &GetPurchaseOrdersNotFound{}
}

/*GetPurchaseOrdersNotFound handles this case with default header values.

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

	Payload *ops_models.Error
}

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

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

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

// NewGetPurchaseOrdersUnprocessableEntity creates a GetPurchaseOrdersUnprocessableEntity with default headers values
func NewGetPurchaseOrdersUnprocessableEntity() *GetPurchaseOrdersUnprocessableEntity {
	return &GetPurchaseOrdersUnprocessableEntity{}
}

/*GetPurchaseOrdersUnprocessableEntity handles this case with default header values.

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

	Payload *ops_models.Error
}

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

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

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

// NewGetPurchaseOrdersInternalServerError creates a GetPurchaseOrdersInternalServerError with default headers values
func NewGetPurchaseOrdersInternalServerError() *GetPurchaseOrdersInternalServerError {
	return &GetPurchaseOrdersInternalServerError{}
}

/*GetPurchaseOrdersInternalServerError handles this case with default header values.

Server Internal Error
*/
type GetPurchaseOrdersInternalServerError struct {
	AccessControlAllowOrigin string

	Payload *ops_models.Error
}

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

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

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