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