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

// GetCarslocationsReader is a Reader for the GetCarslocations structure.
type GetCarslocationsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetCarslocationsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetCarslocationsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewGetCarslocationsBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewGetCarslocationsUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewGetCarslocationsServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /carslocations] GetCarslocations", response, response.Code())
	}
}

// NewGetCarslocationsOK creates a GetCarslocationsOK with default headers values
func NewGetCarslocationsOK() *GetCarslocationsOK {
	return &GetCarslocationsOK{}
}

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

OK
*/
type GetCarslocationsOK struct {
	Payload *models.HandlersJSONCarLocations
}

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

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

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

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

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

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

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

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

func (o *GetCarslocationsOK) GetPayload() *models.HandlersJSONCarLocations {
	return o.Payload
}

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

	o.Payload = new(models.HandlersJSONCarLocations)

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

	return nil
}

// NewGetCarslocationsBadRequest creates a GetCarslocationsBadRequest with default headers values
func NewGetCarslocationsBadRequest() *GetCarslocationsBadRequest {
	return &GetCarslocationsBadRequest{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewGetCarslocationsUnauthorized creates a GetCarslocationsUnauthorized with default headers values
func NewGetCarslocationsUnauthorized() *GetCarslocationsUnauthorized {
	return &GetCarslocationsUnauthorized{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewGetCarslocationsServiceUnavailable creates a GetCarslocationsServiceUnavailable with default headers values
func NewGetCarslocationsServiceUnavailable() *GetCarslocationsServiceUnavailable {
	return &GetCarslocationsServiceUnavailable{}
}

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

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

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

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

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

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

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

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

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

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

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

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