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