0:00 All right, so we want to start implementing our order 0:02 response DTO. 0:05 So let's go ahead and start by exporting the class 0:07 OrderResponseDTO. 0:12 And now what we'll do is define the properties 0:14 that we want to expose 0:16 on the presentation layer through our HTTP controller. 0:20 Now again, this is completely decoupled from the 0:23 domain layer. 0:24 These properties can be different from what the domain needs or 0:27 expects, and this can be exactly what the client 0:30 needs in this case, and 0:31 that's the benefit. We have this decoupling between the 0:34 presentation and the 0:35 domain. 0:37 And so what we'll go ahead and do is start defining our properties we want 0:40 to 0:40 expose. We'll have the 0:42 order ID, 0:44 the customer ID, 0:46 the order status, which will be a string, 0:49 and then we have the items themself. 0:51 So just like we're doing for the order response, we want to define a new 0:54 class for the order item and define the properties there. 1:00 So we'll export class above it, 1:02 OrderItemResponseDTO, 1:06 and define the properties now. Again, we want the ID, 1:10 the product ID, 1:12 product name, 1:15 unit price, 1:19 currency, 1:22 quantity. 1:24 Discount will be number or null if it doesn't exist, 1:28 and finally, the subtotal, which will be a number. 1:31 So now we have the properties we're exposing for the order item. 1:35 We can reference this type as the OrderItemResponseDTO 1:38 array, 1:40 and then we can continue with the rest of the properties we want to expose. 1:43 So we can have the total amount, 1:46 the total currency, 1:49 and we can even add an extra property here that the domain wouldn't have, the 1:53 item count. For example, if our client needs to know how many order 1:57 items 1:57 we actually have, for example, like a cart indicator, we can 2:01 easily present that back to the client. 2:05 We'll add the rest of our properties now that we expect.
The rest of the transcript is for members.
Sign in