github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/contributed-templates/stratoscale/client/store/order_get_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package store 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/contributed-templates/stratoscale/models" 16 ) 17 18 // OrderGetReader is a Reader for the OrderGet structure. 19 type OrderGetReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *OrderGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewOrderGetOK() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 case 400: 33 result := NewOrderGetBadRequest() 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 := NewOrderGetNotFound() 40 if err := result.readResponse(response, consumer, o.formats); err != nil { 41 return nil, err 42 } 43 return nil, result 44 default: 45 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) 46 } 47 } 48 49 // NewOrderGetOK creates a OrderGetOK with default headers values 50 func NewOrderGetOK() *OrderGetOK { 51 return &OrderGetOK{} 52 } 53 54 /* 55 OrderGetOK describes a response with status code 200, with default header values. 56 57 successful operation 58 */ 59 type OrderGetOK struct { 60 Payload *models.Order 61 } 62 63 // IsSuccess returns true when this order get o k response returns a 2xx status code 64 func (o *OrderGetOK) IsSuccess() bool { 65 return true 66 } 67 68 // IsRedirect returns true when this order get o k response returns a 3xx status code 69 func (o *OrderGetOK) IsRedirect() bool { 70 return false 71 } 72 73 // IsClientError returns true when this order get o k response returns a 4xx status code 74 func (o *OrderGetOK) IsClientError() bool { 75 return false 76 } 77 78 // IsServerError returns true when this order get o k response returns a 5xx status code 79 func (o *OrderGetOK) IsServerError() bool { 80 return false 81 } 82 83 // IsCode returns true when this order get o k response returns a 4xx status code 84 func (o *OrderGetOK) IsCode(code int) bool { 85 return code == 200 86 } 87 88 func (o *OrderGetOK) Error() string { 89 return fmt.Sprintf("[GET /store/order/{orderId}][%d] orderGetOK %+v", 200, o.Payload) 90 } 91 92 func (o *OrderGetOK) String() string { 93 return fmt.Sprintf("[GET /store/order/{orderId}][%d] orderGetOK %+v", 200, o.Payload) 94 } 95 96 func (o *OrderGetOK) GetPayload() *models.Order { 97 return o.Payload 98 } 99 100 func (o *OrderGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 101 102 o.Payload = new(models.Order) 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 // NewOrderGetBadRequest creates a OrderGetBadRequest with default headers values 113 func NewOrderGetBadRequest() *OrderGetBadRequest { 114 return &OrderGetBadRequest{} 115 } 116 117 /* 118 OrderGetBadRequest describes a response with status code 400, with default header values. 119 120 Invalid ID supplied 121 */ 122 type OrderGetBadRequest struct { 123 } 124 125 // IsSuccess returns true when this order get bad request response returns a 2xx status code 126 func (o *OrderGetBadRequest) IsSuccess() bool { 127 return false 128 } 129 130 // IsRedirect returns true when this order get bad request response returns a 3xx status code 131 func (o *OrderGetBadRequest) IsRedirect() bool { 132 return false 133 } 134 135 // IsClientError returns true when this order get bad request response returns a 4xx status code 136 func (o *OrderGetBadRequest) IsClientError() bool { 137 return true 138 } 139 140 // IsServerError returns true when this order get bad request response returns a 5xx status code 141 func (o *OrderGetBadRequest) IsServerError() bool { 142 return false 143 } 144 145 // IsCode returns true when this order get bad request response returns a 4xx status code 146 func (o *OrderGetBadRequest) IsCode(code int) bool { 147 return code == 400 148 } 149 150 func (o *OrderGetBadRequest) Error() string { 151 return fmt.Sprintf("[GET /store/order/{orderId}][%d] orderGetBadRequest ", 400) 152 } 153 154 func (o *OrderGetBadRequest) String() string { 155 return fmt.Sprintf("[GET /store/order/{orderId}][%d] orderGetBadRequest ", 400) 156 } 157 158 func (o *OrderGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 159 160 return nil 161 } 162 163 // NewOrderGetNotFound creates a OrderGetNotFound with default headers values 164 func NewOrderGetNotFound() *OrderGetNotFound { 165 return &OrderGetNotFound{} 166 } 167 168 /* 169 OrderGetNotFound describes a response with status code 404, with default header values. 170 171 Order not found 172 */ 173 type OrderGetNotFound struct { 174 } 175 176 // IsSuccess returns true when this order get not found response returns a 2xx status code 177 func (o *OrderGetNotFound) IsSuccess() bool { 178 return false 179 } 180 181 // IsRedirect returns true when this order get not found response returns a 3xx status code 182 func (o *OrderGetNotFound) IsRedirect() bool { 183 return false 184 } 185 186 // IsClientError returns true when this order get not found response returns a 4xx status code 187 func (o *OrderGetNotFound) IsClientError() bool { 188 return true 189 } 190 191 // IsServerError returns true when this order get not found response returns a 5xx status code 192 func (o *OrderGetNotFound) IsServerError() bool { 193 return false 194 } 195 196 // IsCode returns true when this order get not found response returns a 4xx status code 197 func (o *OrderGetNotFound) IsCode(code int) bool { 198 return code == 404 199 } 200 201 func (o *OrderGetNotFound) Error() string { 202 return fmt.Sprintf("[GET /store/order/{orderId}][%d] orderGetNotFound ", 404) 203 } 204 205 func (o *OrderGetNotFound) String() string { 206 return fmt.Sprintf("[GET /store/order/{orderId}][%d] orderGetNotFound ", 404) 207 } 208 209 func (o *OrderGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 210 211 return nil 212 }