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

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

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

// GetTemplatesReader is a Reader for the GetTemplates structure.
type GetTemplatesReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetTemplatesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewGetTemplatesOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewGetTemplatesUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewGetTemplatesForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewGetTemplatesNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewGetTemplatesUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewGetTemplatesInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /templates] getTemplates", response, response.Code())
	}
}

// NewGetTemplatesOK creates a GetTemplatesOK with default headers values
func NewGetTemplatesOK() *GetTemplatesOK {
	return &GetTemplatesOK{}
}

// GetTemplatesOK describes a response with status code 200, with default header values.
//
// Response with Template objects
type GetTemplatesOK struct {
	Payload *members_models.TemplateResponse
}

// IsSuccess returns true when this get templates o k response has a 2xx status code
func (o *GetTemplatesOK) IsSuccess() bool {
	return true
}

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

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

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

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

// Code gets the status code for the get templates o k response
func (o *GetTemplatesOK) Code() int {
	return 200
}

func (o *GetTemplatesOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesOK %s", 200, payload)
}

func (o *GetTemplatesOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesOK %s", 200, payload)
}

func (o *GetTemplatesOK) GetPayload() *members_models.TemplateResponse {
	return o.Payload
}

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

	o.Payload = new(members_models.TemplateResponse)

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

	return nil
}

// NewGetTemplatesUnauthorized creates a GetTemplatesUnauthorized with default headers values
func NewGetTemplatesUnauthorized() *GetTemplatesUnauthorized {
	return &GetTemplatesUnauthorized{}
}

// GetTemplatesUnauthorized describes a response with status code 401, with default header values.
//
// Access Unauthorized, invalid API-KEY was used
type GetTemplatesUnauthorized struct {
	Payload *members_models.Error
}

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

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

// IsClientError returns true when this get templates unauthorized response has a 4xx status code
func (o *GetTemplatesUnauthorized) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the get templates unauthorized response
func (o *GetTemplatesUnauthorized) Code() int {
	return 401
}

func (o *GetTemplatesUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesUnauthorized %s", 401, payload)
}

func (o *GetTemplatesUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesUnauthorized %s", 401, payload)
}

func (o *GetTemplatesUnauthorized) GetPayload() *members_models.Error {
	return o.Payload
}

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

	o.Payload = new(members_models.Error)

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

	return nil
}

// NewGetTemplatesForbidden creates a GetTemplatesForbidden with default headers values
func NewGetTemplatesForbidden() *GetTemplatesForbidden {
	return &GetTemplatesForbidden{}
}

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

	Payload *members_models.Error
}

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

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

// IsClientError returns true when this get templates forbidden response has a 4xx status code
func (o *GetTemplatesForbidden) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the get templates forbidden response
func (o *GetTemplatesForbidden) Code() int {
	return 403
}

func (o *GetTemplatesForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesForbidden %s", 403, payload)
}

func (o *GetTemplatesForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesForbidden %s", 403, payload)
}

func (o *GetTemplatesForbidden) GetPayload() *members_models.Error {
	return o.Payload
}

func (o *GetTemplatesForbidden) 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(members_models.Error)

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

	return nil
}

// NewGetTemplatesNotFound creates a GetTemplatesNotFound with default headers values
func NewGetTemplatesNotFound() *GetTemplatesNotFound {
	return &GetTemplatesNotFound{}
}

// GetTemplatesNotFound describes a response with status code 404, with default header values.
//
// Resource was not found
type GetTemplatesNotFound struct {
	Payload *members_models.Error
}

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

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

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

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

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

// Code gets the status code for the get templates not found response
func (o *GetTemplatesNotFound) Code() int {
	return 404
}

func (o *GetTemplatesNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesNotFound %s", 404, payload)
}

func (o *GetTemplatesNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesNotFound %s", 404, payload)
}

func (o *GetTemplatesNotFound) GetPayload() *members_models.Error {
	return o.Payload
}

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

	o.Payload = new(members_models.Error)

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

	return nil
}

// NewGetTemplatesUnprocessableEntity creates a GetTemplatesUnprocessableEntity with default headers values
func NewGetTemplatesUnprocessableEntity() *GetTemplatesUnprocessableEntity {
	return &GetTemplatesUnprocessableEntity{}
}

// GetTemplatesUnprocessableEntity describes a response with status code 422, with default header values.
//
// Unprocessable Entity, likely a bad parameter
type GetTemplatesUnprocessableEntity struct {
	Payload *members_models.Error
}

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

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

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

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

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

// Code gets the status code for the get templates unprocessable entity response
func (o *GetTemplatesUnprocessableEntity) Code() int {
	return 422
}

func (o *GetTemplatesUnprocessableEntity) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesUnprocessableEntity %s", 422, payload)
}

func (o *GetTemplatesUnprocessableEntity) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesUnprocessableEntity %s", 422, payload)
}

func (o *GetTemplatesUnprocessableEntity) GetPayload() *members_models.Error {
	return o.Payload
}

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

	o.Payload = new(members_models.Error)

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

	return nil
}

// NewGetTemplatesInternalServerError creates a GetTemplatesInternalServerError with default headers values
func NewGetTemplatesInternalServerError() *GetTemplatesInternalServerError {
	return &GetTemplatesInternalServerError{}
}

// GetTemplatesInternalServerError describes a response with status code 500, with default header values.
//
// Server Internal Error
type GetTemplatesInternalServerError struct {
	Payload *members_models.Error
}

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

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

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

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

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

// Code gets the status code for the get templates internal server error response
func (o *GetTemplatesInternalServerError) Code() int {
	return 500
}

func (o *GetTemplatesInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesInternalServerError %s", 500, payload)
}

func (o *GetTemplatesInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /templates][%d] getTemplatesInternalServerError %s", 500, payload)
}

func (o *GetTemplatesInternalServerError) GetPayload() *members_models.Error {
	return o.Payload
}

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

	o.Payload = new(members_models.Error)

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

	return nil
}
