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