dis_rs/common/service_request/
builder.rs1use crate::common::model::EntityId;
2use crate::common::model::SupplyQuantity;
3use crate::common::service_request::model::ServiceRequest;
4use crate::enumerations::ServiceRequestServiceTypeRequested;
5use alloc::vec::Vec;
6
7pub struct ServiceRequestBuilder(ServiceRequest);
8
9impl Default for ServiceRequestBuilder {
10 fn default() -> Self {
11 Self::new()
12 }
13}
14
15impl ServiceRequestBuilder {
16 #[must_use]
17 pub fn new() -> Self {
18 ServiceRequestBuilder(ServiceRequest::default())
19 }
20
21 #[must_use]
22 pub fn new_from_body(body: ServiceRequest) -> Self {
23 ServiceRequestBuilder(body)
24 }
25
26 #[must_use]
27 pub fn build(self) -> ServiceRequest {
28 self.0
29 }
30
31 #[must_use]
32 pub fn with_requesting_id(mut self, requesting_id: EntityId) -> Self {
33 self.0.requesting_id = requesting_id;
34 self
35 }
36
37 #[must_use]
38 pub fn with_servicing_id(mut self, servicing_id: EntityId) -> Self {
39 self.0.servicing_id = servicing_id;
40 self
41 }
42
43 #[must_use]
44 pub fn with_service_type_requested(
45 mut self,
46 service_type_requested: ServiceRequestServiceTypeRequested,
47 ) -> Self {
48 self.0.service_type_requested = service_type_requested;
49 self
50 }
51
52 #[must_use]
53 pub fn with_supply(mut self, supplies: SupplyQuantity) -> Self {
54 self.0.supplies.push(supplies);
55 self
56 }
57
58 #[must_use]
59 pub fn with_supplies(mut self, supplies: Vec<SupplyQuantity>) -> Self {
60 self.0.supplies = supplies;
61 self
62 }
63}