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