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