| Total Complexity | 2 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 19 | |||
| 20 | @Controller('shipping-costs') |
||
| 21 | @ApiTags('Order') |
||
| 22 | @ApiBearerAuth() |
||
| 23 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
| 24 | export class UpdateShippingCostAction { |
||
| 25 | constructor( |
||
| 26 | @Inject('ICommandBus') |
||
| 27 | private readonly commandBus: ICommandBus |
||
| 28 | ) {} |
||
| 29 | |||
| 30 | @Put(':id') |
||
| 31 | @Roles(UserRole.PHOTOGRAPHER) |
||
| 32 | @ApiOperation({ summary: 'Update shipping cost' }) |
||
| 33 | public async index(@Param() idDto: IdDTO, @Body() dto: ShippingCostDTO) { |
||
| 34 | try { |
||
| 35 | const { price, grams } = dto; |
||
| 36 | const id = await this.commandBus.execute( |
||
| 37 | new UpdateShippingCostCommand(idDto.id, grams, price) |
||
| 38 | ); |
||
| 39 | |||
| 40 | return { id }; |
||
| 41 | } catch (e) { |
||
| 42 | throw new BadRequestException(e.message); |
||
| 43 | } |
||
| 46 |