github.com/circl-dev/go-swagger@v0.31.0/examples/todo-list-strict/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/strfmt"
    13  	"github.com/circl-dev/runtime"
    14  
    15  	"github.com/circl-dev/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  /*AddOneCreated handles this case with default header values.
    50  
    51  Created
    52  */
    53  type AddOneCreated struct {
    54  	Payload *models.Item
    55  }
    56  
    57  func (o *AddOneCreated) Error() string {
    58  	return fmt.Sprintf("[POST /][%d] addOneCreated  %+v", 201, o.Payload)
    59  }
    60  
    61  func (o *AddOneCreated) GetPayload() *models.Item {
    62  	return o.Payload
    63  }
    64  
    65  func (o *AddOneCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    66  
    67  	o.Payload = new(models.Item)
    68  
    69  	// response payload
    70  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
    71  		return err
    72  	}
    73  
    74  	return nil
    75  }
    76  
    77  // NewAddOneDefault creates a AddOneDefault with default headers values
    78  func NewAddOneDefault(code int) *AddOneDefault {
    79  	return &AddOneDefault{
    80  		_statusCode: code,
    81  	}
    82  }
    83  
    84  /*AddOneDefault handles this case with default header values.
    85  
    86  error
    87  */
    88  type AddOneDefault struct {
    89  	_statusCode int
    90  
    91  	Payload *models.Error
    92  }
    93  
    94  // Code gets the status code for the add one default response
    95  func (o *AddOneDefault) Code() int {
    96  	return o._statusCode
    97  }
    98  
    99  func (o *AddOneDefault) Error() string {
   100  	return fmt.Sprintf("[POST /][%d] addOne default  %+v", o._statusCode, o.Payload)
   101  }
   102  
   103  func (o *AddOneDefault) GetPayload() *models.Error {
   104  	return o.Payload
   105  }
   106  
   107  func (o *AddOneDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   108  
   109  	o.Payload = new(models.Error)
   110  
   111  	// response payload
   112  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   113  		return err
   114  	}
   115  
   116  	return nil
   117  }