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