github.com/circl-dev/go-swagger@v0.31.0/examples/authentication/client/customers/get_id_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package customers
     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/authentication/models"
    16  )
    17  
    18  // GetIDReader is a Reader for the GetID structure.
    19  type GetIDReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *GetIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 200:
    27  		result := NewGetIDOK()
    28  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    29  			return nil, err
    30  		}
    31  		return result, nil
    32  	case 401:
    33  		result := NewGetIDUnauthorized()
    34  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    35  			return nil, err
    36  		}
    37  		return nil, result
    38  	case 404:
    39  		result := NewGetIDNotFound()
    40  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    41  			return nil, err
    42  		}
    43  		return nil, result
    44  	default:
    45  		result := NewGetIDDefault(response.Code())
    46  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    47  			return nil, err
    48  		}
    49  		if response.Code()/100 == 2 {
    50  			return result, nil
    51  		}
    52  		return nil, result
    53  	}
    54  }
    55  
    56  // NewGetIDOK creates a GetIDOK with default headers values
    57  func NewGetIDOK() *GetIDOK {
    58  	return &GetIDOK{}
    59  }
    60  
    61  /* GetIDOK describes a response with status code 200, with default header values.
    62  
    63  OK
    64  */
    65  type GetIDOK struct {
    66  	Payload *models.Customer
    67  }
    68  
    69  func (o *GetIDOK) Error() string {
    70  	return fmt.Sprintf("[GET /customers][%d] getIdOK  %+v", 200, o.Payload)
    71  }
    72  func (o *GetIDOK) GetPayload() *models.Customer {
    73  	return o.Payload
    74  }
    75  
    76  func (o *GetIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    77  
    78  	o.Payload = new(models.Customer)
    79  
    80  	// response payload
    81  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
    82  		return err
    83  	}
    84  
    85  	return nil
    86  }
    87  
    88  // NewGetIDUnauthorized creates a GetIDUnauthorized with default headers values
    89  func NewGetIDUnauthorized() *GetIDUnauthorized {
    90  	return &GetIDUnauthorized{}
    91  }
    92  
    93  /* GetIDUnauthorized describes a response with status code 401, with default header values.
    94  
    95  unauthorized
    96  */
    97  type GetIDUnauthorized struct {
    98  	Payload *models.Error
    99  }
   100  
   101  func (o *GetIDUnauthorized) Error() string {
   102  	return fmt.Sprintf("[GET /customers][%d] getIdUnauthorized  %+v", 401, o.Payload)
   103  }
   104  func (o *GetIDUnauthorized) GetPayload() *models.Error {
   105  	return o.Payload
   106  }
   107  
   108  func (o *GetIDUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   109  
   110  	o.Payload = new(models.Error)
   111  
   112  	// response payload
   113  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   114  		return err
   115  	}
   116  
   117  	return nil
   118  }
   119  
   120  // NewGetIDNotFound creates a GetIDNotFound with default headers values
   121  func NewGetIDNotFound() *GetIDNotFound {
   122  	return &GetIDNotFound{}
   123  }
   124  
   125  /* GetIDNotFound describes a response with status code 404, with default header values.
   126  
   127  resource not found
   128  */
   129  type GetIDNotFound struct {
   130  	Payload *models.Error
   131  }
   132  
   133  func (o *GetIDNotFound) Error() string {
   134  	return fmt.Sprintf("[GET /customers][%d] getIdNotFound  %+v", 404, o.Payload)
   135  }
   136  func (o *GetIDNotFound) GetPayload() *models.Error {
   137  	return o.Payload
   138  }
   139  
   140  func (o *GetIDNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   141  
   142  	o.Payload = new(models.Error)
   143  
   144  	// response payload
   145  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   146  		return err
   147  	}
   148  
   149  	return nil
   150  }
   151  
   152  // NewGetIDDefault creates a GetIDDefault with default headers values
   153  func NewGetIDDefault(code int) *GetIDDefault {
   154  	return &GetIDDefault{
   155  		_statusCode: code,
   156  	}
   157  }
   158  
   159  /* GetIDDefault describes a response with status code -1, with default header values.
   160  
   161  error
   162  */
   163  type GetIDDefault struct {
   164  	_statusCode int
   165  
   166  	Payload *models.Error
   167  }
   168  
   169  // Code gets the status code for the get Id default response
   170  func (o *GetIDDefault) Code() int {
   171  	return o._statusCode
   172  }
   173  
   174  func (o *GetIDDefault) Error() string {
   175  	return fmt.Sprintf("[GET /customers][%d] getId default  %+v", o._statusCode, o.Payload)
   176  }
   177  func (o *GetIDDefault) GetPayload() *models.Error {
   178  	return o.Payload
   179  }
   180  
   181  func (o *GetIDDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   182  
   183  	o.Payload = new(models.Error)
   184  
   185  	// response payload
   186  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   187  		return err
   188  	}
   189  
   190  	return nil
   191  }