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

// PostVehicleReader is a Reader for the PostVehicle structure.
type PostVehicleReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostVehicleReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewPostVehicleOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewPostVehicleBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewPostVehicleUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewPostVehicleServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /vehicle] PostVehicle", response, response.Code())
	}
}

// NewPostVehicleOK creates a PostVehicleOK with default headers values
func NewPostVehicleOK() *PostVehicleOK {
	return &PostVehicleOK{}
}

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

OK
*/
type PostVehicleOK struct {
	Payload *models.CommonAddCarRequest
}

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

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

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

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

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

// Code gets the status code for the post vehicle o k response
func (o *PostVehicleOK) Code() int {
	return 200
}

func (o *PostVehicleOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /vehicle][%d] postVehicleOK %s", 200, payload)
}

func (o *PostVehicleOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /vehicle][%d] postVehicleOK %s", 200, payload)
}

func (o *PostVehicleOK) GetPayload() *models.CommonAddCarRequest {
	return o.Payload
}

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

	o.Payload = new(models.CommonAddCarRequest)

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

	return nil
}

// NewPostVehicleBadRequest creates a PostVehicleBadRequest with default headers values
func NewPostVehicleBadRequest() *PostVehicleBadRequest {
	return &PostVehicleBadRequest{}
}

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

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

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

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

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

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

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

// Code gets the status code for the post vehicle bad request response
func (o *PostVehicleBadRequest) Code() int {
	return 400
}

func (o *PostVehicleBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /vehicle][%d] postVehicleBadRequest %s", 400, payload)
}

func (o *PostVehicleBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /vehicle][%d] postVehicleBadRequest %s", 400, payload)
}

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

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

// NewPostVehicleUnauthorized creates a PostVehicleUnauthorized with default headers values
func NewPostVehicleUnauthorized() *PostVehicleUnauthorized {
	return &PostVehicleUnauthorized{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewPostVehicleServiceUnavailable creates a PostVehicleServiceUnavailable with default headers values
func NewPostVehicleServiceUnavailable() *PostVehicleServiceUnavailable {
	return &PostVehicleServiceUnavailable{}
}

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

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

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

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

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

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

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

// Code gets the status code for the post vehicle service unavailable response
func (o *PostVehicleServiceUnavailable) Code() int {
	return 503
}

func (o *PostVehicleServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /vehicle][%d] postVehicleServiceUnavailable %s", 503, payload)
}

func (o *PostVehicleServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /vehicle][%d] postVehicleServiceUnavailable %s", 503, payload)
}

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

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