github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/todo-list-strict/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/thetreep/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 handles this case with default header values.
    51  
    52  OK
    53  */
    54  type UpdateOneOK struct {
    55  	Payload *models.Item
    56  }
    57  
    58  func (o *UpdateOneOK) Error() string {
    59  	return fmt.Sprintf("[PUT /{id}][%d] updateOneOK  %+v", 200, o.Payload)
    60  }
    61  
    62  func (o *UpdateOneOK) GetPayload() *models.Item {
    63  	return o.Payload
    64  }
    65  
    66  func (o *UpdateOneOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    67  
    68  	o.Payload = new(models.Item)
    69  
    70  	// response payload
    71  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
    72  		return err
    73  	}
    74  
    75  	return nil
    76  }
    77  
    78  // NewUpdateOneDefault creates a UpdateOneDefault with default headers values
    79  func NewUpdateOneDefault(code int) *UpdateOneDefault {
    80  	return &UpdateOneDefault{
    81  		_statusCode: code,
    82  	}
    83  }
    84  
    85  /*
    86  UpdateOneDefault handles this case with default header values.
    87  
    88  error
    89  */
    90  type UpdateOneDefault struct {
    91  	_statusCode int
    92  
    93  	Payload *models.Error
    94  }
    95  
    96  // Code gets the status code for the update one default response
    97  func (o *UpdateOneDefault) Code() int {
    98  	return o._statusCode
    99  }
   100  
   101  func (o *UpdateOneDefault) Error() string {
   102  	return fmt.Sprintf("[PUT /{id}][%d] updateOne default  %+v", o._statusCode, o.Payload)
   103  }
   104  
   105  func (o *UpdateOneDefault) GetPayload() *models.Error {
   106  	return o.Payload
   107  }
   108  
   109  func (o *UpdateOneDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   110  
   111  	o.Payload = new(models.Error)
   112  
   113  	// response payload
   114  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   115  		return err
   116  	}
   117  
   118  	return nil
   119  }