github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/task-tracker/client/tasks/get_task_comments_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package tasks
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"fmt"
    10  	"io"
    11  
    12  	"github.com/go-openapi/runtime"
    13  	"github.com/go-openapi/strfmt"
    14  
    15  	"github.com/go-swagger/go-swagger/examples/task-tracker/models"
    16  )
    17  
    18  // GetTaskCommentsReader is a Reader for the GetTaskComments structure.
    19  type GetTaskCommentsReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *GetTaskCommentsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 200:
    27  		result := NewGetTaskCommentsOK()
    28  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    29  			return nil, err
    30  		}
    31  		return result, nil
    32  	default:
    33  		result := NewGetTaskCommentsDefault(response.Code())
    34  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    35  			return nil, err
    36  		}
    37  		if response.Code()/100 == 2 {
    38  			return result, nil
    39  		}
    40  		return nil, result
    41  	}
    42  }
    43  
    44  // NewGetTaskCommentsOK creates a GetTaskCommentsOK with default headers values
    45  func NewGetTaskCommentsOK() *GetTaskCommentsOK {
    46  	return &GetTaskCommentsOK{}
    47  }
    48  
    49  /*
    50  	GetTaskCommentsOK describes a response with status code 200, with default header values.
    51  
    52  The list of comments
    53  */
    54  type GetTaskCommentsOK struct {
    55  	Payload []*models.Comment
    56  }
    57  
    58  // IsSuccess returns true when this get task comments o k response returns a 2xx status code
    59  func (o *GetTaskCommentsOK) IsSuccess() bool {
    60  	return true
    61  }
    62  
    63  // IsRedirect returns true when this get task comments o k response returns a 3xx status code
    64  func (o *GetTaskCommentsOK) IsRedirect() bool {
    65  	return false
    66  }
    67  
    68  // IsClientError returns true when this get task comments o k response returns a 4xx status code
    69  func (o *GetTaskCommentsOK) IsClientError() bool {
    70  	return false
    71  }
    72  
    73  // IsServerError returns true when this get task comments o k response returns a 5xx status code
    74  func (o *GetTaskCommentsOK) IsServerError() bool {
    75  	return false
    76  }
    77  
    78  // IsCode returns true when this get task comments o k response returns a 4xx status code
    79  func (o *GetTaskCommentsOK) IsCode(code int) bool {
    80  	return code == 200
    81  }
    82  
    83  func (o *GetTaskCommentsOK) Error() string {
    84  	return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskCommentsOK  %+v", 200, o.Payload)
    85  }
    86  
    87  func (o *GetTaskCommentsOK) String() string {
    88  	return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskCommentsOK  %+v", 200, o.Payload)
    89  }
    90  
    91  func (o *GetTaskCommentsOK) GetPayload() []*models.Comment {
    92  	return o.Payload
    93  }
    94  
    95  func (o *GetTaskCommentsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    96  
    97  	// response payload
    98  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
    99  		return err
   100  	}
   101  
   102  	return nil
   103  }
   104  
   105  // NewGetTaskCommentsDefault creates a GetTaskCommentsDefault with default headers values
   106  func NewGetTaskCommentsDefault(code int) *GetTaskCommentsDefault {
   107  	return &GetTaskCommentsDefault{
   108  		_statusCode: code,
   109  	}
   110  }
   111  
   112  /*
   113  	GetTaskCommentsDefault describes a response with status code -1, with default header values.
   114  
   115  Error response
   116  */
   117  type GetTaskCommentsDefault struct {
   118  	_statusCode int
   119  	XErrorCode  string
   120  
   121  	Payload *models.Error
   122  }
   123  
   124  // Code gets the status code for the get task comments default response
   125  func (o *GetTaskCommentsDefault) Code() int {
   126  	return o._statusCode
   127  }
   128  
   129  // IsSuccess returns true when this get task comments default response returns a 2xx status code
   130  func (o *GetTaskCommentsDefault) IsSuccess() bool {
   131  	return o._statusCode/100 == 2
   132  }
   133  
   134  // IsRedirect returns true when this get task comments default response returns a 3xx status code
   135  func (o *GetTaskCommentsDefault) IsRedirect() bool {
   136  	return o._statusCode/100 == 3
   137  }
   138  
   139  // IsClientError returns true when this get task comments default response returns a 4xx status code
   140  func (o *GetTaskCommentsDefault) IsClientError() bool {
   141  	return o._statusCode/100 == 4
   142  }
   143  
   144  // IsServerError returns true when this get task comments default response returns a 5xx status code
   145  func (o *GetTaskCommentsDefault) IsServerError() bool {
   146  	return o._statusCode/100 == 5
   147  }
   148  
   149  // IsCode returns true when this get task comments default response returns a 4xx status code
   150  func (o *GetTaskCommentsDefault) IsCode(code int) bool {
   151  	return o._statusCode == code
   152  }
   153  
   154  func (o *GetTaskCommentsDefault) Error() string {
   155  	return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskComments default  %+v", o._statusCode, o.Payload)
   156  }
   157  
   158  func (o *GetTaskCommentsDefault) String() string {
   159  	return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskComments default  %+v", o._statusCode, o.Payload)
   160  }
   161  
   162  func (o *GetTaskCommentsDefault) GetPayload() *models.Error {
   163  	return o.Payload
   164  }
   165  
   166  func (o *GetTaskCommentsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   167  
   168  	// hydrates response header X-Error-Code
   169  	hdrXErrorCode := response.GetHeader("X-Error-Code")
   170  
   171  	if hdrXErrorCode != "" {
   172  		o.XErrorCode = hdrXErrorCode
   173  	}
   174  
   175  	o.Payload = new(models.Error)
   176  
   177  	// response payload
   178  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   179  		return err
   180  	}
   181  
   182  	return nil
   183  }