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