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

// RepoGetPullRequestCommitsReader is a Reader for the RepoGetPullRequestCommits structure.
type RepoGetPullRequestCommitsReader struct {
	formats strfmt.Registry
}

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

// NewRepoGetPullRequestCommitsOK creates a RepoGetPullRequestCommitsOK with default headers values
func NewRepoGetPullRequestCommitsOK() *RepoGetPullRequestCommitsOK {
	return &RepoGetPullRequestCommitsOK{}
}

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

CommitList
*/
type RepoGetPullRequestCommitsOK 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.Commit
}

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

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

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

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

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

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

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

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

func (o *RepoGetPullRequestCommitsOK) GetPayload() []*models.Commit {
	return o.Payload
}

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

// NewRepoGetPullRequestCommitsNotFound creates a RepoGetPullRequestCommitsNotFound with default headers values
func NewRepoGetPullRequestCommitsNotFound() *RepoGetPullRequestCommitsNotFound {
	return &RepoGetPullRequestCommitsNotFound{}
}

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

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

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

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

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

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

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

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

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

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

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

	return nil
}
