Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 151 |
|
0.00% |
0 / 15 |
CRAP | |
0.00% |
0 / 1 |
| ApiAttributeController | |
0.00% |
0 / 151 |
|
0.00% |
0 / 15 |
1190 | |
0.00% |
0 / 1 |
| apiBillAttributeCreate | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeTypeL11nCreate | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeTypeCreate | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeValueCreate | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
12 | |||
| apiBillAttributeValueL11nCreate | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeUpdate | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
30 | |||
| apiBillAttributeDelete | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
12 | |||
| apiBillAttributeTypeL11nUpdate | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeTypeL11nDelete | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeTypeUpdate | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeTypeDelete | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeValueUpdate | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeValueDelete | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| apiBillAttributeValueL11nUpdate | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| apiBillAttributeValueL11nDelete | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package Modules\Billing |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace Modules\Billing\Controller; |
| 16 | |
| 17 | use Modules\Attribute\Models\Attribute; |
| 18 | use Modules\Attribute\Models\AttributeType; |
| 19 | use Modules\Attribute\Models\AttributeValue; |
| 20 | use Modules\Billing\Models\Attribute\BillAttributeMapper; |
| 21 | use Modules\Billing\Models\Attribute\BillAttributeTypeL11nMapper; |
| 22 | use Modules\Billing\Models\Attribute\BillAttributeTypeMapper; |
| 23 | use Modules\Billing\Models\Attribute\BillAttributeValueL11nMapper; |
| 24 | use Modules\Billing\Models\Attribute\BillAttributeValueMapper; |
| 25 | use phpOMS\Localization\BaseStringL11n; |
| 26 | use phpOMS\Message\Http\RequestStatusCode; |
| 27 | use phpOMS\Message\RequestAbstract; |
| 28 | use phpOMS\Message\ResponseAbstract; |
| 29 | |
| 30 | /** |
| 31 | * Billing class. |
| 32 | * |
| 33 | * @package Modules\Billing |
| 34 | * @license OMS License 2.0 |
| 35 | * @link https://jingga.app |
| 36 | * @since 1.0.0 |
| 37 | */ |
| 38 | final class ApiAttributeController extends Controller |
| 39 | { |
| 40 | use \Modules\Attribute\Controller\ApiAttributeTraitController; |
| 41 | |
| 42 | /** |
| 43 | * Api method to create item attribute |
| 44 | * |
| 45 | * @param RequestAbstract $request Request |
| 46 | * @param ResponseAbstract $response Response |
| 47 | * @param array $data Generic data |
| 48 | * |
| 49 | * @return void |
| 50 | * |
| 51 | * @api |
| 52 | * |
| 53 | * @since 1.0.0 |
| 54 | */ |
| 55 | public function apiBillAttributeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 56 | { |
| 57 | if (!empty($val = $this->validateAttributeCreate($request))) { |
| 58 | $response->header->status = RequestStatusCode::R_400; |
| 59 | $this->createInvalidCreateResponse($request, $response, $val); |
| 60 | |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | $attribute = $this->createAttributeFromRequest($request); |
| 65 | $this->createModel($request->header->account, $attribute, BillAttributeMapper::class, 'attribute', $request->getOrigin()); |
| 66 | $this->createStandardCreateResponse($request, $response, $attribute); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Api method to create bill attribute l11n |
| 71 | * |
| 72 | * @param RequestAbstract $request Request |
| 73 | * @param ResponseAbstract $response Response |
| 74 | * @param array $data Generic data |
| 75 | * |
| 76 | * @return void |
| 77 | * |
| 78 | * @api |
| 79 | * |
| 80 | * @since 1.0.0 |
| 81 | */ |
| 82 | public function apiBillAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 83 | { |
| 84 | if (!empty($val = $this->validateAttributeTypeL11nCreate($request))) { |
| 85 | $response->header->status = RequestStatusCode::R_400; |
| 86 | $this->createInvalidCreateResponse($request, $response, $val); |
| 87 | |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | $attrL11n = $this->createAttributeTypeL11nFromRequest($request); |
| 92 | $this->createModel($request->header->account, $attrL11n, BillAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin()); |
| 93 | $this->createStandardCreateResponse($request, $response, $attrL11n); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Api method to create bill attribute type |
| 98 | * |
| 99 | * @param RequestAbstract $request Request |
| 100 | * @param ResponseAbstract $response Response |
| 101 | * @param array $data Generic data |
| 102 | * |
| 103 | * @return void |
| 104 | * |
| 105 | * @api |
| 106 | * |
| 107 | * @since 1.0.0 |
| 108 | */ |
| 109 | public function apiBillAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 110 | { |
| 111 | if (!empty($val = $this->validateAttributeTypeCreate($request))) { |
| 112 | $response->header->status = RequestStatusCode::R_400; |
| 113 | $this->createInvalidCreateResponse($request, $response, $val); |
| 114 | |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | $attrType = $this->createAttributeTypeFromRequest($request); |
| 119 | $this->createModel($request->header->account, $attrType, BillAttributeTypeMapper::class, 'attr_type', $request->getOrigin()); |
| 120 | $this->createStandardCreateResponse($request, $response, $attrType); |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Api method to create bill attribute value |
| 125 | * |
| 126 | * @param RequestAbstract $request Request |
| 127 | * @param ResponseAbstract $response Response |
| 128 | * @param array $data Generic data |
| 129 | * |
| 130 | * @return void |
| 131 | * |
| 132 | * @api |
| 133 | * |
| 134 | * @since 1.0.0 |
| 135 | */ |
| 136 | public function apiBillAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 137 | { |
| 138 | if (!empty($val = $this->validateAttributeValueCreate($request))) { |
| 139 | $response->header->status = RequestStatusCode::R_400; |
| 140 | $this->createInvalidCreateResponse($request, $response, $val); |
| 141 | |
| 142 | return; |
| 143 | } |
| 144 | |
| 145 | /** @var \Modules\Attribute\Models\AttributeType $type */ |
| 146 | $type = BillAttributeTypeMapper::get() |
| 147 | ->where('id', $request->getDataInt('type') ?? 0) |
| 148 | ->execute(); |
| 149 | |
| 150 | $attrValue = $this->createAttributeValueFromRequest($request, $type); |
| 151 | $this->createModel($request->header->account, $attrValue, BillAttributeValueMapper::class, 'attr_value', $request->getOrigin()); |
| 152 | |
| 153 | if ($attrValue->isDefault) { |
| 154 | $this->createModelRelation( |
| 155 | $request->header->account, |
| 156 | (int) $request->getData('type'), |
| 157 | $attrValue->id, |
| 158 | BillAttributeTypeMapper::class, 'defaults', '', $request->getOrigin() |
| 159 | ); |
| 160 | } |
| 161 | |
| 162 | $this->createStandardCreateResponse($request, $response, $attrValue); |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Api method to create bill attribute l11n |
| 167 | * |
| 168 | * @param RequestAbstract $request Request |
| 169 | * @param ResponseAbstract $response Response |
| 170 | * @param array $data Generic data |
| 171 | * |
| 172 | * @return void |
| 173 | * |
| 174 | * @api |
| 175 | * |
| 176 | * @since 1.0.0 |
| 177 | */ |
| 178 | public function apiBillAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 179 | { |
| 180 | if (!empty($val = $this->validateAttributeValueL11nCreate($request))) { |
| 181 | $response->header->status = RequestStatusCode::R_400; |
| 182 | $this->createInvalidCreateResponse($request, $response, $val); |
| 183 | |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | $attrL11n = $this->createAttributeValueL11nFromRequest($request); |
| 188 | $this->createModel($request->header->account, $attrL11n, BillAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin()); |
| 189 | $this->createStandardCreateResponse($request, $response, $attrL11n); |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Api method to update BillAttribute |
| 194 | * |
| 195 | * @param RequestAbstract $request Request |
| 196 | * @param ResponseAbstract $response Response |
| 197 | * @param array $data Generic data |
| 198 | * |
| 199 | * @return void |
| 200 | * |
| 201 | * @api |
| 202 | * |
| 203 | * @since 1.0.0 |
| 204 | */ |
| 205 | public function apiBillAttributeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 206 | { |
| 207 | if (!empty($val = $this->validateAttributeUpdate($request))) { |
| 208 | $response->header->status = RequestStatusCode::R_400; |
| 209 | $this->createInvalidUpdateResponse($request, $response, $val); |
| 210 | |
| 211 | return; |
| 212 | } |
| 213 | |
| 214 | /** @var Attribute $old */ |
| 215 | $old = BillAttributeMapper::get() |
| 216 | ->with('type') |
| 217 | ->with('type/defaults') |
| 218 | ->with('value') |
| 219 | ->where('id', (int) $request->getData('id')) |
| 220 | ->execute(); |
| 221 | |
| 222 | $new = $this->updateAttributeFromRequest($request, clone $old); |
| 223 | |
| 224 | if ($new->id === 0) { |
| 225 | // Set response header to invalid request because of invalid data |
| 226 | $response->header->status = RequestStatusCode::R_400; |
| 227 | $this->createInvalidUpdateResponse($request, $response, $new); |
| 228 | |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | $this->updateModel($request->header->account, $old, $new, BillAttributeMapper::class, 'bill_attribute', $request->getOrigin()); |
| 233 | |
| 234 | if ($new->value->getValue() !== $old->value->getValue() |
| 235 | && $new->type->custom |
| 236 | ) { |
| 237 | $this->updateModel($request->header->account, $old->value, $new->value, BillAttributeValueMapper::class, 'attribute_value', $request->getOrigin()); |
| 238 | } |
| 239 | |
| 240 | $this->createStandardUpdateResponse($request, $response, $new); |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Api method to delete BillAttribute |
| 245 | * |
| 246 | * @param RequestAbstract $request Request |
| 247 | * @param ResponseAbstract $response Response |
| 248 | * @param array $data Generic data |
| 249 | * |
| 250 | * @return void |
| 251 | * |
| 252 | * @api |
| 253 | * |
| 254 | * @since 1.0.0 |
| 255 | */ |
| 256 | public function apiBillAttributeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 257 | { |
| 258 | if (!empty($val = $this->validateAttributeDelete($request))) { |
| 259 | $response->header->status = RequestStatusCode::R_400; |
| 260 | $this->createInvalidDeleteResponse($request, $response, $val); |
| 261 | |
| 262 | return; |
| 263 | } |
| 264 | |
| 265 | $billAttribute = BillAttributeMapper::get() |
| 266 | ->with('type') |
| 267 | ->where('id', (int) $request->getData('id')) |
| 268 | ->execute(); |
| 269 | |
| 270 | if ($billAttribute->type->isRequired) { |
| 271 | $this->createInvalidDeleteResponse($request, $response, []); |
| 272 | |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | $this->deleteModel($request->header->account, $billAttribute, BillAttributeMapper::class, 'bill_attribute', $request->getOrigin()); |
| 277 | $this->createStandardDeleteResponse($request, $response, $billAttribute); |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Api method to update BillAttributeTypeL11n |
| 282 | * |
| 283 | * @param RequestAbstract $request Request |
| 284 | * @param ResponseAbstract $response Response |
| 285 | * @param array $data Generic data |
| 286 | * |
| 287 | * @return void |
| 288 | * |
| 289 | * @api |
| 290 | * |
| 291 | * @since 1.0.0 |
| 292 | */ |
| 293 | public function apiBillAttributeTypeL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 294 | { |
| 295 | if (!empty($val = $this->validateAttributeTypeL11nUpdate($request))) { |
| 296 | $response->header->status = RequestStatusCode::R_400; |
| 297 | $this->createInvalidUpdateResponse($request, $response, $val); |
| 298 | |
| 299 | return; |
| 300 | } |
| 301 | |
| 302 | /** @var BaseStringL11n $old */ |
| 303 | $old = BillAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute(); |
| 304 | $new = $this->updateAttributeTypeL11nFromRequest($request, clone $old); |
| 305 | |
| 306 | $this->updateModel($request->header->account, $old, $new, BillAttributeTypeL11nMapper::class, 'bill_attribute_type_l11n', $request->getOrigin()); |
| 307 | $this->createStandardUpdateResponse($request, $response, $new); |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Api method to delete BillAttributeTypeL11n |
| 312 | * |
| 313 | * @param RequestAbstract $request Request |
| 314 | * @param ResponseAbstract $response Response |
| 315 | * @param array $data Generic data |
| 316 | * |
| 317 | * @return void |
| 318 | * |
| 319 | * @api |
| 320 | * |
| 321 | * @since 1.0.0 |
| 322 | */ |
| 323 | public function apiBillAttributeTypeL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 324 | { |
| 325 | if (!empty($val = $this->validateAttributeTypeL11nDelete($request))) { |
| 326 | $response->header->status = RequestStatusCode::R_400; |
| 327 | $this->createInvalidDeleteResponse($request, $response, $val); |
| 328 | |
| 329 | return; |
| 330 | } |
| 331 | |
| 332 | /** @var BaseStringL11n $billAttributeTypeL11n */ |
| 333 | $billAttributeTypeL11n = BillAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute(); |
| 334 | $this->deleteModel($request->header->account, $billAttributeTypeL11n, BillAttributeTypeL11nMapper::class, 'bill_attribute_type_l11n', $request->getOrigin()); |
| 335 | $this->createStandardDeleteResponse($request, $response, $billAttributeTypeL11n); |
| 336 | } |
| 337 | |
| 338 | /** |
| 339 | * Api method to update BillAttributeType |
| 340 | * |
| 341 | * @param RequestAbstract $request Request |
| 342 | * @param ResponseAbstract $response Response |
| 343 | * @param array $data Generic data |
| 344 | * |
| 345 | * @return void |
| 346 | * |
| 347 | * @api |
| 348 | * |
| 349 | * @since 1.0.0 |
| 350 | */ |
| 351 | public function apiBillAttributeTypeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 352 | { |
| 353 | if (!empty($val = $this->validateAttributeTypeUpdate($request))) { |
| 354 | $response->header->status = RequestStatusCode::R_400; |
| 355 | $this->createInvalidUpdateResponse($request, $response, $val); |
| 356 | |
| 357 | return; |
| 358 | } |
| 359 | |
| 360 | /** @var AttributeType $old */ |
| 361 | $old = BillAttributeTypeMapper::get()->where('id', (int) $request->getData('id'))->execute(); |
| 362 | $new = $this->updateAttributeTypeFromRequest($request, clone $old); |
| 363 | |
| 364 | $this->updateModel($request->header->account, $old, $new, BillAttributeTypeMapper::class, 'bill_attribute_type', $request->getOrigin()); |
| 365 | $this->createStandardUpdateResponse($request, $response, $new); |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * Api method to delete BillAttributeType |
| 370 | * |
| 371 | * @param RequestAbstract $request Request |
| 372 | * @param ResponseAbstract $response Response |
| 373 | * @param array $data Generic data |
| 374 | * |
| 375 | * @return void |
| 376 | * |
| 377 | * @api |
| 378 | * |
| 379 | * @todo: implement |
| 380 | * |
| 381 | * @since 1.0.0 |
| 382 | */ |
| 383 | public function apiBillAttributeTypeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 384 | { |
| 385 | if (!empty($val = $this->validateAttributeTypeDelete($request))) { |
| 386 | $response->header->status = RequestStatusCode::R_400; |
| 387 | $this->createInvalidDeleteResponse($request, $response, $val); |
| 388 | |
| 389 | return; |
| 390 | } |
| 391 | |
| 392 | /** @var AttributeType $billAttributeType */ |
| 393 | $billAttributeType = BillAttributeTypeMapper::get()->where('id', (int) $request->getData('id'))->execute(); |
| 394 | $this->deleteModel($request->header->account, $billAttributeType, BillAttributeTypeMapper::class, 'bill_attribute_type', $request->getOrigin()); |
| 395 | $this->createStandardDeleteResponse($request, $response, $billAttributeType); |
| 396 | } |
| 397 | |
| 398 | /** |
| 399 | * Api method to update BillAttributeValue |
| 400 | * |
| 401 | * @param RequestAbstract $request Request |
| 402 | * @param ResponseAbstract $response Response |
| 403 | * @param array $data Generic data |
| 404 | * |
| 405 | * @return void |
| 406 | * |
| 407 | * @api |
| 408 | * |
| 409 | * @since 1.0.0 |
| 410 | */ |
| 411 | public function apiBillAttributeValueUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 412 | { |
| 413 | if (!empty($val = $this->validateAttributeValueUpdate($request))) { |
| 414 | $response->header->status = RequestStatusCode::R_400; |
| 415 | $this->createInvalidUpdateResponse($request, $response, $val); |
| 416 | |
| 417 | return; |
| 418 | } |
| 419 | |
| 420 | /** @var AttributeValue $old */ |
| 421 | $old = BillAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute(); |
| 422 | |
| 423 | /** @var \Modules\Attribute\Models\Attribute $attr */ |
| 424 | $attr = BillAttributeMapper::get() |
| 425 | ->with('type') |
| 426 | ->where('id', $request->getDataInt('attribute') ?? 0) |
| 427 | ->execute(); |
| 428 | |
| 429 | $new = $this->updateAttributeValueFromRequest($request, clone $old, $attr); |
| 430 | |
| 431 | $this->updateModel($request->header->account, $old, $new, BillAttributeValueMapper::class, 'bill_attribute_value', $request->getOrigin()); |
| 432 | $this->createStandardUpdateResponse($request, $response, $new); |
| 433 | } |
| 434 | |
| 435 | /** |
| 436 | * Api method to delete BillAttributeValue |
| 437 | * |
| 438 | * @param RequestAbstract $request Request |
| 439 | * @param ResponseAbstract $response Response |
| 440 | * @param array $data Generic data |
| 441 | * |
| 442 | * @return void |
| 443 | * |
| 444 | * @api |
| 445 | * |
| 446 | * @since 1.0.0 |
| 447 | */ |
| 448 | public function apiBillAttributeValueDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 449 | { |
| 450 | // @todo: I don't think values can be deleted? Only Attributes |
| 451 | // However, It should be possible to remove UNUSED default values |
| 452 | // either here or other function? |
| 453 | // if (!empty($val = $this->validateAttributeValueDelete($request))) { |
| 454 | // $response->header->status = RequestStatusCode::R_400; |
| 455 | // $this->createInvalidDeleteResponse($request, $response, $val); |
| 456 | |
| 457 | // return; |
| 458 | // } |
| 459 | |
| 460 | // /** @var \Modules\Billing\Models\BillAttributeValue $billAttributeValue */ |
| 461 | // $billAttributeValue = BillAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute(); |
| 462 | // $this->deleteModel($request->header->account, $billAttributeValue, BillAttributeValueMapper::class, 'bill_attribute_value', $request->getOrigin()); |
| 463 | // $this->createStandardDeleteResponse($request, $response, $billAttributeValue); |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * Api method to update BillAttributeValueL11n |
| 468 | * |
| 469 | * @param RequestAbstract $request Request |
| 470 | * @param ResponseAbstract $response Response |
| 471 | * @param array $data Generic data |
| 472 | * |
| 473 | * @return void |
| 474 | * |
| 475 | * @api |
| 476 | * |
| 477 | * @since 1.0.0 |
| 478 | */ |
| 479 | public function apiBillAttributeValueL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 480 | { |
| 481 | if (!empty($val = $this->validateAttributeValueL11nUpdate($request))) { |
| 482 | $response->header->status = RequestStatusCode::R_400; |
| 483 | $this->createInvalidUpdateResponse($request, $response, $val); |
| 484 | |
| 485 | return; |
| 486 | } |
| 487 | |
| 488 | /** @var BaseStringL11n $old */ |
| 489 | $old = BillAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id')); |
| 490 | $new = $this->updateAttributeValueL11nFromRequest($request, clone $old); |
| 491 | |
| 492 | $this->updateModel($request->header->account, $old, $new, BillAttributeValueL11nMapper::class, 'bill_attribute_value_l11n', $request->getOrigin()); |
| 493 | $this->createStandardUpdateResponse($request, $response, $new); |
| 494 | } |
| 495 | |
| 496 | /** |
| 497 | * Api method to delete BillAttributeValueL11n |
| 498 | * |
| 499 | * @param RequestAbstract $request Request |
| 500 | * @param ResponseAbstract $response Response |
| 501 | * @param array $data Generic data |
| 502 | * |
| 503 | * @return void |
| 504 | * |
| 505 | * @api |
| 506 | * |
| 507 | * @since 1.0.0 |
| 508 | */ |
| 509 | public function apiBillAttributeValueL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void |
| 510 | { |
| 511 | if (!empty($val = $this->validateAttributeValueL11nDelete($request))) { |
| 512 | $response->header->status = RequestStatusCode::R_400; |
| 513 | $this->createInvalidDeleteResponse($request, $response, $val); |
| 514 | |
| 515 | return; |
| 516 | } |
| 517 | |
| 518 | /** @var BaseStringL11n $billAttributeValueL11n */ |
| 519 | $billAttributeValueL11n = BillAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'))->execute(); |
| 520 | $this->deleteModel($request->header->account, $billAttributeValueL11n, BillAttributeValueL11nMapper::class, 'bill_attribute_value_l11n', $request->getOrigin()); |
| 521 | $this->createStandardDeleteResponse($request, $response, $billAttributeValueL11n); |
| 522 | } |
| 523 | } |