github.com/emreu/go-swagger@v0.22.1/examples/task-tracker/client/tasks/update_task_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  // UpdateTaskReader is a Reader for the UpdateTask structure.
    20  type UpdateTaskReader struct {
    21  	formats strfmt.Registry
    22  }
    23  
    24  // ReadResponse reads a server response into the received o.
    25  func (o *UpdateTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    26  	switch response.Code() {
    27  	case 200:
    28  		result := NewUpdateTaskOK()
    29  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    30  			return nil, err
    31  		}
    32  		return result, nil
    33  	case 422:
    34  		result := NewUpdateTaskUnprocessableEntity()
    35  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    36  			return nil, err
    37  		}
    38  		return nil, result
    39  	default:
    40  		result := NewUpdateTaskDefault(response.Code())
    41  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    42  			return nil, err
    43  		}
    44  		if response.Code()/100 == 2 {
    45  			return result, nil
    46  		}
    47  		return nil, result
    48  	}
    49  }
    50  
    51  // NewUpdateTaskOK creates a UpdateTaskOK with default headers values
    52  func NewUpdateTaskOK() *UpdateTaskOK {
    53  	return &UpdateTaskOK{}
    54  }
    55  
    56  /*UpdateTaskOK handles this case with default header values.
    57  
    58  Task details
    59  */
    60  type UpdateTaskOK struct {
    61  	Payload *models.Task
    62  }
    63  
    64  func (o *UpdateTaskOK) Error() string {
    65  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskOK  %+v", 200, o.Payload)
    66  }
    67  
    68  func (o *UpdateTaskOK) GetPayload() *models.Task {
    69  	return o.Payload
    70  }
    71  
    72  func (o *UpdateTaskOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    73  
    74  	o.Payload = new(models.Task)
    75  
    76  	// response payload
    77  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
    78  		return err
    79  	}
    80  
    81  	return nil
    82  }
    83  
    84  // NewUpdateTaskUnprocessableEntity creates a UpdateTaskUnprocessableEntity with default headers values
    85  func NewUpdateTaskUnprocessableEntity() *UpdateTaskUnprocessableEntity {
    86  	return &UpdateTaskUnprocessableEntity{}
    87  }
    88  
    89  /*UpdateTaskUnprocessableEntity handles this case with default header values.
    90  
    91  Validation error
    92  */
    93  type UpdateTaskUnprocessableEntity struct {
    94  	Payload *models.ValidationError
    95  }
    96  
    97  func (o *UpdateTaskUnprocessableEntity) Error() string {
    98  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskUnprocessableEntity  %+v", 422, o.Payload)
    99  }
   100  
   101  func (o *UpdateTaskUnprocessableEntity) GetPayload() *models.ValidationError {
   102  	return o.Payload
   103  }
   104  
   105  func (o *UpdateTaskUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   106  
   107  	o.Payload = new(models.ValidationError)
   108  
   109  	// response payload
   110  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   111  		return err
   112  	}
   113  
   114  	return nil
   115  }
   116  
   117  // NewUpdateTaskDefault creates a UpdateTaskDefault with default headers values
   118  func NewUpdateTaskDefault(code int) *UpdateTaskDefault {
   119  	return &UpdateTaskDefault{
   120  		_statusCode: code,
   121  	}
   122  }
   123  
   124  /*UpdateTaskDefault handles this case with default header values.
   125  
   126  Error response
   127  */
   128  type UpdateTaskDefault struct {
   129  	_statusCode int
   130  
   131  	XErrorCode string
   132  
   133  	Payload *models.Error
   134  }
   135  
   136  // Code gets the status code for the update task default response
   137  func (o *UpdateTaskDefault) Code() int {
   138  	return o._statusCode
   139  }
   140  
   141  func (o *UpdateTaskDefault) Error() string {
   142  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTask default  %+v", o._statusCode, o.Payload)
   143  }
   144  
   145  func (o *UpdateTaskDefault) GetPayload() *models.Error {
   146  	return o.Payload
   147  }
   148  
   149  func (o *UpdateTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   150  
   151  	// response header X-Error-Code
   152  	o.XErrorCode = response.GetHeader("X-Error-Code")
   153  
   154  	o.Payload = new(models.Error)
   155  
   156  	// response payload
   157  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   158  		return err
   159  	}
   160  
   161  	return nil
   162  }