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

// GetVehicleyearsReader is a Reader for the GetVehicleyears structure.
type GetVehicleyearsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetVehicleyearsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetVehicleyearsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewGetVehicleyearsBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewGetVehicleyearsUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewGetVehicleyearsServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /vehicleyears] GetVehicleyears", response, response.Code())
	}
}

// NewGetVehicleyearsOK creates a GetVehicleyearsOK with default headers values
func NewGetVehicleyearsOK() *GetVehicleyearsOK {
	return &GetVehicleyearsOK{}
}

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

OK
*/
type GetVehicleyearsOK struct {
	Payload *models.HandlersJSONYearsResult
}

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

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

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

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

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

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

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

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

func (o *GetVehicleyearsOK) GetPayload() *models.HandlersJSONYearsResult {
	return o.Payload
}

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

	o.Payload = new(models.HandlersJSONYearsResult)

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

	return nil
}

// NewGetVehicleyearsBadRequest creates a GetVehicleyearsBadRequest with default headers values
func NewGetVehicleyearsBadRequest() *GetVehicleyearsBadRequest {
	return &GetVehicleyearsBadRequest{}
}

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

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

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

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

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

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

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

// Code gets the status code for the get vehicleyears bad request response
func (o *GetVehicleyearsBadRequest) Code() int {
	return 400
}

func (o *GetVehicleyearsBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /vehicleyears][%d] getVehicleyearsBadRequest %s", 400, payload)
}

func (o *GetVehicleyearsBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /vehicleyears][%d] getVehicleyearsBadRequest %s", 400, payload)
}

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

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

// NewGetVehicleyearsUnauthorized creates a GetVehicleyearsUnauthorized with default headers values
func NewGetVehicleyearsUnauthorized() *GetVehicleyearsUnauthorized {
	return &GetVehicleyearsUnauthorized{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewGetVehicleyearsServiceUnavailable creates a GetVehicleyearsServiceUnavailable with default headers values
func NewGetVehicleyearsServiceUnavailable() *GetVehicleyearsServiceUnavailable {
	return &GetVehicleyearsServiceUnavailable{}
}

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

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

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

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

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

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

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

// Code gets the status code for the get vehicleyears service unavailable response
func (o *GetVehicleyearsServiceUnavailable) Code() int {
	return 503
}

func (o *GetVehicleyearsServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /vehicleyears][%d] getVehicleyearsServiceUnavailable %s", 503, payload)
}

func (o *GetVehicleyearsServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /vehicleyears][%d] getVehicleyearsServiceUnavailable %s", 503, payload)
}

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

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