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

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

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

// PostCoursesReader is a Reader for the PostCourses structure.
type PostCoursesReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostCoursesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 201:
		result := NewPostCoursesCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 401:
		result := NewPostCoursesUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewPostCoursesForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewPostCoursesNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewPostCoursesUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewPostCoursesInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /courses] postCourses", response, response.Code())
	}
}

// NewPostCoursesCreated creates a PostCoursesCreated with default headers values
func NewPostCoursesCreated() *PostCoursesCreated {
	return &PostCoursesCreated{}
}

// PostCoursesCreated describes a response with status code 201, with default header values.
//
// Response from Salesforce
type PostCoursesCreated struct {
	Payload *sfgate_models.SalesforcePostResponse
}

// IsSuccess returns true when this post courses created response has a 2xx status code
func (o *PostCoursesCreated) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this post courses created response has a 3xx status code
func (o *PostCoursesCreated) IsRedirect() bool {
	return false
}

// IsClientError returns true when this post courses created response has a 4xx status code
func (o *PostCoursesCreated) IsClientError() bool {
	return false
}

// IsServerError returns true when this post courses created response has a 5xx status code
func (o *PostCoursesCreated) IsServerError() bool {
	return false
}

// IsCode returns true when this post courses created response a status code equal to that given
func (o *PostCoursesCreated) IsCode(code int) bool {
	return code == 201
}

// Code gets the status code for the post courses created response
func (o *PostCoursesCreated) Code() int {
	return 201
}

func (o *PostCoursesCreated) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesCreated %s", 201, payload)
}

func (o *PostCoursesCreated) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesCreated %s", 201, payload)
}

func (o *PostCoursesCreated) GetPayload() *sfgate_models.SalesforcePostResponse {
	return o.Payload
}

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

	o.Payload = new(sfgate_models.SalesforcePostResponse)

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

	return nil
}

// NewPostCoursesUnauthorized creates a PostCoursesUnauthorized with default headers values
func NewPostCoursesUnauthorized() *PostCoursesUnauthorized {
	return &PostCoursesUnauthorized{}
}

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

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

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

// IsClientError returns true when this post courses unauthorized response has a 4xx status code
func (o *PostCoursesUnauthorized) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the post courses unauthorized response
func (o *PostCoursesUnauthorized) Code() int {
	return 401
}

func (o *PostCoursesUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesUnauthorized %s", 401, payload)
}

func (o *PostCoursesUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesUnauthorized %s", 401, payload)
}

func (o *PostCoursesUnauthorized) GetPayload() *sfgate_models.Error {
	return o.Payload
}

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

	o.Payload = new(sfgate_models.Error)

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

	return nil
}

// NewPostCoursesForbidden creates a PostCoursesForbidden with default headers values
func NewPostCoursesForbidden() *PostCoursesForbidden {
	return &PostCoursesForbidden{}
}

// PostCoursesForbidden describes a response with status code 403, with default header values.
//
// Access forbidden, account lacks access
type PostCoursesForbidden struct {
	Payload *sfgate_models.Error
}

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

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

// IsClientError returns true when this post courses forbidden response has a 4xx status code
func (o *PostCoursesForbidden) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the post courses forbidden response
func (o *PostCoursesForbidden) Code() int {
	return 403
}

func (o *PostCoursesForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesForbidden %s", 403, payload)
}

func (o *PostCoursesForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesForbidden %s", 403, payload)
}

func (o *PostCoursesForbidden) GetPayload() *sfgate_models.Error {
	return o.Payload
}

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

	o.Payload = new(sfgate_models.Error)

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

	return nil
}

// NewPostCoursesNotFound creates a PostCoursesNotFound with default headers values
func NewPostCoursesNotFound() *PostCoursesNotFound {
	return &PostCoursesNotFound{}
}

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

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

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

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

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

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

// Code gets the status code for the post courses not found response
func (o *PostCoursesNotFound) Code() int {
	return 404
}

func (o *PostCoursesNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesNotFound %s", 404, payload)
}

func (o *PostCoursesNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesNotFound %s", 404, payload)
}

func (o *PostCoursesNotFound) GetPayload() *sfgate_models.Error {
	return o.Payload
}

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

	o.Payload = new(sfgate_models.Error)

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

	return nil
}

// NewPostCoursesUnprocessableEntity creates a PostCoursesUnprocessableEntity with default headers values
func NewPostCoursesUnprocessableEntity() *PostCoursesUnprocessableEntity {
	return &PostCoursesUnprocessableEntity{}
}

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

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

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

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

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

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

// Code gets the status code for the post courses unprocessable entity response
func (o *PostCoursesUnprocessableEntity) Code() int {
	return 422
}

func (o *PostCoursesUnprocessableEntity) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesUnprocessableEntity %s", 422, payload)
}

func (o *PostCoursesUnprocessableEntity) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesUnprocessableEntity %s", 422, payload)
}

func (o *PostCoursesUnprocessableEntity) GetPayload() *sfgate_models.Error {
	return o.Payload
}

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

	o.Payload = new(sfgate_models.Error)

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

	return nil
}

// NewPostCoursesInternalServerError creates a PostCoursesInternalServerError with default headers values
func NewPostCoursesInternalServerError() *PostCoursesInternalServerError {
	return &PostCoursesInternalServerError{}
}

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

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

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

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

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

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

// Code gets the status code for the post courses internal server error response
func (o *PostCoursesInternalServerError) Code() int {
	return 500
}

func (o *PostCoursesInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesInternalServerError %s", 500, payload)
}

func (o *PostCoursesInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /courses][%d] postCoursesInternalServerError %s", 500, payload)
}

func (o *PostCoursesInternalServerError) GetPayload() *sfgate_models.Error {
	return o.Payload
}

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

	o.Payload = new(sfgate_models.Error)

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

	return nil
}
