dis_rs/common/service_request/
builder.rs

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