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