github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/examples/todo-list/client/todos/find_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package todos 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 "github.com/go-openapi/strfmt" 14 15 "github.com/go-swagger/go-swagger/examples/todo-list/models" 16 ) 17 18 // FindReader is a Reader for the Find structure. 19 type FindReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *FindReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewFindOK() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 default: 33 result := NewFindDefault(response.Code()) 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 if response.Code()/100 == 2 { 38 return result, nil 39 } 40 return nil, result 41 } 42 } 43 44 // NewFindOK creates a FindOK with default headers values 45 func NewFindOK() *FindOK { 46 return &FindOK{} 47 } 48 49 /* 50 FindOK describes a response with status code 200, with default header values. 51 52 OK 53 */ 54 type FindOK struct { 55 Payload []*models.Item 56 } 57 58 // IsSuccess returns true when this find o k response has a 2xx status code 59 func (o *FindOK) IsSuccess() bool { 60 return true 61 } 62 63 // IsRedirect returns true when this find o k response has a 3xx status code 64 func (o *FindOK) IsRedirect() bool { 65 return false 66 } 67 68 // IsClientError returns true when this find o k response has a 4xx status code 69 func (o *FindOK) IsClientError() bool { 70 return false 71 } 72 73 // IsServerError returns true when this find o k response has a 5xx status code 74 func (o *FindOK) IsServerError() bool { 75 return false 76 } 77 78 // IsCode returns true when this find o k response a status code equal to that given 79 func (o *FindOK) IsCode(code int) bool { 80 return code == 200 81 } 82 83 // Code gets the status code for the find o k response 84 func (o *FindOK) Code() int { 85 return 200 86 } 87 88 func (o *FindOK) Error() string { 89 return fmt.Sprintf("[GET /][%d] findOK %+v", 200, o.Payload) 90 } 91 92 func (o *FindOK) String() string { 93 return fmt.Sprintf("[GET /][%d] findOK %+v", 200, o.Payload) 94 } 95 96 func (o *FindOK) GetPayload() []*models.Item { 97 return o.Payload 98 } 99 100 func (o *FindOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 101 102 // response payload 103 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 104 return err 105 } 106 107 return nil 108 } 109 110 // NewFindDefault creates a FindDefault with default headers values 111 func NewFindDefault(code int) *FindDefault { 112 return &FindDefault{ 113 _statusCode: code, 114 } 115 } 116 117 /* 118 FindDefault describes a response with status code -1, with default header values. 119 120 error 121 */ 122 type FindDefault struct { 123 _statusCode int 124 125 Payload *models.Error 126 } 127 128 // IsSuccess returns true when this find default response has a 2xx status code 129 func (o *FindDefault) IsSuccess() bool { 130 return o._statusCode/100 == 2 131 } 132 133 // IsRedirect returns true when this find default response has a 3xx status code 134 func (o *FindDefault) IsRedirect() bool { 135 return o._statusCode/100 == 3 136 } 137 138 // IsClientError returns true when this find default response has a 4xx status code 139 func (o *FindDefault) IsClientError() bool { 140 return o._statusCode/100 == 4 141 } 142 143 // IsServerError returns true when this find default response has a 5xx status code 144 func (o *FindDefault) IsServerError() bool { 145 return o._statusCode/100 == 5 146 } 147 148 // IsCode returns true when this find default response a status code equal to that given 149 func (o *FindDefault) IsCode(code int) bool { 150 return o._statusCode == code 151 } 152 153 // Code gets the status code for the find default response 154 func (o *FindDefault) Code() int { 155 return o._statusCode 156 } 157 158 func (o *FindDefault) Error() string { 159 return fmt.Sprintf("[GET /][%d] find default %+v", o._statusCode, o.Payload) 160 } 161 162 func (o *FindDefault) String() string { 163 return fmt.Sprintf("[GET /][%d] find default %+v", o._statusCode, o.Payload) 164 } 165 166 func (o *FindDefault) GetPayload() *models.Error { 167 return o.Payload 168 } 169 170 func (o *FindDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 171 172 o.Payload = new(models.Error) 173 174 // response payload 175 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 176 return err 177 } 178 179 return nil 180 }