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