github.com/emreu/go-swagger@v0.22.1/examples/task-tracker/client/tasks/upload_task_file_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package tasks
     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  
    14  	strfmt "github.com/go-openapi/strfmt"
    15  
    16  	models "github.com/go-swagger/go-swagger/examples/task-tracker/models"
    17  )
    18  
    19  // UploadTaskFileReader is a Reader for the UploadTaskFile structure.
    20  type UploadTaskFileReader struct {
    21  	formats strfmt.Registry
    22  }
    23  
    24  // ReadResponse reads a server response into the received o.
    25  func (o *UploadTaskFileReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    26  	switch response.Code() {
    27  	case 201:
    28  		result := NewUploadTaskFileCreated()
    29  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    30  			return nil, err
    31  		}
    32  		return result, nil
    33  	default:
    34  		result := NewUploadTaskFileDefault(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  // NewUploadTaskFileCreated creates a UploadTaskFileCreated with default headers values
    46  func NewUploadTaskFileCreated() *UploadTaskFileCreated {
    47  	return &UploadTaskFileCreated{}
    48  }
    49  
    50  /*UploadTaskFileCreated handles this case with default header values.
    51  
    52  File added
    53  */
    54  type UploadTaskFileCreated struct {
    55  }
    56  
    57  func (o *UploadTaskFileCreated) Error() string {
    58  	return fmt.Sprintf("[POST /tasks/{id}/files][%d] uploadTaskFileCreated ", 201)
    59  }
    60  
    61  func (o *UploadTaskFileCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    62  
    63  	return nil
    64  }
    65  
    66  // NewUploadTaskFileDefault creates a UploadTaskFileDefault with default headers values
    67  func NewUploadTaskFileDefault(code int) *UploadTaskFileDefault {
    68  	return &UploadTaskFileDefault{
    69  		_statusCode: code,
    70  	}
    71  }
    72  
    73  /*UploadTaskFileDefault handles this case with default header values.
    74  
    75  Error response
    76  */
    77  type UploadTaskFileDefault struct {
    78  	_statusCode int
    79  
    80  	XErrorCode string
    81  
    82  	Payload *models.Error
    83  }
    84  
    85  // Code gets the status code for the upload task file default response
    86  func (o *UploadTaskFileDefault) Code() int {
    87  	return o._statusCode
    88  }
    89  
    90  func (o *UploadTaskFileDefault) Error() string {
    91  	return fmt.Sprintf("[POST /tasks/{id}/files][%d] uploadTaskFile default  %+v", o._statusCode, o.Payload)
    92  }
    93  
    94  func (o *UploadTaskFileDefault) GetPayload() *models.Error {
    95  	return o.Payload
    96  }
    97  
    98  func (o *UploadTaskFileDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    99  
   100  	// response header X-Error-Code
   101  	o.XErrorCode = response.GetHeader("X-Error-Code")
   102  
   103  	o.Payload = new(models.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  }