github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/examples/authentication/client/customers/create_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  // CreateReader is a Reader for the Create structure.
    19  type CreateReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *CreateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 201:
    27  		result := NewCreateCreated()
    28  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    29  			return nil, err
    30  		}
    31  		return result, nil
    32  	default:
    33  		result := NewCreateDefault(response.Code())
    34  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    35  			return nil, err
    36  		}
    37  		if response.Code()/100 == 2 {
    38  			return result, nil
    39  		}
    40  		return nil, result
    41  	}
    42  }
    43  
    44  // NewCreateCreated creates a CreateCreated with default headers values
    45  func NewCreateCreated() *CreateCreated {
    46  	return &CreateCreated{}
    47  }
    48  
    49  /*
    50  CreateCreated describes a response with status code 201, with default header values.
    51  
    52  created
    53  */
    54  type CreateCreated struct {
    55  	Payload *models.Customer
    56  }
    57  
    58  // IsSuccess returns true when this create created response has a 2xx status code
    59  func (o *CreateCreated) IsSuccess() bool {
    60  	return true
    61  }
    62  
    63  // IsRedirect returns true when this create created response has a 3xx status code
    64  func (o *CreateCreated) IsRedirect() bool {
    65  	return false
    66  }
    67  
    68  // IsClientError returns true when this create created response has a 4xx status code
    69  func (o *CreateCreated) IsClientError() bool {
    70  	return false
    71  }
    72  
    73  // IsServerError returns true when this create created response has a 5xx status code
    74  func (o *CreateCreated) IsServerError() bool {
    75  	return false
    76  }
    77  
    78  // IsCode returns true when this create created response a status code equal to that given
    79  func (o *CreateCreated) IsCode(code int) bool {
    80  	return code == 201
    81  }
    82  
    83  // Code gets the status code for the create created response
    84  func (o *CreateCreated) Code() int {
    85  	return 201
    86  }
    87  
    88  func (o *CreateCreated) Error() string {
    89  	return fmt.Sprintf("[POST /customers][%d] createCreated  %+v", 201, o.Payload)
    90  }
    91  
    92  func (o *CreateCreated) String() string {
    93  	return fmt.Sprintf("[POST /customers][%d] createCreated  %+v", 201, o.Payload)
    94  }
    95  
    96  func (o *CreateCreated) GetPayload() *models.Customer {
    97  	return o.Payload
    98  }
    99  
   100  func (o *CreateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   101  
   102  	o.Payload = new(models.Customer)
   103  
   104  	// response payload
   105  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   106  		return err
   107  	}
   108  
   109  	return nil
   110  }
   111  
   112  // NewCreateDefault creates a CreateDefault with default headers values
   113  func NewCreateDefault(code int) *CreateDefault {
   114  	return &CreateDefault{
   115  		_statusCode: code,
   116  	}
   117  }
   118  
   119  /*
   120  CreateDefault describes a response with status code -1, with default header values.
   121  
   122  error
   123  */
   124  type CreateDefault struct {
   125  	_statusCode int
   126  
   127  	Payload *models.Error
   128  }
   129  
   130  // IsSuccess returns true when this create default response has a 2xx status code
   131  func (o *CreateDefault) IsSuccess() bool {
   132  	return o._statusCode/100 == 2
   133  }
   134  
   135  // IsRedirect returns true when this create default response has a 3xx status code
   136  func (o *CreateDefault) IsRedirect() bool {
   137  	return o._statusCode/100 == 3
   138  }
   139  
   140  // IsClientError returns true when this create default response has a 4xx status code
   141  func (o *CreateDefault) IsClientError() bool {
   142  	return o._statusCode/100 == 4
   143  }
   144  
   145  // IsServerError returns true when this create default response has a 5xx status code
   146  func (o *CreateDefault) IsServerError() bool {
   147  	return o._statusCode/100 == 5
   148  }
   149  
   150  // IsCode returns true when this create default response a status code equal to that given
   151  func (o *CreateDefault) IsCode(code int) bool {
   152  	return o._statusCode == code
   153  }
   154  
   155  // Code gets the status code for the create default response
   156  func (o *CreateDefault) Code() int {
   157  	return o._statusCode
   158  }
   159  
   160  func (o *CreateDefault) Error() string {
   161  	return fmt.Sprintf("[POST /customers][%d] create default  %+v", o._statusCode, o.Payload)
   162  }
   163  
   164  func (o *CreateDefault) String() string {
   165  	return fmt.Sprintf("[POST /customers][%d] create default  %+v", o._statusCode, o.Payload)
   166  }
   167  
   168  func (o *CreateDefault) GetPayload() *models.Error {
   169  	return o.Payload
   170  }
   171  
   172  func (o *CreateDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   173  
   174  	o.Payload = new(models.Error)
   175  
   176  	// response payload
   177  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   178  		return err
   179  	}
   180  
   181  	return nil
   182  }