Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #122 from Grupo-G03-4SOAT-FIAP/feature/51/clean-ar…
Browse files Browse the repository at this point in the history
…chitecture

refactor: Melhoria na PedidoUseCase
  • Loading branch information
dannevesdantas authored Jan 29, 2024
2 parents 3e59504 + 763ce2d commit b95374d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/application/use_cases/pedido/pedido.use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class PedidoUseCase implements IPedidoUseCase {
private readonly pedidoFactory: IPedidoFactory,
@Inject(IGatewayPagamentoService)
private readonly gatewayPagamentoService: IGatewayPagamentoService,
private configService: ConfigService,
@Inject(IPedidoDTOFactory)
private readonly pedidoDTOFactory: IPedidoDTOFactory,
private configService: ConfigService,
) {}

private async validarPedidoPorId(
Expand All @@ -42,11 +42,11 @@ export class PedidoUseCase implements IPedidoUseCase {
return pedido;
}

async criarPedido(pedido: CriaPedidoDTO): Promise<HTTPResponse<PedidoDTO>> {
const pedidoFactory = await this.pedidoFactory.criarEntidadePedido(pedido);
async criarPedido(criaPedidoDTO: CriaPedidoDTO): Promise<HTTPResponse<PedidoDTO>> {
const pedidoEntity = await this.pedidoFactory.criarEntidadePedido(criaPedidoDTO);

const result = await this.pedidoRepository.criarPedido(pedidoFactory);
pedidoFactory.id = result.id;
const result = await this.pedidoRepository.criarPedido(pedidoEntity);
pedidoEntity.id = result.id;

const pedidoDTO = this.pedidoDTOFactory.criarPedidoDTO(result);

Expand All @@ -56,7 +56,7 @@ export class PedidoUseCase implements IPedidoUseCase {

if (mercadoPagoIsEnabled) {
const qrData =
await this.gatewayPagamentoService.criarPedido(pedidoFactory);
await this.gatewayPagamentoService.criarPedido(pedidoEntity);
pedidoDTO.qrCode = qrData;
}

Expand Down

0 comments on commit b95374d

Please sign in to comment.