1
use crate::common::FreeBusyTimeType;
2
use crate::model::component::{
3
    add_comment, add_contact, add_date_time_end, add_date_time_stamp, add_date_time_start,
4
    add_organizer, add_request_status, add_unique_identifier, add_url, impl_finish_component_build,
5
    impl_other_component_properties, CalendarComponent, ComponentProperty,
6
};
7
use crate::model::impl_component_access;
8
use crate::model::object::ICalObjectBuilder;
9
use crate::model::param::ParticipationStatusEvent;
10
use crate::model::property::{
11
    AddComponentProperty, AttendeePropertyBuilder, FreeBusyTimePropertyBuilder,
12
    IanaComponentPropertyBuilder, Period, XComponentPropertyBuilder,
13
};
14

            
15
#[derive(Debug, PartialEq)]
16
pub struct FreeBusyComponent {
17
    pub(crate) properties: Vec<ComponentProperty>,
18
}
19

            
20
impl_component_access!(FreeBusyComponent);
21

            
22
impl FreeBusyComponent {
23
16
    pub(crate) fn new() -> Self {
24
16
        FreeBusyComponent {
25
16
            properties: Vec::new(),
26
16
        }
27
16
    }
28
}
29

            
30
impl Default for FreeBusyComponent {
31
    fn default() -> Self {
32
        Self::new()
33
    }
34
}
35

            
36
pub struct FreeBusyComponentBuilder {
37
    owner: ICalObjectBuilder,
38
    inner: FreeBusyComponent,
39
}
40

            
41
impl FreeBusyComponentBuilder {
42
12
    pub(crate) fn new(owner: ICalObjectBuilder) -> Self {
43
12
        FreeBusyComponentBuilder {
44
12
            owner,
45
12
            inner: FreeBusyComponent {
46
12
                properties: Vec::new(),
47
12
            },
48
12
        }
49
12
    }
50

            
51
    add_date_time_stamp!();
52

            
53
    add_unique_identifier!();
54

            
55
    add_contact!();
56

            
57
    add_date_time_start!();
58

            
59
    add_date_time_end!();
60

            
61
    add_organizer!();
62

            
63
    add_url!();
64

            
65
12
    pub fn add_attendee(
66
12
        self,
67
12
        value: &str,
68
12
    ) -> AttendeePropertyBuilder<Self, ParticipationStatusEvent> {
69
12
        AttendeePropertyBuilder::new(self, value.to_string())
70
12
    }
71

            
72
    add_comment!();
73

            
74
12
    pub fn add_free_busy_time(
75
12
        self,
76
12
        free_busy_time_type: FreeBusyTimeType,
77
12
        periods: Vec<Period>,
78
12
    ) -> FreeBusyTimePropertyBuilder<Self> {
79
12
        FreeBusyTimePropertyBuilder::new(self, free_busy_time_type, periods)
80
12
    }
81

            
82
    add_request_status!();
83

            
84
    impl_other_component_properties!(
85
        XComponentPropertyBuilder,
86
        IanaComponentPropertyBuilder,
87
        FreeBusyComponentBuilder
88
    );
89

            
90
    impl_finish_component_build!(CalendarComponent::FreeBusy);
91
}
92

            
93
impl AddComponentProperty for FreeBusyComponentBuilder {
94
156
    fn add_property(&mut self, property: ComponentProperty) {
95
156
        self.inner.properties.push(property);
96
156
    }
97
}