github.com/jamescostian/go-swagger@v0.30.4-0.20221130163922-68364d6b567b/examples/task-tracker/client/tasks/add_comment_to_task_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 "context" 10 "fmt" 11 "io" 12 13 "github.com/go-openapi/errors" 14 "github.com/go-openapi/runtime" 15 "github.com/go-openapi/strfmt" 16 "github.com/go-openapi/swag" 17 "github.com/go-openapi/validate" 18 19 "github.com/jamescostian/go-swagger/examples/task-tracker/models" 20 ) 21 22 // AddCommentToTaskReader is a Reader for the AddCommentToTask structure. 23 type AddCommentToTaskReader struct { 24 formats strfmt.Registry 25 } 26 27 // ReadResponse reads a server response into the received o. 28 func (o *AddCommentToTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 29 switch response.Code() { 30 case 201: 31 result := NewAddCommentToTaskCreated() 32 if err := result.readResponse(response, consumer, o.formats); err != nil { 33 return nil, err 34 } 35 return result, nil 36 default: 37 result := NewAddCommentToTaskDefault(response.Code()) 38 if err := result.readResponse(response, consumer, o.formats); err != nil { 39 return nil, err 40 } 41 if response.Code()/100 == 2 { 42 return result, nil 43 } 44 return nil, result 45 } 46 } 47 48 // NewAddCommentToTaskCreated creates a AddCommentToTaskCreated with default headers values 49 func NewAddCommentToTaskCreated() *AddCommentToTaskCreated { 50 return &AddCommentToTaskCreated{} 51 } 52 53 /* 54 AddCommentToTaskCreated describes a response with status code 201, with default header values. 55 56 Comment added 57 */ 58 type AddCommentToTaskCreated struct { 59 } 60 61 // IsSuccess returns true when this add comment to task created response returns a 2xx status code 62 func (o *AddCommentToTaskCreated) IsSuccess() bool { 63 return true 64 } 65 66 // IsRedirect returns true when this add comment to task created response returns a 3xx status code 67 func (o *AddCommentToTaskCreated) IsRedirect() bool { 68 return false 69 } 70 71 // IsClientError returns true when this add comment to task created response returns a 4xx status code 72 func (o *AddCommentToTaskCreated) IsClientError() bool { 73 return false 74 } 75 76 // IsServerError returns true when this add comment to task created response returns a 5xx status code 77 func (o *AddCommentToTaskCreated) IsServerError() bool { 78 return false 79 } 80 81 // IsCode returns true when this add comment to task created response returns a 4xx status code 82 func (o *AddCommentToTaskCreated) IsCode(code int) bool { 83 return code == 201 84 } 85 86 func (o *AddCommentToTaskCreated) Error() string { 87 return fmt.Sprintf("[POST /tasks/{id}/comments][%d] addCommentToTaskCreated ", 201) 88 } 89 90 func (o *AddCommentToTaskCreated) String() string { 91 return fmt.Sprintf("[POST /tasks/{id}/comments][%d] addCommentToTaskCreated ", 201) 92 } 93 94 func (o *AddCommentToTaskCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 95 96 return nil 97 } 98 99 // NewAddCommentToTaskDefault creates a AddCommentToTaskDefault with default headers values 100 func NewAddCommentToTaskDefault(code int) *AddCommentToTaskDefault { 101 return &AddCommentToTaskDefault{ 102 _statusCode: code, 103 } 104 } 105 106 /* 107 AddCommentToTaskDefault describes a response with status code -1, with default header values. 108 109 Error response 110 */ 111 type AddCommentToTaskDefault struct { 112 _statusCode int 113 XErrorCode string 114 115 Payload *models.Error 116 } 117 118 // Code gets the status code for the add comment to task default response 119 func (o *AddCommentToTaskDefault) Code() int { 120 return o._statusCode 121 } 122 123 // IsSuccess returns true when this add comment to task default response returns a 2xx status code 124 func (o *AddCommentToTaskDefault) IsSuccess() bool { 125 return o._statusCode/100 == 2 126 } 127 128 // IsRedirect returns true when this add comment to task default response returns a 3xx status code 129 func (o *AddCommentToTaskDefault) IsRedirect() bool { 130 return o._statusCode/100 == 3 131 } 132 133 // IsClientError returns true when this add comment to task default response returns a 4xx status code 134 func (o *AddCommentToTaskDefault) IsClientError() bool { 135 return o._statusCode/100 == 4 136 } 137 138 // IsServerError returns true when this add comment to task default response returns a 5xx status code 139 func (o *AddCommentToTaskDefault) IsServerError() bool { 140 return o._statusCode/100 == 5 141 } 142 143 // IsCode returns true when this add comment to task default response returns a 4xx status code 144 func (o *AddCommentToTaskDefault) IsCode(code int) bool { 145 return o._statusCode == code 146 } 147 148 func (o *AddCommentToTaskDefault) Error() string { 149 return fmt.Sprintf("[POST /tasks/{id}/comments][%d] addCommentToTask default %+v", o._statusCode, o.Payload) 150 } 151 152 func (o *AddCommentToTaskDefault) String() string { 153 return fmt.Sprintf("[POST /tasks/{id}/comments][%d] addCommentToTask default %+v", o._statusCode, o.Payload) 154 } 155 156 func (o *AddCommentToTaskDefault) GetPayload() *models.Error { 157 return o.Payload 158 } 159 160 func (o *AddCommentToTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 161 162 // hydrates response header X-Error-Code 163 hdrXErrorCode := response.GetHeader("X-Error-Code") 164 165 if hdrXErrorCode != "" { 166 o.XErrorCode = hdrXErrorCode 167 } 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 } 178 179 /* 180 AddCommentToTaskBody A comment to create 181 // 182 // These values can have github flavored markdown. 183 // 184 swagger:model AddCommentToTaskBody 185 */ 186 type AddCommentToTaskBody struct { 187 188 // content 189 // Required: true 190 Content *string `json:"content"` 191 192 // user Id 193 // Required: true 194 UserID *int64 `json:"userId"` 195 } 196 197 // Validate validates this add comment to task body 198 func (o *AddCommentToTaskBody) Validate(formats strfmt.Registry) error { 199 var res []error 200 201 if err := o.validateContent(formats); err != nil { 202 res = append(res, err) 203 } 204 205 if err := o.validateUserID(formats); err != nil { 206 res = append(res, err) 207 } 208 209 if len(res) > 0 { 210 return errors.CompositeValidationError(res...) 211 } 212 return nil 213 } 214 215 func (o *AddCommentToTaskBody) validateContent(formats strfmt.Registry) error { 216 217 if err := validate.Required("body"+"."+"content", "body", o.Content); err != nil { 218 return err 219 } 220 221 return nil 222 } 223 224 func (o *AddCommentToTaskBody) validateUserID(formats strfmt.Registry) error { 225 226 if err := validate.Required("body"+"."+"userId", "body", o.UserID); err != nil { 227 return err 228 } 229 230 return nil 231 } 232 233 // ContextValidate validates this add comment to task body based on context it is used 234 func (o *AddCommentToTaskBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 235 return nil 236 } 237 238 // MarshalBinary interface implementation 239 func (o *AddCommentToTaskBody) MarshalBinary() ([]byte, error) { 240 if o == nil { 241 return nil, nil 242 } 243 return swag.WriteJSON(o) 244 } 245 246 // UnmarshalBinary interface implementation 247 func (o *AddCommentToTaskBody) UnmarshalBinary(b []byte) error { 248 var res AddCommentToTaskBody 249 if err := swag.ReadJSON(b, &res); err != nil { 250 return err 251 } 252 *o = res 253 return nil 254 }