// Code generated by go-swagger; DO NOT EDIT.

package operations

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

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

	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"

	"github.com/fiskerinc/cloud-services/pkg/ota_api/models"
)

// PostCarupdateIDCancelReader is a Reader for the PostCarupdateIDCancel structure.
type PostCarupdateIDCancelReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostCarupdateIDCancelReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewPostCarupdateIDCancelOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewPostCarupdateIDCancelBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewPostCarupdateIDCancelUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewPostCarupdateIDCancelServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /carupdate/{id}/cancel] PostCarupdateIDCancel", response, response.Code())
	}
}

// NewPostCarupdateIDCancelOK creates a PostCarupdateIDCancelOK with default headers values
func NewPostCarupdateIDCancelOK() *PostCarupdateIDCancelOK {
	return &PostCarupdateIDCancelOK{}
}

/*
PostCarupdateIDCancelOK describes a response with status code 200, with default header values.

Request result
*/
type PostCarupdateIDCancelOK struct {
	Payload *models.CommonJSONMessage
}

// IsSuccess returns true when this post carupdate Id cancel o k response has a 2xx status code
func (o *PostCarupdateIDCancelOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this post carupdate Id cancel o k response has a 3xx status code
func (o *PostCarupdateIDCancelOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this post carupdate Id cancel o k response has a 4xx status code
func (o *PostCarupdateIDCancelOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this post carupdate Id cancel o k response has a 5xx status code
func (o *PostCarupdateIDCancelOK) IsServerError() bool {
	return false
}

// IsCode returns true when this post carupdate Id cancel o k response a status code equal to that given
func (o *PostCarupdateIDCancelOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the post carupdate Id cancel o k response
func (o *PostCarupdateIDCancelOK) Code() int {
	return 200
}

func (o *PostCarupdateIDCancelOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /carupdate/{id}/cancel][%d] postCarupdateIdCancelOK %s", 200, payload)
}

func (o *PostCarupdateIDCancelOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /carupdate/{id}/cancel][%d] postCarupdateIdCancelOK %s", 200, payload)
}

func (o *PostCarupdateIDCancelOK) GetPayload() *models.CommonJSONMessage {
	return o.Payload
}

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

	o.Payload = new(models.CommonJSONMessage)

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

	return nil
}

// NewPostCarupdateIDCancelBadRequest creates a PostCarupdateIDCancelBadRequest with default headers values
func NewPostCarupdateIDCancelBadRequest() *PostCarupdateIDCancelBadRequest {
	return &PostCarupdateIDCancelBadRequest{}
}

/*
PostCarupdateIDCancelBadRequest describes a response with status code 400, with default header values.

Bad request
*/
type PostCarupdateIDCancelBadRequest struct {
	Payload *models.CommonJSONError
}

// IsSuccess returns true when this post carupdate Id cancel bad request response has a 2xx status code
func (o *PostCarupdateIDCancelBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this post carupdate Id cancel bad request response has a 3xx status code
func (o *PostCarupdateIDCancelBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this post carupdate Id cancel bad request response has a 4xx status code
func (o *PostCarupdateIDCancelBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this post carupdate Id cancel bad request response has a 5xx status code
func (o *PostCarupdateIDCancelBadRequest) IsServerError() bool {
	return false
}

// IsCode returns true when this post carupdate Id cancel bad request response a status code equal to that given
func (o *PostCarupdateIDCancelBadRequest) IsCode(code int) bool {
	return code == 400
}

// Code gets the status code for the post carupdate Id cancel bad request response
func (o *PostCarupdateIDCancelBadRequest) Code() int {
	return 400
}

func (o *PostCarupdateIDCancelBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /carupdate/{id}/cancel][%d] postCarupdateIdCancelBadRequest %s", 400, payload)
}

func (o *PostCarupdateIDCancelBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /carupdate/{id}/cancel][%d] postCarupdateIdCancelBadRequest %s", 400, payload)
}

func (o *PostCarupdateIDCancelBadRequest) GetPayload() *models.CommonJSONError {
	return o.Payload
}

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

	o.Payload = new(models.CommonJSONError)

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

	return nil
}

// NewPostCarupdateIDCancelUnauthorized creates a PostCarupdateIDCancelUnauthorized with default headers values
func NewPostCarupdateIDCancelUnauthorized() *PostCarupdateIDCancelUnauthorized {
	return &PostCarupdateIDCancelUnauthorized{}
}

/*
PostCarupdateIDCancelUnauthorized describes a response with status code 401, with default header values.

Unauthorized
*/
type PostCarupdateIDCancelUnauthorized struct {
	Payload *models.CommonJSONError
}

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

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

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

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

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

// Code gets the status code for the post carupdate Id cancel unauthorized response
func (o *PostCarupdateIDCancelUnauthorized) Code() int {
	return 401
}

func (o *PostCarupdateIDCancelUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /carupdate/{id}/cancel][%d] postCarupdateIdCancelUnauthorized %s", 401, payload)
}

func (o *PostCarupdateIDCancelUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /carupdate/{id}/cancel][%d] postCarupdateIdCancelUnauthorized %s", 401, payload)
}

func (o *PostCarupdateIDCancelUnauthorized) GetPayload() *models.CommonJSONError {
	return o.Payload
}

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

	o.Payload = new(models.CommonJSONError)

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

	return nil
}

// NewPostCarupdateIDCancelServiceUnavailable creates a PostCarupdateIDCancelServiceUnavailable with default headers values
func NewPostCarupdateIDCancelServiceUnavailable() *PostCarupdateIDCancelServiceUnavailable {
	return &PostCarupdateIDCancelServiceUnavailable{}
}

/*
PostCarupdateIDCancelServiceUnavailable describes a response with status code 503, with default header values.

Service unavailable
*/
type PostCarupdateIDCancelServiceUnavailable struct {
	Payload *models.CommonJSONError
}

// IsSuccess returns true when this post carupdate Id cancel service unavailable response has a 2xx status code
func (o *PostCarupdateIDCancelServiceUnavailable) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this post carupdate Id cancel service unavailable response has a 3xx status code
func (o *PostCarupdateIDCancelServiceUnavailable) IsRedirect() bool {
	return false
}

// IsClientError returns true when this post carupdate Id cancel service unavailable response has a 4xx status code
func (o *PostCarupdateIDCancelServiceUnavailable) IsClientError() bool {
	return false
}

// IsServerError returns true when this post carupdate Id cancel service unavailable response has a 5xx status code
func (o *PostCarupdateIDCancelServiceUnavailable) IsServerError() bool {
	return true
}

// IsCode returns true when this post carupdate Id cancel service unavailable response a status code equal to that given
func (o *PostCarupdateIDCancelServiceUnavailable) IsCode(code int) bool {
	return code == 503
}

// Code gets the status code for the post carupdate Id cancel service unavailable response
func (o *PostCarupdateIDCancelServiceUnavailable) Code() int {
	return 503
}

func (o *PostCarupdateIDCancelServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /carupdate/{id}/cancel][%d] postCarupdateIdCancelServiceUnavailable %s", 503, payload)
}

func (o *PostCarupdateIDCancelServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /carupdate/{id}/cancel][%d] postCarupdateIdCancelServiceUnavailable %s", 503, payload)
}

func (o *PostCarupdateIDCancelServiceUnavailable) GetPayload() *models.CommonJSONError {
	return o.Payload
}

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

	o.Payload = new(models.CommonJSONError)

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

	return nil
}
