// Code generated by go-swagger; DO NOT EDIT.

package repository

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

	"src.opensuse.org/autogits/common/gitea-generated/models"
)

// RepoSubmitPullReviewReader is a Reader for the RepoSubmitPullReview structure.
type RepoSubmitPullReviewReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoSubmitPullReviewReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewRepoSubmitPullReviewOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 404:
		result := NewRepoSubmitPullReviewNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewRepoSubmitPullReviewUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}] repoSubmitPullReview", response, response.Code())
	}
}

// NewRepoSubmitPullReviewOK creates a RepoSubmitPullReviewOK with default headers values
func NewRepoSubmitPullReviewOK() *RepoSubmitPullReviewOK {
	return &RepoSubmitPullReviewOK{}
}

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

PullReview
*/
type RepoSubmitPullReviewOK struct {
	Payload *models.PullReview
}

// IsSuccess returns true when this repo submit pull review o k response has a 2xx status code
func (o *RepoSubmitPullReviewOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this repo submit pull review o k response has a 3xx status code
func (o *RepoSubmitPullReviewOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo submit pull review o k response has a 4xx status code
func (o *RepoSubmitPullReviewOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this repo submit pull review o k response has a 5xx status code
func (o *RepoSubmitPullReviewOK) IsServerError() bool {
	return false
}

// IsCode returns true when this repo submit pull review o k response a status code equal to that given
func (o *RepoSubmitPullReviewOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the repo submit pull review o k response
func (o *RepoSubmitPullReviewOK) Code() int {
	return 200
}

func (o *RepoSubmitPullReviewOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}][%d] repoSubmitPullReviewOK %s", 200, payload)
}

func (o *RepoSubmitPullReviewOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}][%d] repoSubmitPullReviewOK %s", 200, payload)
}

func (o *RepoSubmitPullReviewOK) GetPayload() *models.PullReview {
	return o.Payload
}

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

	o.Payload = new(models.PullReview)

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

	return nil
}

// NewRepoSubmitPullReviewNotFound creates a RepoSubmitPullReviewNotFound with default headers values
func NewRepoSubmitPullReviewNotFound() *RepoSubmitPullReviewNotFound {
	return &RepoSubmitPullReviewNotFound{}
}

/*
RepoSubmitPullReviewNotFound describes a response with status code 404, with default header values.

APINotFound is a not found empty response
*/
type RepoSubmitPullReviewNotFound struct {
}

// IsSuccess returns true when this repo submit pull review not found response has a 2xx status code
func (o *RepoSubmitPullReviewNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo submit pull review not found response has a 3xx status code
func (o *RepoSubmitPullReviewNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo submit pull review not found response has a 4xx status code
func (o *RepoSubmitPullReviewNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo submit pull review not found response has a 5xx status code
func (o *RepoSubmitPullReviewNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this repo submit pull review not found response a status code equal to that given
func (o *RepoSubmitPullReviewNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the repo submit pull review not found response
func (o *RepoSubmitPullReviewNotFound) Code() int {
	return 404
}

func (o *RepoSubmitPullReviewNotFound) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}][%d] repoSubmitPullReviewNotFound", 404)
}

func (o *RepoSubmitPullReviewNotFound) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}][%d] repoSubmitPullReviewNotFound", 404)
}

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

	return nil
}

// NewRepoSubmitPullReviewUnprocessableEntity creates a RepoSubmitPullReviewUnprocessableEntity with default headers values
func NewRepoSubmitPullReviewUnprocessableEntity() *RepoSubmitPullReviewUnprocessableEntity {
	return &RepoSubmitPullReviewUnprocessableEntity{}
}

/*
RepoSubmitPullReviewUnprocessableEntity describes a response with status code 422, with default header values.

APIValidationError is error format response related to input validation
*/
type RepoSubmitPullReviewUnprocessableEntity struct {
	Message string
	URL     string
}

// IsSuccess returns true when this repo submit pull review unprocessable entity response has a 2xx status code
func (o *RepoSubmitPullReviewUnprocessableEntity) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo submit pull review unprocessable entity response has a 3xx status code
func (o *RepoSubmitPullReviewUnprocessableEntity) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo submit pull review unprocessable entity response has a 4xx status code
func (o *RepoSubmitPullReviewUnprocessableEntity) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo submit pull review unprocessable entity response has a 5xx status code
func (o *RepoSubmitPullReviewUnprocessableEntity) IsServerError() bool {
	return false
}

// IsCode returns true when this repo submit pull review unprocessable entity response a status code equal to that given
func (o *RepoSubmitPullReviewUnprocessableEntity) IsCode(code int) bool {
	return code == 422
}

// Code gets the status code for the repo submit pull review unprocessable entity response
func (o *RepoSubmitPullReviewUnprocessableEntity) Code() int {
	return 422
}

func (o *RepoSubmitPullReviewUnprocessableEntity) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}][%d] repoSubmitPullReviewUnprocessableEntity", 422)
}

func (o *RepoSubmitPullReviewUnprocessableEntity) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}][%d] repoSubmitPullReviewUnprocessableEntity", 422)
}

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

	// hydrates response header message
	hdrMessage := response.GetHeader("message")

	if hdrMessage != "" {
		o.Message = hdrMessage
	}

	// hydrates response header url
	hdrURL := response.GetHeader("url")

	if hdrURL != "" {
		o.URL = hdrURL
	}

	return nil
}
