// 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/errors"
	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"

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

// RepoGetPullRequestFilesReader is a Reader for the RepoGetPullRequestFiles structure.
type RepoGetPullRequestFilesReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoGetPullRequestFilesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewRepoGetPullRequestFilesOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 404:
		result := NewRepoGetPullRequestFilesNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /repos/{owner}/{repo}/pulls/{index}/files] repoGetPullRequestFiles", response, response.Code())
	}
}

// NewRepoGetPullRequestFilesOK creates a RepoGetPullRequestFilesOK with default headers values
func NewRepoGetPullRequestFilesOK() *RepoGetPullRequestFilesOK {
	return &RepoGetPullRequestFilesOK{}
}

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

ChangedFileList
*/
type RepoGetPullRequestFilesOK struct {

	/* True if there is another page
	 */
	XHasMore bool

	/* The current page

	   Format: int64
	*/
	XPage int64

	/* Total number of pages

	   Format: int64
	*/
	XPageCount int64

	/* Commits per page

	   Format: int64
	*/
	XPerPage int64

	/* Total commit count

	   Format: int64
	*/
	XTotal int64

	Payload []*models.ChangedFile
}

// IsSuccess returns true when this repo get pull request files o k response has a 2xx status code
func (o *RepoGetPullRequestFilesOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this repo get pull request files o k response has a 3xx status code
func (o *RepoGetPullRequestFilesOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo get pull request files o k response has a 4xx status code
func (o *RepoGetPullRequestFilesOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this repo get pull request files o k response has a 5xx status code
func (o *RepoGetPullRequestFilesOK) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo get pull request files o k response
func (o *RepoGetPullRequestFilesOK) Code() int {
	return 200
}

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

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

func (o *RepoGetPullRequestFilesOK) GetPayload() []*models.ChangedFile {
	return o.Payload
}

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

	// hydrates response header X-HasMore
	hdrXHasMore := response.GetHeader("X-HasMore")

	if hdrXHasMore != "" {
		valxHasMore, err := swag.ConvertBool(hdrXHasMore)
		if err != nil {
			return errors.InvalidType("X-HasMore", "header", "bool", hdrXHasMore)
		}
		o.XHasMore = valxHasMore
	}

	// hydrates response header X-Page
	hdrXPage := response.GetHeader("X-Page")

	if hdrXPage != "" {
		valxPage, err := swag.ConvertInt64(hdrXPage)
		if err != nil {
			return errors.InvalidType("X-Page", "header", "int64", hdrXPage)
		}
		o.XPage = valxPage
	}

	// hydrates response header X-PageCount
	hdrXPageCount := response.GetHeader("X-PageCount")

	if hdrXPageCount != "" {
		valxPageCount, err := swag.ConvertInt64(hdrXPageCount)
		if err != nil {
			return errors.InvalidType("X-PageCount", "header", "int64", hdrXPageCount)
		}
		o.XPageCount = valxPageCount
	}

	// hydrates response header X-PerPage
	hdrXPerPage := response.GetHeader("X-PerPage")

	if hdrXPerPage != "" {
		valxPerPage, err := swag.ConvertInt64(hdrXPerPage)
		if err != nil {
			return errors.InvalidType("X-PerPage", "header", "int64", hdrXPerPage)
		}
		o.XPerPage = valxPerPage
	}

	// hydrates response header X-Total
	hdrXTotal := response.GetHeader("X-Total")

	if hdrXTotal != "" {
		valxTotal, err := swag.ConvertInt64(hdrXTotal)
		if err != nil {
			return errors.InvalidType("X-Total", "header", "int64", hdrXTotal)
		}
		o.XTotal = valxTotal
	}

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

	return nil
}

// NewRepoGetPullRequestFilesNotFound creates a RepoGetPullRequestFilesNotFound with default headers values
func NewRepoGetPullRequestFilesNotFound() *RepoGetPullRequestFilesNotFound {
	return &RepoGetPullRequestFilesNotFound{}
}

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

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

// IsSuccess returns true when this repo get pull request files not found response has a 2xx status code
func (o *RepoGetPullRequestFilesNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo get pull request files not found response has a 3xx status code
func (o *RepoGetPullRequestFilesNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo get pull request files not found response has a 4xx status code
func (o *RepoGetPullRequestFilesNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo get pull request files not found response has a 5xx status code
func (o *RepoGetPullRequestFilesNotFound) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo get pull request files not found response
func (o *RepoGetPullRequestFilesNotFound) Code() int {
	return 404
}

func (o *RepoGetPullRequestFilesNotFound) Error() string {
	return fmt.Sprintf("[GET /repos/{owner}/{repo}/pulls/{index}/files][%d] repoGetPullRequestFilesNotFound", 404)
}

func (o *RepoGetPullRequestFilesNotFound) String() string {
	return fmt.Sprintf("[GET /repos/{owner}/{repo}/pulls/{index}/files][%d] repoGetPullRequestFilesNotFound", 404)
}

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

	return nil
}
