github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/todo-list/client/todos/find_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  	"encoding/json"
    10  	"fmt"
    11  	"io"
    12  
    13  	"github.com/go-openapi/runtime"
    14  	"github.com/go-openapi/strfmt"
    15  
    16  	"github.com/thetreep/go-swagger/examples/todo-list/models"
    17  )
    18  
    19  // FindReader is a Reader for the Find structure.
    20  type FindReader struct {
    21  	formats strfmt.Registry
    22  }
    23  
    24  // ReadResponse reads a server response into the received o.
    25  func (o *FindReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    26  	switch response.Code() {
    27  	case 200:
    28  		result := NewFindOK()
    29  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    30  			return nil, err
    31  		}
    32  		return result, nil
    33  	default:
    34  		result := NewFindDefault(response.Code())
    35  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    36  			return nil, err
    37  		}
    38  		if response.Code()/100 == 2 {
    39  			return result, nil
    40  		}
    41  		return nil, result
    42  	}
    43  }
    44  
    45  // NewFindOK creates a FindOK with default headers values
    46  func NewFindOK() *FindOK {
    47  	return &FindOK{}
    48  }
    49  
    50  /*
    51  FindOK describes a response with status code 200, with default header values.
    52  
    53  OK
    54  */
    55  type FindOK struct {
    56  	Payload []*models.Item
    57  }
    58  
    59  // IsSuccess returns true when this find o k response has a 2xx status code
    60  func (o *FindOK) IsSuccess() bool {
    61  	return true
    62  }
    63  
    64  // IsRedirect returns true when this find o k response has a 3xx status code
    65  func (o *FindOK) IsRedirect() bool {
    66  	return false
    67  }
    68  
    69  // IsClientError returns true when this find o k response has a 4xx status code
    70  func (o *FindOK) IsClientError() bool {
    71  	return false
    72  }
    73  
    74  // IsServerError returns true when this find o k response has a 5xx status code
    75  func (o *FindOK) IsServerError() bool {
    76  	return false
    77  }
    78  
    79  // IsCode returns true when this find o k response a status code equal to that given
    80  func (o *FindOK) IsCode(code int) bool {
    81  	return code == 200
    82  }
    83  
    84  // Code gets the status code for the find o k response
    85  func (o *FindOK) Code() int {
    86  	return 200
    87  }
    88  
    89  func (o *FindOK) Error() string {
    90  	payload, _ := json.Marshal(o.Payload)
    91  	return fmt.Sprintf("[GET /][%d] findOK %s", 200, payload)
    92  }
    93  
    94  func (o *FindOK) String() string {
    95  	payload, _ := json.Marshal(o.Payload)
    96  	return fmt.Sprintf("[GET /][%d] findOK %s", 200, payload)
    97  }
    98  
    99  func (o *FindOK) GetPayload() []*models.Item {
   100  	return o.Payload
   101  }
   102  
   103  func (o *FindOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   104  
   105  	// response payload
   106  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
   107  		return err
   108  	}
   109  
   110  	return nil
   111  }
   112  
   113  // NewFindDefault creates a FindDefault with default headers values
   114  func NewFindDefault(code int) *FindDefault {
   115  	return &FindDefault{
   116  		_statusCode: code,
   117  	}
   118  }
   119  
   120  /*
   121  FindDefault describes a response with status code -1, with default header values.
   122  
   123  error
   124  */
   125  type FindDefault struct {
   126  	_statusCode int
   127  
   128  	Payload *models.Error
   129  }
   130  
   131  // IsSuccess returns true when this find default response has a 2xx status code
   132  func (o *FindDefault) IsSuccess() bool {
   133  	return o._statusCode/100 == 2
   134  }
   135  
   136  // IsRedirect returns true when this find default response has a 3xx status code
   137  func (o *FindDefault) IsRedirect() bool {
   138  	return o._statusCode/100 == 3
   139  }
   140  
   141  // IsClientError returns true when this find default response has a 4xx status code
   142  func (o *FindDefault) IsClientError() bool {
   143  	return o._statusCode/100 == 4
   144  }
   145  
   146  // IsServerError returns true when this find default response has a 5xx status code
   147  func (o *FindDefault) IsServerError() bool {
   148  	return o._statusCode/100 == 5
   149  }
   150  
   151  // IsCode returns true when this find default response a status code equal to that given
   152  func (o *FindDefault) IsCode(code int) bool {
   153  	return o._statusCode == code
   154  }
   155  
   156  // Code gets the status code for the find default response
   157  func (o *FindDefault) Code() int {
   158  	return o._statusCode
   159  }
   160  
   161  func (o *FindDefault) Error() string {
   162  	payload, _ := json.Marshal(o.Payload)
   163  	return fmt.Sprintf("[GET /][%d] find default %s", o._statusCode, payload)
   164  }
   165  
   166  func (o *FindDefault) String() string {
   167  	payload, _ := json.Marshal(o.Payload)
   168  	return fmt.Sprintf("[GET /][%d] find default %s", o._statusCode, payload)
   169  }
   170  
   171  func (o *FindDefault) GetPayload() *models.Error {
   172  	return o.Payload
   173  }
   174  
   175  func (o *FindDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   176  
   177  	o.Payload = new(models.Error)
   178  
   179  	// response payload
   180  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   181  		return err
   182  	}
   183  
   184  	return nil
   185  }