github.com/djarvur/go-swagger@v0.18.0/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  
    28  	case 201:
    29  		result := NewUploadTaskFileCreated()
    30  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    31  			return nil, err
    32  		}
    33  		return result, nil
    34  
    35  	default:
    36  		result := NewUploadTaskFileDefault(response.Code())
    37  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    38  			return nil, err
    39  		}
    40  		if response.Code()/100 == 2 {
    41  			return result, nil
    42  		}
    43  		return nil, result
    44  	}
    45  }
    46  
    47  // NewUploadTaskFileCreated creates a UploadTaskFileCreated with default headers values
    48  func NewUploadTaskFileCreated() *UploadTaskFileCreated {
    49  	return &UploadTaskFileCreated{}
    50  }
    51  
    52  /*UploadTaskFileCreated handles this case with default header values.
    53  
    54  File added
    55  */
    56  type UploadTaskFileCreated struct {
    57  }
    58  
    59  func (o *UploadTaskFileCreated) Error() string {
    60  	return fmt.Sprintf("[POST /tasks/{id}/files][%d] uploadTaskFileCreated ", 201)
    61  }
    62  
    63  func (o *UploadTaskFileCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    64  
    65  	return nil
    66  }
    67  
    68  // NewUploadTaskFileDefault creates a UploadTaskFileDefault with default headers values
    69  func NewUploadTaskFileDefault(code int) *UploadTaskFileDefault {
    70  	return &UploadTaskFileDefault{
    71  		_statusCode: code,
    72  	}
    73  }
    74  
    75  /*UploadTaskFileDefault handles this case with default header values.
    76  
    77  Error response
    78  */
    79  type UploadTaskFileDefault struct {
    80  	_statusCode int
    81  
    82  	XErrorCode string
    83  
    84  	Payload *models.Error
    85  }
    86  
    87  // Code gets the status code for the upload task file default response
    88  func (o *UploadTaskFileDefault) Code() int {
    89  	return o._statusCode
    90  }
    91  
    92  func (o *UploadTaskFileDefault) Error() string {
    93  	return fmt.Sprintf("[POST /tasks/{id}/files][%d] uploadTaskFile default  %+v", o._statusCode, o.Payload)
    94  }
    95  
    96  func (o *UploadTaskFileDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    97  
    98  	// response header X-Error-Code
    99  	o.XErrorCode = response.GetHeader("X-Error-Code")
   100  
   101  	o.Payload = new(models.Error)
   102  
   103  	// response payload
   104  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   105  		return err
   106  	}
   107  
   108  	return nil
   109  }