1package Net::Google::Calendar::Calendar;
2
3use base qw(Net::Google::Calendar::Entry);
4
5=head1 NAME
6
7Net::Google::Calendar::Calendar - entry class for Net::Google::Calendar Calendar objects
8
9=head1 METHODS
10
11Note this is very rough at the moment - there are plenty of
12convenience methods that could be added but for now you'll
13have to access them using the underlying C<XML::Atom::Entry>
14object.
15
16=head2 new
17
18=cut
19
20sub new {
21    my ($class, %opts) = @_;
22
23    my $self  = $class->SUPER::new( Version => '1.0', %opts );
24    $self->_initialize();
25    return $self;
26}
27
28sub _initialize {
29    my $self = shift;
30
31    $self->{_gd_ns}   = XML::Atom::Namespace->new(gd => 'http://schemas.google.com/g/2005');
32    $self->{_gcal_ns} = XML::Atom::Namespace->new(gCal => 'http://schemas.google.com/gCal/2005');
33}
34
35=head2 summary [value]
36
37A summary of the calendar.
38
39=cut 
40
41sub summary {
42    my $self= shift;
43    if (@_) {
44        $self->set($self->ns, 'summary', shift);
45    }
46    return $self->get($self->ns, 'summary');
47}
48
49
50=head2 edit_url
51
52Get the edit url
53
54=cut
55
56sub edit_url {
57    my $self  = shift;
58    my $force = shift || 0;
59    my $url   = $self->_generic_url('edit');
60
61    $url      =~ s!/allcalendars/full!/owncalendars/full! if $force;
62    return $url;
63}
64
65=head2 color
66
67The color assigned to the calendar.
68
69=cut
70
71sub color {
72    my $self = shift;
73    if (@_) {}
74    if (my $el = $self->elem->getChildrenByTagName('gCal:color')->[0]) {
75        return $el->getAttribute('value');
76    }
77    return;
78}
79
80=head2 override_name
81
82Returns the override name of the calendar.  Not always set.
83
84=cut
85
86sub override_name {
87    my $self = shift;
88    if (@_) {}
89    if (my $el = $self->elem->getChildrenByTagName('gCal:overridename')->[0]) {
90        return $el->getAttribute('value');
91    }
92    return;
93}
94
95=head2 access_level
96
97Returns the access level of the calendar.
98
99=cut
100
101sub access_level {
102    my $self = shift;
103    if (@_) {}
104    if (my $el = $self->elem->getChildrenByTagName('gCal:accesslevel')->[0]) {
105        return $el->getAttribute('value');
106    }
107    return;
108}
109
110=head2 hidden
111
112Returns true if the calendar is hidden, false otherwise
113
114=cut
115
116sub hidden {
117    my $self = shift;
118    if (@_) {}
119    if (my $el = $self->elem->getChildrenByTagName('gCal:hidden')->[0]) {
120        if ($el->getAttribute('value') eq 'true') {
121            return 1;
122        }
123    }
124    return 0;
125}
126
127
128=head2 selected
129
130Returns true if the calendar is selected, false otherwise.
131
132=cut
133
134sub selected {
135    my $self = shift;
136    if (@_) {}
137    if (my $el = $self->elem->getChildrenByTagName('gCal:selected')->[0]) {
138        if ($el->getAttribute('value') eq 'true') {
139            return 1;
140        }
141    }
142    return 0;
143}
144
145=head2 time_zone
146
147Returns the time zone of the calendar.
148
149=cut
150
151sub time_zone {
152    my $self = shift;
153    if (@_) {}
154    if (my $el = $self->elem->getChildrenByTagName('gCal:timezone')->[0]) {
155        return $el->getAttribute('value');
156    }
157    return;
158}
159
160
161
162=head2 times_cleaned
163
164Returns the value of timesCleaned
165
166=cut
167
168sub times_cleaned {
169    my $self = shift;
170    if (@_) {}
171    if (my $el = $self->elem->getChildrenByTagName('gCal:timesCleaned')->[0]) {
172        return $el->getAttribute('value');
173    }
174    return;
175}
176
1771;
178