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