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

// PostFlashpackVersionReader is a Reader for the PostFlashpackVersion structure.
type PostFlashpackVersionReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostFlashpackVersionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewPostFlashpackVersionOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewPostFlashpackVersionBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewPostFlashpackVersionUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewPostFlashpackVersionServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /flashpack_version] PostFlashpackVersion", response, response.Code())
	}
}

// NewPostFlashpackVersionOK creates a PostFlashpackVersionOK with default headers values
func NewPostFlashpackVersionOK() *PostFlashpackVersionOK {
	return &PostFlashpackVersionOK{}
}

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

Created flashpack ecu mapping result
*/
type PostFlashpackVersionOK struct {
	Payload *models.CommonJSONDBQueryResult
}

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

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

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

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

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

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

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

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

func (o *PostFlashpackVersionOK) GetPayload() *models.CommonJSONDBQueryResult {
	return o.Payload
}

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

	o.Payload = new(models.CommonJSONDBQueryResult)

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

	return nil
}

// NewPostFlashpackVersionBadRequest creates a PostFlashpackVersionBadRequest with default headers values
func NewPostFlashpackVersionBadRequest() *PostFlashpackVersionBadRequest {
	return &PostFlashpackVersionBadRequest{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewPostFlashpackVersionUnauthorized creates a PostFlashpackVersionUnauthorized with default headers values
func NewPostFlashpackVersionUnauthorized() *PostFlashpackVersionUnauthorized {
	return &PostFlashpackVersionUnauthorized{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewPostFlashpackVersionServiceUnavailable creates a PostFlashpackVersionServiceUnavailable with default headers values
func NewPostFlashpackVersionServiceUnavailable() *PostFlashpackVersionServiceUnavailable {
	return &PostFlashpackVersionServiceUnavailable{}
}

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

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

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

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

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

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

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

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

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

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

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

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