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