github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/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/runtime"
    13  	"github.com/go-openapi/strfmt"
    14  
    15  	"github.com/go-swagger/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  /*
    62  GetIDOK describes a response with status code 200, with default header values.
    63  
    64  OK
    65  */
    66  type GetIDOK struct {
    67  	Payload *models.Customer
    68  }
    69  
    70  // IsSuccess returns true when this get Id o k response has a 2xx status code
    71  func (o *GetIDOK) IsSuccess() bool {
    72  	return true
    73  }
    74  
    75  // IsRedirect returns true when this get Id o k response has a 3xx status code
    76  func (o *GetIDOK) IsRedirect() bool {
    77  	return false
    78  }
    79  
    80  // IsClientError returns true when this get Id o k response has a 4xx status code
    81  func (o *GetIDOK) IsClientError() bool {
    82  	return false
    83  }
    84  
    85  // IsServerError returns true when this get Id o k response has a 5xx status code
    86  func (o *GetIDOK) IsServerError() bool {
    87  	return false
    88  }
    89  
    90  // IsCode returns true when this get Id o k response a status code equal to that given
    91  func (o *GetIDOK) IsCode(code int) bool {
    92  	return code == 200
    93  }
    94  
    95  // Code gets the status code for the get Id o k response
    96  func (o *GetIDOK) Code() int {
    97  	return 200
    98  }
    99  
   100  func (o *GetIDOK) Error() string {
   101  	return fmt.Sprintf("[GET /customers][%d] getIdOK  %+v", 200, o.Payload)
   102  }
   103  
   104  func (o *GetIDOK) String() string {
   105  	return fmt.Sprintf("[GET /customers][%d] getIdOK  %+v", 200, o.Payload)
   106  }
   107  
   108  func (o *GetIDOK) GetPayload() *models.Customer {
   109  	return o.Payload
   110  }
   111  
   112  func (o *GetIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   113  
   114  	o.Payload = new(models.Customer)
   115  
   116  	// response payload
   117  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   118  		return err
   119  	}
   120  
   121  	return nil
   122  }
   123  
   124  // NewGetIDUnauthorized creates a GetIDUnauthorized with default headers values
   125  func NewGetIDUnauthorized() *GetIDUnauthorized {
   126  	return &GetIDUnauthorized{}
   127  }
   128  
   129  /*
   130  GetIDUnauthorized describes a response with status code 401, with default header values.
   131  
   132  unauthorized
   133  */
   134  type GetIDUnauthorized struct {
   135  	Payload *models.Error
   136  }
   137  
   138  // IsSuccess returns true when this get Id unauthorized response has a 2xx status code
   139  func (o *GetIDUnauthorized) IsSuccess() bool {
   140  	return false
   141  }
   142  
   143  // IsRedirect returns true when this get Id unauthorized response has a 3xx status code
   144  func (o *GetIDUnauthorized) IsRedirect() bool {
   145  	return false
   146  }
   147  
   148  // IsClientError returns true when this get Id unauthorized response has a 4xx status code
   149  func (o *GetIDUnauthorized) IsClientError() bool {
   150  	return true
   151  }
   152  
   153  // IsServerError returns true when this get Id unauthorized response has a 5xx status code
   154  func (o *GetIDUnauthorized) IsServerError() bool {
   155  	return false
   156  }
   157  
   158  // IsCode returns true when this get Id unauthorized response a status code equal to that given
   159  func (o *GetIDUnauthorized) IsCode(code int) bool {
   160  	return code == 401
   161  }
   162  
   163  // Code gets the status code for the get Id unauthorized response
   164  func (o *GetIDUnauthorized) Code() int {
   165  	return 401
   166  }
   167  
   168  func (o *GetIDUnauthorized) Error() string {
   169  	return fmt.Sprintf("[GET /customers][%d] getIdUnauthorized  %+v", 401, o.Payload)
   170  }
   171  
   172  func (o *GetIDUnauthorized) String() string {
   173  	return fmt.Sprintf("[GET /customers][%d] getIdUnauthorized  %+v", 401, o.Payload)
   174  }
   175  
   176  func (o *GetIDUnauthorized) GetPayload() *models.Error {
   177  	return o.Payload
   178  }
   179  
   180  func (o *GetIDUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   181  
   182  	o.Payload = new(models.Error)
   183  
   184  	// response payload
   185  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   186  		return err
   187  	}
   188  
   189  	return nil
   190  }
   191  
   192  // NewGetIDNotFound creates a GetIDNotFound with default headers values
   193  func NewGetIDNotFound() *GetIDNotFound {
   194  	return &GetIDNotFound{}
   195  }
   196  
   197  /*
   198  GetIDNotFound describes a response with status code 404, with default header values.
   199  
   200  resource not found
   201  */
   202  type GetIDNotFound struct {
   203  	Payload *models.Error
   204  }
   205  
   206  // IsSuccess returns true when this get Id not found response has a 2xx status code
   207  func (o *GetIDNotFound) IsSuccess() bool {
   208  	return false
   209  }
   210  
   211  // IsRedirect returns true when this get Id not found response has a 3xx status code
   212  func (o *GetIDNotFound) IsRedirect() bool {
   213  	return false
   214  }
   215  
   216  // IsClientError returns true when this get Id not found response has a 4xx status code
   217  func (o *GetIDNotFound) IsClientError() bool {
   218  	return true
   219  }
   220  
   221  // IsServerError returns true when this get Id not found response has a 5xx status code
   222  func (o *GetIDNotFound) IsServerError() bool {
   223  	return false
   224  }
   225  
   226  // IsCode returns true when this get Id not found response a status code equal to that given
   227  func (o *GetIDNotFound) IsCode(code int) bool {
   228  	return code == 404
   229  }
   230  
   231  // Code gets the status code for the get Id not found response
   232  func (o *GetIDNotFound) Code() int {
   233  	return 404
   234  }
   235  
   236  func (o *GetIDNotFound) Error() string {
   237  	return fmt.Sprintf("[GET /customers][%d] getIdNotFound  %+v", 404, o.Payload)
   238  }
   239  
   240  func (o *GetIDNotFound) String() string {
   241  	return fmt.Sprintf("[GET /customers][%d] getIdNotFound  %+v", 404, o.Payload)
   242  }
   243  
   244  func (o *GetIDNotFound) GetPayload() *models.Error {
   245  	return o.Payload
   246  }
   247  
   248  func (o *GetIDNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   249  
   250  	o.Payload = new(models.Error)
   251  
   252  	// response payload
   253  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   254  		return err
   255  	}
   256  
   257  	return nil
   258  }
   259  
   260  // NewGetIDDefault creates a GetIDDefault with default headers values
   261  func NewGetIDDefault(code int) *GetIDDefault {
   262  	return &GetIDDefault{
   263  		_statusCode: code,
   264  	}
   265  }
   266  
   267  /*
   268  GetIDDefault describes a response with status code -1, with default header values.
   269  
   270  error
   271  */
   272  type GetIDDefault struct {
   273  	_statusCode int
   274  
   275  	Payload *models.Error
   276  }
   277  
   278  // IsSuccess returns true when this get Id default response has a 2xx status code
   279  func (o *GetIDDefault) IsSuccess() bool {
   280  	return o._statusCode/100 == 2
   281  }
   282  
   283  // IsRedirect returns true when this get Id default response has a 3xx status code
   284  func (o *GetIDDefault) IsRedirect() bool {
   285  	return o._statusCode/100 == 3
   286  }
   287  
   288  // IsClientError returns true when this get Id default response has a 4xx status code
   289  func (o *GetIDDefault) IsClientError() bool {
   290  	return o._statusCode/100 == 4
   291  }
   292  
   293  // IsServerError returns true when this get Id default response has a 5xx status code
   294  func (o *GetIDDefault) IsServerError() bool {
   295  	return o._statusCode/100 == 5
   296  }
   297  
   298  // IsCode returns true when this get Id default response a status code equal to that given
   299  func (o *GetIDDefault) IsCode(code int) bool {
   300  	return o._statusCode == code
   301  }
   302  
   303  // Code gets the status code for the get Id default response
   304  func (o *GetIDDefault) Code() int {
   305  	return o._statusCode
   306  }
   307  
   308  func (o *GetIDDefault) Error() string {
   309  	return fmt.Sprintf("[GET /customers][%d] getId default  %+v", o._statusCode, o.Payload)
   310  }
   311  
   312  func (o *GetIDDefault) String() string {
   313  	return fmt.Sprintf("[GET /customers][%d] getId default  %+v", o._statusCode, o.Payload)
   314  }
   315  
   316  func (o *GetIDDefault) GetPayload() *models.Error {
   317  	return o.Payload
   318  }
   319  
   320  func (o *GetIDDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   321  
   322  	o.Payload = new(models.Error)
   323  
   324  	// response payload
   325  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   326  		return err
   327  	}
   328  
   329  	return nil
   330  }