github.com/circl-dev/go-swagger@v0.31.0/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/strfmt"
    13  	"github.com/circl-dev/runtime"
    14  
    15  	"github.com/circl-dev/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  /* GetTaskCommentsOK describes a response with status code 200, with default header values.
    50  
    51  The list of comments
    52  */
    53  type GetTaskCommentsOK struct {
    54  	Payload []*models.Comment
    55  }
    56  
    57  func (o *GetTaskCommentsOK) Error() string {
    58  	return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskCommentsOK  %+v", 200, o.Payload)
    59  }
    60  func (o *GetTaskCommentsOK) GetPayload() []*models.Comment {
    61  	return o.Payload
    62  }
    63  
    64  func (o *GetTaskCommentsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    65  
    66  	// response payload
    67  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
    68  		return err
    69  	}
    70  
    71  	return nil
    72  }
    73  
    74  // NewGetTaskCommentsDefault creates a GetTaskCommentsDefault with default headers values
    75  func NewGetTaskCommentsDefault(code int) *GetTaskCommentsDefault {
    76  	return &GetTaskCommentsDefault{
    77  		_statusCode: code,
    78  	}
    79  }
    80  
    81  /* GetTaskCommentsDefault describes a response with status code -1, with default header values.
    82  
    83  Error response
    84  */
    85  type GetTaskCommentsDefault struct {
    86  	_statusCode int
    87  	XErrorCode  string
    88  
    89  	Payload *models.Error
    90  }
    91  
    92  // Code gets the status code for the get task comments default response
    93  func (o *GetTaskCommentsDefault) Code() int {
    94  	return o._statusCode
    95  }
    96  
    97  func (o *GetTaskCommentsDefault) Error() string {
    98  	return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskComments default  %+v", o._statusCode, o.Payload)
    99  }
   100  func (o *GetTaskCommentsDefault) GetPayload() *models.Error {
   101  	return o.Payload
   102  }
   103  
   104  func (o *GetTaskCommentsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   105  
   106  	// hydrates response header X-Error-Code
   107  	hdrXErrorCode := response.GetHeader("X-Error-Code")
   108  
   109  	if hdrXErrorCode != "" {
   110  		o.XErrorCode = hdrXErrorCode
   111  	}
   112  
   113  	o.Payload = new(models.Error)
   114  
   115  	// response payload
   116  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   117  		return err
   118  	}
   119  
   120  	return nil
   121  }