From 599bf486d2812f2bdcf1ddbd180fdacbb59be4f0 Mon Sep 17 00:00:00 2001 From: eya cherif Date: Fri, 20 Dec 2024 15:47:10 +0100 Subject: [PATCH] establishing communication with Order microservice --- .../java/payment/api/clients/OrderClient.java | 21 ++++++++++++ .../api/dto/OrderUpdateRequestDTO.java | 34 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 payment/src/main/java/payment/api/clients/OrderClient.java create mode 100644 payment/src/main/java/payment/api/dto/OrderUpdateRequestDTO.java diff --git a/payment/src/main/java/payment/api/clients/OrderClient.java b/payment/src/main/java/payment/api/clients/OrderClient.java new file mode 100644 index 00000000..d3905665 --- /dev/null +++ b/payment/src/main/java/payment/api/clients/OrderClient.java @@ -0,0 +1,21 @@ +package payment.api.clients; + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import payment.api.dto.OrderUpdateRequestDTO; + +@RegisterRestClient(baseUri = "http://localhost:8084/") +@Path("/orders") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface OrderClient { + @POST + @Path("/update-status") + Response updateOrderStatus(OrderUpdateRequestDTO orderUpdateRequestDTO); +} diff --git a/payment/src/main/java/payment/api/dto/OrderUpdateRequestDTO.java b/payment/src/main/java/payment/api/dto/OrderUpdateRequestDTO.java new file mode 100644 index 00000000..c45d6c1c --- /dev/null +++ b/payment/src/main/java/payment/api/dto/OrderUpdateRequestDTO.java @@ -0,0 +1,34 @@ +package payment.api.dto; + +import java.util.UUID; + +public class OrderUpdateRequestDTO { + + private UUID orderId; + private String newStatus; + + public OrderUpdateRequestDTO() {} + + public OrderUpdateRequestDTO(UUID orderId, String newStatus) { + this.orderId = orderId; + this.newStatus = newStatus; + } + + + public UUID getOrderId() { + return orderId; + } + + public void setOrderId(UUID orderId) { + this.orderId = orderId; + } + + public String getNewStatus() { + return newStatus; + } + + public void setNewStatus(String newStatus) { + this.newStatus = newStatus; + } +} +