github.com/circl-dev/go-swagger@v0.31.0/examples/cli/client/todos/find_todos_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/strfmt"
    13  	"github.com/circl-dev/runtime"
    14  
    15  	"github.com/circl-dev/go-swagger/examples/cli/models"
    16  )
    17  
    18  // FindTodosReader is a Reader for the FindTodos structure.
    19  type FindTodosReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *FindTodosReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 200:
    27  		result := NewFindTodosOK()
    28  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    29  			return nil, err
    30  		}
    31  		return result, nil
    32  	default:
    33  		result := NewFindTodosDefault(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  // NewFindTodosOK creates a FindTodosOK with default headers values
    45  func NewFindTodosOK() *FindTodosOK {
    46  	return &FindTodosOK{}
    47  }
    48  
    49  /* FindTodosOK describes a response with status code 200, with default header values.
    50  
    51  list the todo operations
    52  */
    53  type FindTodosOK struct {
    54  	Payload []*models.Item
    55  }
    56  
    57  func (o *FindTodosOK) Error() string {
    58  	return fmt.Sprintf("[GET /][%d] findTodosOK  %+v", 200, o.Payload)
    59  }
    60  func (o *FindTodosOK) GetPayload() []*models.Item {
    61  	return o.Payload
    62  }
    63  
    64  func (o *FindTodosOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    65  
    66  	// response payload
    67  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
    68  		return err
    69  	}
    70  
    71  	return nil
    72  }
    73  
    74  // NewFindTodosDefault creates a FindTodosDefault with default headers values
    75  func NewFindTodosDefault(code int) *FindTodosDefault {
    76  	return &FindTodosDefault{
    77  		_statusCode: code,
    78  	}
    79  }
    80  
    81  /* FindTodosDefault describes a response with status code -1, with default header values.
    82  
    83  generic error response
    84  */
    85  type FindTodosDefault struct {
    86  	_statusCode int
    87  
    88  	Payload *models.Error
    89  }
    90  
    91  // Code gets the status code for the find todos default response
    92  func (o *FindTodosDefault) Code() int {
    93  	return o._statusCode
    94  }
    95  
    96  func (o *FindTodosDefault) Error() string {
    97  	return fmt.Sprintf("[GET /][%d] findTodos default  %+v", o._statusCode, o.Payload)
    98  }
    99  func (o *FindTodosDefault) GetPayload() *models.Error {
   100  	return o.Payload
   101  }
   102  
   103  func (o *FindTodosDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   104  
   105  	o.Payload = new(models.Error)
   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  }