Skip to content

Commit 316713c

Browse files
authored
fix: get order endpoint (#4)
2 parents 2cfb5fe + 339d57b commit 316713c

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/main/java/br/com/grupo63/techchallenge/payment/gateway/order/IOrderGateway.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
import br.com.grupo63.techchallenge.payment.gateway.order.dto.OrderDTO;
44
import org.springframework.cloud.openfeign.FeignClient;
5+
import org.springframework.web.bind.annotation.PathVariable;
56
import org.springframework.web.bind.annotation.RequestMapping;
67
import org.springframework.web.bind.annotation.RequestMethod;
7-
import org.springframework.web.bind.annotation.RequestParam;
88

99
import java.util.Optional;
1010

11-
@FeignClient(name = "order", url = "${urls.baseurl}")
11+
@FeignClient(name = "orders", url = "${urls.baseurl}")
1212
public interface IOrderGateway {
1313

14-
@RequestMapping(method = RequestMethod.GET, value = "${urls.orders}")
15-
Optional<OrderDTO> getOrderById(@RequestParam("orderId") Long orderId);
14+
@RequestMapping(method = RequestMethod.GET, value = "${urls.orders}/{orderId}")
15+
Optional<OrderDTO> getOrderById(@PathVariable("orderId") Long orderId);
1616

1717
}

src/main/java/br/com/grupo63/techchallenge/payment/gateway/order/dto/OrderDTO.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
@NoArgsConstructor
1212
public class OrderDTO {
1313

14-
private Long id;
1514
private Double totalPrice;
1615
}

src/main/java/br/com/grupo63/techchallenge/payment/usecase/PaymentUseCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public class PaymentUseCase implements IPaymentUseCase {
2525
public String startPayment(Long orderId) throws NotFoundException {
2626
OrderDTO orderDTO = orderGateway.getOrderById(orderId).orElseThrow(NotFoundException::new);
2727

28-
String qrData = mercadoPagoGateway.generateQRCode(orderDTO.getId(), orderDTO.getTotalPrice());
28+
String qrData = mercadoPagoGateway.generateQRCode(orderId, orderDTO.getTotalPrice());
2929

30-
Payment payment = new Payment(null, false, PaymentStatus.PENDING, PaymentMethod.MERCADO_PAGO_QR_CODE, qrData, orderDTO.getId());
30+
Payment payment = new Payment(null, false, PaymentStatus.PENDING, PaymentMethod.MERCADO_PAGO_QR_CODE, qrData, orderId);
3131

3232
paymentGateway.saveAndFlush(payment);
3333

src/test/java/br/com/grupo63/techchallenge/payment/PaymentIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class PaymentIntegrationTest {
4848
private final Long defaultOrderId = 1L;
4949
private final String qrData = UUID.randomUUID().toString();
5050
private final Double totalPrice = 100.00;
51-
private final OrderDTO orderDTO = new OrderDTO(defaultOrderId, totalPrice);
51+
private final OrderDTO orderDTO = new OrderDTO(totalPrice);
5252
private final Payment payment = new Payment(1L, false, PaymentStatus.PENDING, PaymentMethod.MERCADO_PAGO_QR_CODE, qrData, defaultOrderId);
5353
private final PaymentPersistenceEntity defaultPaymentPersistenceEntity =
5454
new PaymentPersistenceEntity(payment);

0 commit comments

Comments
 (0)