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

// PutApitokenReader is a Reader for the PutApitoken structure.
type PutApitokenReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PutApitokenReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewPutApitokenOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewPutApitokenBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewPutApitokenUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewPutApitokenServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[PUT /apitoken] PutApitoken", response, response.Code())
	}
}

// NewPutApitokenOK creates a PutApitokenOK with default headers values
func NewPutApitokenOK() *PutApitokenOK {
	return &PutApitokenOK{}
}

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

OK
*/
type PutApitokenOK struct {
	Payload *models.CommonSubscriptionConfiguration
}

// IsSuccess returns true when this put apitoken o k response has a 2xx status code
func (o *PutApitokenOK) IsSuccess() bool {
	return true
}

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

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

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

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

// Code gets the status code for the put apitoken o k response
func (o *PutApitokenOK) Code() int {
	return 200
}

func (o *PutApitokenOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /apitoken][%d] putApitokenOK %s", 200, payload)
}

func (o *PutApitokenOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /apitoken][%d] putApitokenOK %s", 200, payload)
}

func (o *PutApitokenOK) GetPayload() *models.CommonSubscriptionConfiguration {
	return o.Payload
}

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

	o.Payload = new(models.CommonSubscriptionConfiguration)

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

	return nil
}

// NewPutApitokenBadRequest creates a PutApitokenBadRequest with default headers values
func NewPutApitokenBadRequest() *PutApitokenBadRequest {
	return &PutApitokenBadRequest{}
}

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

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

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

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

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

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

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

// Code gets the status code for the put apitoken bad request response
func (o *PutApitokenBadRequest) Code() int {
	return 400
}

func (o *PutApitokenBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /apitoken][%d] putApitokenBadRequest %s", 400, payload)
}

func (o *PutApitokenBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /apitoken][%d] putApitokenBadRequest %s", 400, payload)
}

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

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

// NewPutApitokenUnauthorized creates a PutApitokenUnauthorized with default headers values
func NewPutApitokenUnauthorized() *PutApitokenUnauthorized {
	return &PutApitokenUnauthorized{}
}

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

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

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

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

// IsClientError returns true when this put apitoken unauthorized response has a 4xx status code
func (o *PutApitokenUnauthorized) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the put apitoken unauthorized response
func (o *PutApitokenUnauthorized) Code() int {
	return 401
}

func (o *PutApitokenUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /apitoken][%d] putApitokenUnauthorized %s", 401, payload)
}

func (o *PutApitokenUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /apitoken][%d] putApitokenUnauthorized %s", 401, payload)
}

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

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

// NewPutApitokenServiceUnavailable creates a PutApitokenServiceUnavailable with default headers values
func NewPutApitokenServiceUnavailable() *PutApitokenServiceUnavailable {
	return &PutApitokenServiceUnavailable{}
}

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

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

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

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

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

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

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

// Code gets the status code for the put apitoken service unavailable response
func (o *PutApitokenServiceUnavailable) Code() int {
	return 503
}

func (o *PutApitokenServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /apitoken][%d] putApitokenServiceUnavailable %s", 503, payload)
}

func (o *PutApitokenServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /apitoken][%d] putApitokenServiceUnavailable %s", 503, payload)
}

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

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