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