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