github.com/djarvur/go-swagger@v0.18.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/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 28 case 200: 29 result := NewGetTaskCommentsOK() 30 if err := result.readResponse(response, consumer, o.formats); err != nil { 31 return nil, err 32 } 33 return result, nil 34 35 default: 36 result := NewGetTaskCommentsDefault(response.Code()) 37 if err := result.readResponse(response, consumer, o.formats); err != nil { 38 return nil, err 39 } 40 if response.Code()/100 == 2 { 41 return result, nil 42 } 43 return nil, result 44 } 45 } 46 47 // NewGetTaskCommentsOK creates a GetTaskCommentsOK with default headers values 48 func NewGetTaskCommentsOK() *GetTaskCommentsOK { 49 return &GetTaskCommentsOK{} 50 } 51 52 /*GetTaskCommentsOK handles this case with default header values. 53 54 The list of comments 55 */ 56 type GetTaskCommentsOK struct { 57 Payload []*models.Comment 58 } 59 60 func (o *GetTaskCommentsOK) Error() string { 61 return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskCommentsOK %+v", 200, 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 handles this case with default header values. 82 83 Error response 84 */ 85 type GetTaskCommentsDefault struct { 86 _statusCode int 87 88 XErrorCode string 89 90 Payload *models.Error 91 } 92 93 // Code gets the status code for the get task comments default response 94 func (o *GetTaskCommentsDefault) Code() int { 95 return o._statusCode 96 } 97 98 func (o *GetTaskCommentsDefault) Error() string { 99 return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskComments default %+v", o._statusCode, o.Payload) 100 } 101 102 func (o *GetTaskCommentsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 103 104 // response header X-Error-Code 105 o.XErrorCode = response.GetHeader("X-Error-Code") 106 107 o.Payload = new(models.Error) 108 109 // response payload 110 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 111 return err 112 } 113 114 return nil 115 }