github.com/djarvur/go-swagger@v0.18.0/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 28 case 200: 29 result := NewGetTaskDetailsOK() 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 := NewGetTaskDetailsUnprocessableEntity() 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 := NewGetTaskDetailsDefault(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 // NewGetTaskDetailsOK creates a GetTaskDetailsOK with default headers values 55 func NewGetTaskDetailsOK() *GetTaskDetailsOK { 56 return &GetTaskDetailsOK{} 57 } 58 59 /*GetTaskDetailsOK handles this case with default header values. 60 61 Task details 62 */ 63 type GetTaskDetailsOK struct { 64 Payload *models.Task 65 } 66 67 func (o *GetTaskDetailsOK) Error() string { 68 return fmt.Sprintf("[GET /tasks/{id}][%d] getTaskDetailsOK %+v", 200, o.Payload) 69 } 70 71 func (o *GetTaskDetailsOK) 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 // NewGetTaskDetailsUnprocessableEntity creates a GetTaskDetailsUnprocessableEntity with default headers values 84 func NewGetTaskDetailsUnprocessableEntity() *GetTaskDetailsUnprocessableEntity { 85 return &GetTaskDetailsUnprocessableEntity{} 86 } 87 88 /*GetTaskDetailsUnprocessableEntity handles this case with default header values. 89 90 Validation error 91 */ 92 type GetTaskDetailsUnprocessableEntity struct { 93 Payload *models.ValidationError 94 } 95 96 func (o *GetTaskDetailsUnprocessableEntity) Error() string { 97 return fmt.Sprintf("[GET /tasks/{id}][%d] getTaskDetailsUnprocessableEntity %+v", 422, o.Payload) 98 } 99 100 func (o *GetTaskDetailsUnprocessableEntity) 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 // NewGetTaskDetailsDefault creates a GetTaskDetailsDefault with default headers values 113 func NewGetTaskDetailsDefault(code int) *GetTaskDetailsDefault { 114 return &GetTaskDetailsDefault{ 115 _statusCode: code, 116 } 117 } 118 119 /*GetTaskDetailsDefault handles this case with default header values. 120 121 Error response 122 */ 123 type GetTaskDetailsDefault struct { 124 _statusCode int 125 126 XErrorCode string 127 128 Payload *models.Error 129 } 130 131 // Code gets the status code for the get task details default response 132 func (o *GetTaskDetailsDefault) Code() int { 133 return o._statusCode 134 } 135 136 func (o *GetTaskDetailsDefault) Error() string { 137 return fmt.Sprintf("[GET /tasks/{id}][%d] getTaskDetails default %+v", o._statusCode, o.Payload) 138 } 139 140 func (o *GetTaskDetailsDefault) 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 }