github.com/jamescostian/go-swagger@v0.30.4-0.20221130163922-68364d6b567b/examples/authentication/client/customers/get_id_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package customers 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/jamescostian/go-swagger/examples/authentication/models" 16 ) 17 18 // GetIDReader is a Reader for the GetID structure. 19 type GetIDReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *GetIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewGetIDOK() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 case 401: 33 result := NewGetIDUnauthorized() 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 return nil, result 38 case 404: 39 result := NewGetIDNotFound() 40 if err := result.readResponse(response, consumer, o.formats); err != nil { 41 return nil, err 42 } 43 return nil, result 44 default: 45 result := NewGetIDDefault(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 // NewGetIDOK creates a GetIDOK with default headers values 57 func NewGetIDOK() *GetIDOK { 58 return &GetIDOK{} 59 } 60 61 /* 62 GetIDOK describes a response with status code 200, with default header values. 63 64 OK 65 */ 66 type GetIDOK struct { 67 Payload *models.Customer 68 } 69 70 // IsSuccess returns true when this get Id o k response returns a 2xx status code 71 func (o *GetIDOK) IsSuccess() bool { 72 return true 73 } 74 75 // IsRedirect returns true when this get Id o k response returns a 3xx status code 76 func (o *GetIDOK) IsRedirect() bool { 77 return false 78 } 79 80 // IsClientError returns true when this get Id o k response returns a 4xx status code 81 func (o *GetIDOK) IsClientError() bool { 82 return false 83 } 84 85 // IsServerError returns true when this get Id o k response returns a 5xx status code 86 func (o *GetIDOK) IsServerError() bool { 87 return false 88 } 89 90 // IsCode returns true when this get Id o k response returns a 4xx status code 91 func (o *GetIDOK) IsCode(code int) bool { 92 return code == 200 93 } 94 95 func (o *GetIDOK) Error() string { 96 return fmt.Sprintf("[GET /customers][%d] getIdOK %+v", 200, o.Payload) 97 } 98 99 func (o *GetIDOK) String() string { 100 return fmt.Sprintf("[GET /customers][%d] getIdOK %+v", 200, o.Payload) 101 } 102 103 func (o *GetIDOK) GetPayload() *models.Customer { 104 return o.Payload 105 } 106 107 func (o *GetIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 108 109 o.Payload = new(models.Customer) 110 111 // response payload 112 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 113 return err 114 } 115 116 return nil 117 } 118 119 // NewGetIDUnauthorized creates a GetIDUnauthorized with default headers values 120 func NewGetIDUnauthorized() *GetIDUnauthorized { 121 return &GetIDUnauthorized{} 122 } 123 124 /* 125 GetIDUnauthorized describes a response with status code 401, with default header values. 126 127 unauthorized 128 */ 129 type GetIDUnauthorized struct { 130 Payload *models.Error 131 } 132 133 // IsSuccess returns true when this get Id unauthorized response returns a 2xx status code 134 func (o *GetIDUnauthorized) IsSuccess() bool { 135 return false 136 } 137 138 // IsRedirect returns true when this get Id unauthorized response returns a 3xx status code 139 func (o *GetIDUnauthorized) IsRedirect() bool { 140 return false 141 } 142 143 // IsClientError returns true when this get Id unauthorized response returns a 4xx status code 144 func (o *GetIDUnauthorized) IsClientError() bool { 145 return true 146 } 147 148 // IsServerError returns true when this get Id unauthorized response returns a 5xx status code 149 func (o *GetIDUnauthorized) IsServerError() bool { 150 return false 151 } 152 153 // IsCode returns true when this get Id unauthorized response returns a 4xx status code 154 func (o *GetIDUnauthorized) IsCode(code int) bool { 155 return code == 401 156 } 157 158 func (o *GetIDUnauthorized) Error() string { 159 return fmt.Sprintf("[GET /customers][%d] getIdUnauthorized %+v", 401, o.Payload) 160 } 161 162 func (o *GetIDUnauthorized) String() string { 163 return fmt.Sprintf("[GET /customers][%d] getIdUnauthorized %+v", 401, o.Payload) 164 } 165 166 func (o *GetIDUnauthorized) GetPayload() *models.Error { 167 return o.Payload 168 } 169 170 func (o *GetIDUnauthorized) 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 } 181 182 // NewGetIDNotFound creates a GetIDNotFound with default headers values 183 func NewGetIDNotFound() *GetIDNotFound { 184 return &GetIDNotFound{} 185 } 186 187 /* 188 GetIDNotFound describes a response with status code 404, with default header values. 189 190 resource not found 191 */ 192 type GetIDNotFound struct { 193 Payload *models.Error 194 } 195 196 // IsSuccess returns true when this get Id not found response returns a 2xx status code 197 func (o *GetIDNotFound) IsSuccess() bool { 198 return false 199 } 200 201 // IsRedirect returns true when this get Id not found response returns a 3xx status code 202 func (o *GetIDNotFound) IsRedirect() bool { 203 return false 204 } 205 206 // IsClientError returns true when this get Id not found response returns a 4xx status code 207 func (o *GetIDNotFound) IsClientError() bool { 208 return true 209 } 210 211 // IsServerError returns true when this get Id not found response returns a 5xx status code 212 func (o *GetIDNotFound) IsServerError() bool { 213 return false 214 } 215 216 // IsCode returns true when this get Id not found response returns a 4xx status code 217 func (o *GetIDNotFound) IsCode(code int) bool { 218 return code == 404 219 } 220 221 func (o *GetIDNotFound) Error() string { 222 return fmt.Sprintf("[GET /customers][%d] getIdNotFound %+v", 404, o.Payload) 223 } 224 225 func (o *GetIDNotFound) String() string { 226 return fmt.Sprintf("[GET /customers][%d] getIdNotFound %+v", 404, o.Payload) 227 } 228 229 func (o *GetIDNotFound) GetPayload() *models.Error { 230 return o.Payload 231 } 232 233 func (o *GetIDNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 234 235 o.Payload = new(models.Error) 236 237 // response payload 238 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 239 return err 240 } 241 242 return nil 243 } 244 245 // NewGetIDDefault creates a GetIDDefault with default headers values 246 func NewGetIDDefault(code int) *GetIDDefault { 247 return &GetIDDefault{ 248 _statusCode: code, 249 } 250 } 251 252 /* 253 GetIDDefault describes a response with status code -1, with default header values. 254 255 error 256 */ 257 type GetIDDefault struct { 258 _statusCode int 259 260 Payload *models.Error 261 } 262 263 // Code gets the status code for the get Id default response 264 func (o *GetIDDefault) Code() int { 265 return o._statusCode 266 } 267 268 // IsSuccess returns true when this get Id default response returns a 2xx status code 269 func (o *GetIDDefault) IsSuccess() bool { 270 return o._statusCode/100 == 2 271 } 272 273 // IsRedirect returns true when this get Id default response returns a 3xx status code 274 func (o *GetIDDefault) IsRedirect() bool { 275 return o._statusCode/100 == 3 276 } 277 278 // IsClientError returns true when this get Id default response returns a 4xx status code 279 func (o *GetIDDefault) IsClientError() bool { 280 return o._statusCode/100 == 4 281 } 282 283 // IsServerError returns true when this get Id default response returns a 5xx status code 284 func (o *GetIDDefault) IsServerError() bool { 285 return o._statusCode/100 == 5 286 } 287 288 // IsCode returns true when this get Id default response returns a 4xx status code 289 func (o *GetIDDefault) IsCode(code int) bool { 290 return o._statusCode == code 291 } 292 293 func (o *GetIDDefault) Error() string { 294 return fmt.Sprintf("[GET /customers][%d] getId default %+v", o._statusCode, o.Payload) 295 } 296 297 func (o *GetIDDefault) String() string { 298 return fmt.Sprintf("[GET /customers][%d] getId default %+v", o._statusCode, o.Payload) 299 } 300 301 func (o *GetIDDefault) GetPayload() *models.Error { 302 return o.Payload 303 } 304 305 func (o *GetIDDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 306 307 o.Payload = new(models.Error) 308 309 // response payload 310 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 311 return err 312 } 313 314 return nil 315 }