github.com/djarvur/go-swagger@v0.18.0/examples/task-tracker/client/tasks/list_tasks_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/errors" 13 "github.com/go-openapi/runtime" 14 "github.com/go-openapi/swag" 15 16 strfmt "github.com/go-openapi/strfmt" 17 18 models "github.com/go-swagger/go-swagger/examples/task-tracker/models" 19 ) 20 21 // ListTasksReader is a Reader for the ListTasks structure. 22 type ListTasksReader struct { 23 formats strfmt.Registry 24 } 25 26 // ReadResponse reads a server response into the received o. 27 func (o *ListTasksReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 28 switch response.Code() { 29 30 case 200: 31 result := NewListTasksOK() 32 if err := result.readResponse(response, consumer, o.formats); err != nil { 33 return nil, err 34 } 35 return result, nil 36 37 case 422: 38 result := NewListTasksUnprocessableEntity() 39 if err := result.readResponse(response, consumer, o.formats); err != nil { 40 return nil, err 41 } 42 return nil, result 43 44 default: 45 result := NewListTasksDefault(response.Code()) 46 if err := result.readResponse(response, consumer, o.formats); err != nil { 47 return nil, err 48 } 49 if response.Code()/100 == 2 { 50 return result, nil 51 } 52 return nil, result 53 } 54 } 55 56 // NewListTasksOK creates a ListTasksOK with default headers values 57 func NewListTasksOK() *ListTasksOK { 58 return &ListTasksOK{} 59 } 60 61 /*ListTasksOK handles this case with default header values. 62 63 Successful response 64 */ 65 type ListTasksOK struct { 66 /*the last task id known to the application 67 */ 68 XLastTaskID int64 69 70 Payload []*models.TaskCard 71 } 72 73 func (o *ListTasksOK) Error() string { 74 return fmt.Sprintf("[GET /tasks][%d] listTasksOK %+v", 200, o.Payload) 75 } 76 77 func (o *ListTasksOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 78 79 // response header X-Last-Task-Id 80 xLastTaskId, err := swag.ConvertInt64(response.GetHeader("X-Last-Task-Id")) 81 if err != nil { 82 return errors.InvalidType("X-Last-Task-Id", "header", "int64", response.GetHeader("X-Last-Task-Id")) 83 } 84 o.XLastTaskID = xLastTaskId 85 86 // response payload 87 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 88 return err 89 } 90 91 return nil 92 } 93 94 // NewListTasksUnprocessableEntity creates a ListTasksUnprocessableEntity with default headers values 95 func NewListTasksUnprocessableEntity() *ListTasksUnprocessableEntity { 96 return &ListTasksUnprocessableEntity{} 97 } 98 99 /*ListTasksUnprocessableEntity handles this case with default header values. 100 101 Validation error 102 */ 103 type ListTasksUnprocessableEntity struct { 104 Payload *models.ValidationError 105 } 106 107 func (o *ListTasksUnprocessableEntity) Error() string { 108 return fmt.Sprintf("[GET /tasks][%d] listTasksUnprocessableEntity %+v", 422, o.Payload) 109 } 110 111 func (o *ListTasksUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 112 113 o.Payload = new(models.ValidationError) 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 } 122 123 // NewListTasksDefault creates a ListTasksDefault with default headers values 124 func NewListTasksDefault(code int) *ListTasksDefault { 125 return &ListTasksDefault{ 126 _statusCode: code, 127 } 128 } 129 130 /*ListTasksDefault handles this case with default header values. 131 132 Error response 133 */ 134 type ListTasksDefault struct { 135 _statusCode int 136 137 XErrorCode string 138 139 Payload *models.Error 140 } 141 142 // Code gets the status code for the list tasks default response 143 func (o *ListTasksDefault) Code() int { 144 return o._statusCode 145 } 146 147 func (o *ListTasksDefault) Error() string { 148 return fmt.Sprintf("[GET /tasks][%d] listTasks default %+v", o._statusCode, o.Payload) 149 } 150 151 func (o *ListTasksDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 152 153 // response header X-Error-Code 154 o.XErrorCode = response.GetHeader("X-Error-Code") 155 156 o.Payload = new(models.Error) 157 158 // response payload 159 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 160 return err 161 } 162 163 return nil 164 }