github.com/djarvur/go-swagger@v0.18.0/examples/task-tracker/client/tasks/update_task_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 // UpdateTaskReader is a Reader for the UpdateTask structure. 20 type UpdateTaskReader struct { 21 formats strfmt.Registry 22 } 23 24 // ReadResponse reads a server response into the received o. 25 func (o *UpdateTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 26 switch response.Code() { 27 28 case 200: 29 result := NewUpdateTaskOK() 30 if err := result.readResponse(response, consumer, o.formats); err != nil { 31 return nil, err 32 } 33 return result, nil 34 35 case 422: 36 result := NewUpdateTaskUnprocessableEntity() 37 if err := result.readResponse(response, consumer, o.formats); err != nil { 38 return nil, err 39 } 40 return nil, result 41 42 default: 43 result := NewUpdateTaskDefault(response.Code()) 44 if err := result.readResponse(response, consumer, o.formats); err != nil { 45 return nil, err 46 } 47 if response.Code()/100 == 2 { 48 return result, nil 49 } 50 return nil, result 51 } 52 } 53 54 // NewUpdateTaskOK creates a UpdateTaskOK with default headers values 55 func NewUpdateTaskOK() *UpdateTaskOK { 56 return &UpdateTaskOK{} 57 } 58 59 /*UpdateTaskOK handles this case with default header values. 60 61 Task details 62 */ 63 type UpdateTaskOK struct { 64 Payload *models.Task 65 } 66 67 func (o *UpdateTaskOK) Error() string { 68 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskOK %+v", 200, o.Payload) 69 } 70 71 func (o *UpdateTaskOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 72 73 o.Payload = new(models.Task) 74 75 // response payload 76 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 77 return err 78 } 79 80 return nil 81 } 82 83 // NewUpdateTaskUnprocessableEntity creates a UpdateTaskUnprocessableEntity with default headers values 84 func NewUpdateTaskUnprocessableEntity() *UpdateTaskUnprocessableEntity { 85 return &UpdateTaskUnprocessableEntity{} 86 } 87 88 /*UpdateTaskUnprocessableEntity handles this case with default header values. 89 90 Validation error 91 */ 92 type UpdateTaskUnprocessableEntity struct { 93 Payload *models.ValidationError 94 } 95 96 func (o *UpdateTaskUnprocessableEntity) Error() string { 97 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskUnprocessableEntity %+v", 422, o.Payload) 98 } 99 100 func (o *UpdateTaskUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 101 102 o.Payload = new(models.ValidationError) 103 104 // response payload 105 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 106 return err 107 } 108 109 return nil 110 } 111 112 // NewUpdateTaskDefault creates a UpdateTaskDefault with default headers values 113 func NewUpdateTaskDefault(code int) *UpdateTaskDefault { 114 return &UpdateTaskDefault{ 115 _statusCode: code, 116 } 117 } 118 119 /*UpdateTaskDefault handles this case with default header values. 120 121 Error response 122 */ 123 type UpdateTaskDefault struct { 124 _statusCode int 125 126 XErrorCode string 127 128 Payload *models.Error 129 } 130 131 // Code gets the status code for the update task default response 132 func (o *UpdateTaskDefault) Code() int { 133 return o._statusCode 134 } 135 136 func (o *UpdateTaskDefault) Error() string { 137 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTask default %+v", o._statusCode, o.Payload) 138 } 139 140 func (o *UpdateTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 141 142 // response header X-Error-Code 143 o.XErrorCode = response.GetHeader("X-Error-Code") 144 145 o.Payload = new(models.Error) 146 147 // response payload 148 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 149 return err 150 } 151 152 return nil 153 }