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

// RepoCreatePullReviewReader is a Reader for the RepoCreatePullReview structure.
type RepoCreatePullReviewReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoCreatePullReviewReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewRepoCreatePullReviewOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 404:
		result := NewRepoCreatePullReviewNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewRepoCreatePullReviewUnprocessableEntity()
		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] repoCreatePullReview", response, response.Code())
	}
}

// NewRepoCreatePullReviewOK creates a RepoCreatePullReviewOK with default headers values
func NewRepoCreatePullReviewOK() *RepoCreatePullReviewOK {
	return &RepoCreatePullReviewOK{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewRepoCreatePullReviewNotFound creates a RepoCreatePullReviewNotFound with default headers values
func NewRepoCreatePullReviewNotFound() *RepoCreatePullReviewNotFound {
	return &RepoCreatePullReviewNotFound{}
}

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

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

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

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

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

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

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

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

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

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

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

	return nil
}

// NewRepoCreatePullReviewUnprocessableEntity creates a RepoCreatePullReviewUnprocessableEntity with default headers values
func NewRepoCreatePullReviewUnprocessableEntity() *RepoCreatePullReviewUnprocessableEntity {
	return &RepoCreatePullReviewUnprocessableEntity{}
}

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

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

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

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

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

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

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

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

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

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

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