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