github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/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 has 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 has 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 has 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 has 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 a status code equal to that given
    79  func (o *UpdateOneOK) IsCode(code int) bool {
    80  	return code == 200
    81  }
    82  
    83  // Code gets the status code for the update one o k response
    84  func (o *UpdateOneOK) Code() int {
    85  	return 200
    86  }
    87  
    88  func (o *UpdateOneOK) Error() string {
    89  	return fmt.Sprintf("[PUT /{id}][%d] updateOneOK  %+v", 200, o.Payload)
    90  }
    91  
    92  func (o *UpdateOneOK) String() string {
    93  	return fmt.Sprintf("[PUT /{id}][%d] updateOneOK  %+v", 200, o.Payload)
    94  }
    95  
    96  func (o *UpdateOneOK) GetPayload() *models.Item {
    97  	return o.Payload
    98  }
    99  
   100  func (o *UpdateOneOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   101  
   102  	o.Payload = new(models.Item)
   103  
   104  	// response payload
   105  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   106  		return err
   107  	}
   108  
   109  	return nil
   110  }
   111  
   112  // NewUpdateOneDefault creates a UpdateOneDefault with default headers values
   113  func NewUpdateOneDefault(code int) *UpdateOneDefault {
   114  	return &UpdateOneDefault{
   115  		_statusCode: code,
   116  	}
   117  }
   118  
   119  /*
   120  UpdateOneDefault describes a response with status code -1, with default header values.
   121  
   122  error
   123  */
   124  type UpdateOneDefault struct {
   125  	_statusCode int
   126  
   127  	Payload *models.Error
   128  }
   129  
   130  // IsSuccess returns true when this update one default response has 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 has 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 has 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 has 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 a status code equal to that given
   151  func (o *UpdateOneDefault) IsCode(code int) bool {
   152  	return o._statusCode == code
   153  }
   154  
   155  // Code gets the status code for the update one default response
   156  func (o *UpdateOneDefault) Code() int {
   157  	return o._statusCode
   158  }
   159  
   160  func (o *UpdateOneDefault) Error() string {
   161  	return fmt.Sprintf("[PUT /{id}][%d] updateOne default  %+v", o._statusCode, o.Payload)
   162  }
   163  
   164  func (o *UpdateOneDefault) String() string {
   165  	return fmt.Sprintf("[PUT /{id}][%d] updateOne default  %+v", o._statusCode, o.Payload)
   166  }
   167  
   168  func (o *UpdateOneDefault) GetPayload() *models.Error {
   169  	return o.Payload
   170  }
   171  
   172  func (o *UpdateOneDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   173  
   174  	o.Payload = new(models.Error)
   175  
   176  	// response payload
   177  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   178  		return err
   179  	}
   180  
   181  	return nil
   182  }