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

// PostSubscriptionpackageReader is a Reader for the PostSubscriptionpackage structure.
type PostSubscriptionpackageReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostSubscriptionpackageReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewPostSubscriptionpackageOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewPostSubscriptionpackageBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewPostSubscriptionpackageUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewPostSubscriptionpackageServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /subscriptionpackage] PostSubscriptionpackage", response, response.Code())
	}
}

// NewPostSubscriptionpackageOK creates a PostSubscriptionpackageOK with default headers values
func NewPostSubscriptionpackageOK() *PostSubscriptionpackageOK {
	return &PostSubscriptionpackageOK{}
}

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

OK
*/
type PostSubscriptionpackageOK struct {
	Payload *models.CommonSubscriptionPackage
}

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

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

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

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

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

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

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

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

func (o *PostSubscriptionpackageOK) GetPayload() *models.CommonSubscriptionPackage {
	return o.Payload
}

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

	o.Payload = new(models.CommonSubscriptionPackage)

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

	return nil
}

// NewPostSubscriptionpackageBadRequest creates a PostSubscriptionpackageBadRequest with default headers values
func NewPostSubscriptionpackageBadRequest() *PostSubscriptionpackageBadRequest {
	return &PostSubscriptionpackageBadRequest{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewPostSubscriptionpackageUnauthorized creates a PostSubscriptionpackageUnauthorized with default headers values
func NewPostSubscriptionpackageUnauthorized() *PostSubscriptionpackageUnauthorized {
	return &PostSubscriptionpackageUnauthorized{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewPostSubscriptionpackageServiceUnavailable creates a PostSubscriptionpackageServiceUnavailable with default headers values
func NewPostSubscriptionpackageServiceUnavailable() *PostSubscriptionpackageServiceUnavailable {
	return &PostSubscriptionpackageServiceUnavailable{}
}

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

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

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

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

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

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

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

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

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

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

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

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