Client/Calendar.pm

filter: Statementstmt 100% 11 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 14 / 14 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Calendar/Window.pm ↑ Summary Client/Contacts.pm »
1 package EWS::Client::Calendar;
2 BEGIN {
3 1 ▶ $EWS::Client::Calendar::VERSION = '1.143070';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 with 'EWS::Calendar::Role::Reader';
8 # could add future roles for updates, here
9  
10 1 has client => (
11 is => 'ro',
12 isa => 'EWS::Client',
13 required => 1,
14 weak_ref => 1,
15 );
16  
17 1 __PACKAGE__->meta->make_immutable;
18 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 1;
20  
21 # ABSTRACT: Calendar Entries from Microsoft Exchange Server
22  
23  
24 __END__
25 =pod
26  
27 =head1 NAME
28  
29 EWS::Client::Calendar - Calendar Entries from Microsoft Exchange Server
30  
31 =head1 VERSION
32  
33 version 1.143070
34  
35 =head1 SYNOPSIS
36  
37 First set up your Exchange Web Services client as per L<EWS::Client>:
38  
39 use EWS::Client;
40 use DateTime;
41
42 my $ews = EWS::Client->new({
43 server => 'exchangeserver.example.com',
44 username => 'oliver',
45 password => 's3krit', # or set in $ENV{EWS_PASS}
46 });
47  
48 Then perform operations on the calendar entries:
49  
50 my $entries = $ews->calendar->retrieve({
51 start => DateTime->now(),
52 end => DateTime->now->add( months => 1 ),
53 });
54
55 print "I retrieved ". $entries->count ." items\n";
56
57 while ($entries->has_next) {
58 print $entries->next->Subject, "\n";
59 }
60  
61 =head1 DESCRIPTION
62  
63 This module allows you to perform operations on the calendar entries in a
64 Microsoft Exchange server. At present only read operations are supported,
65 allowing you to retrieve calendar entries within a given time window. The
66 results are available in an iterator and convenience methods exist to access
67 the properties of each entry.
68  
69 =head1 METHODS
70  
71 =head2 CONSTRUCTOR
72  
73 =head2 EWS::Client::Calendar->new( \%arguments )
74  
75 You would not normally call this constructor. Use the L<EWS::Client>
76 constructor instead.
77  
78 Instantiates a new calendar reader. Note that the action of performing a query
79 for a set of results is separated from this step, so you can perform multiple
80 queries using this same object. Pass the following arguments in a hash ref:
81  
82 =over 4
83  
84 =item C<client> => C<EWS::Client> object (required)
85  
86 An instance of C<EWS::Client> which has been configured with your server
87 location, user credentials and SOAP APIs. This will be stored as a weak
88 reference.
89  
90 =back
91  
92 =head2 QUERY AND RESULT SET
93  
94 =head2 $cal->retrieve( \%arguments )
95  
96 Query the Exchange server and retrieve calendar entries between the given
97 timestamps. Pass the following arguments in a hash ref:
98  
99 =over 4
100  
101 =item C<start> => DateTime object (required)
102  
103 Entries with an end date on or after this timestamp will be included in the
104 returned results.
105  
106 =item C<end> => DateTime object (required)
107  
108 Entries with a start date before this timestamp will be included in the
109 results.
110  
111 =item C<email> => String (optional)
112  
113 Passing the primary SMTP address of another account will retrieve the contacts
114 for that Exchange user instead using the I<Delegation> feature, assuming you
115 have rights to see their contacts (i.e. the user has shared their contacts).
116 If you do not have rights, an error will be thrown.
117  
118 If you pass one of the account's secondary SMTP addresses this module
119 I<should> be able to divine the primary SMTP address required.
120  
121 =item C<impersonate> => String (optional)
122  
123 Passing the primary SMTP address of another account will retrieve the entries
124 for that Exchange user instead, assuming you have sufficient rights to
125 I<Impersonate> that account. If you do not have rights, an error will be
126 thrown.
127  
128 =back
129  
130 The returned object contains the collection of calendar entries which matched
131 the start and end criteria, and is of type C<EWS::Calendar::ResultSet>. It's
132 an iterator, so you can walk through the list of entries (see the synposis,
133 above). For example:
134  
135 my $entries = $cal->retrieve({start => '', end => ''});
136  
137 =head2 $entries->next
138  
139 Provides the next item in the collection of calendar entries, or C<undef> if
140 there are no more items to return. Usually used in a loop along with
141 C<has_next> like so:
142  
143 while ($entries->has_next) {
144 print $entries->next->Subject, "\n";
145 }
146  
147 =head2 $entries->peek
148  
149 Returns the next item without moving the state of the iterator forward. It
150 returns C<undef> if it is at the end of the collection and there are no more
151 items to return.
152  
153 =head2 $entries->has_next
154  
155 Returns a true value if there is another entry in the collection after the
156 current item, otherwise returns a false value.
157  
158 =head2 $entries->reset
159  
160 Resets the iterator's cursor, so you can walk through the entries again from
161 the start.
162  
163 =head2 $entries->count
164  
165 Returns the number of entries returned by the C<retrieve> server query.
166  
167 =head2 $entries->items
168  
169 Returns an array ref containing all the entries returned by the C<retrieve>
170 server query. They are each objects of type C<EWS::Calendar::Item>.
171  
172 =head2 ITEM PROPERTIES
173  
174 These descriptions are taken from Microsoft's on-line documentation.
175  
176 =head2 $item->Start
177  
178 A L<DateTime> object representing the starting date and time for a calendar
179 item.
180  
181 =head2 $item->End
182  
183 A L<DateTime> object representing the ending date and time for a calendar
184 item.
185  
186 =head2 $item->TimeSpan
187  
188 A human readable description of the time span of the event, for example:
189  
190 =over 4
191  
192 =item * 25 Feb 2010
193  
194 =item * Feb 16 - 19, 2010
195  
196 =item * 24 Feb 2010 15:00 - 16:00
197  
198 =back
199  
200 =head2 $item->Subject
201  
202 Represents the subject of a calendar item.
203  
204 =head2 $item->Body (optional)
205  
206 Text attachment to the calendar entry which the user may have entered content
207 into.
208  
209 =head2 $item->has_Body
210  
211 Will return true if the event item has content in its Body property, otherwise
212 returns false. Actually returns the length of the Body text content.
213  
214 =head2 $item->Location (optional)
215  
216 Friendly name for where a calendar item pertains to (e.g., a physical address
217 or "My Office").
218  
219 =head2 $item->has_Location
220  
221 Will return true if the event item has content in its Location property,
222 otherwise returns false. Actually returns the length of the Location text
223 content.
224  
225 =head2 $item->Type
226  
227 The type of calendar item indicating its relationship to a recurrence, if any.
228 This will be a string value of one of the following, only:
229  
230 =over 4
231  
232 =item * Single
233  
234 =item * Occurrence
235  
236 =item * Exception
237  
238 =back
239  
240 =head2 $item->CalendarItemType
241  
242 This is an alias (the native name, in fact) for the C<< $item->Type >>
243 property.
244  
245 =head2 $item->IsRecurring
246  
247 True if the event is of Type Occurrence or Exception, which means that it is
248 a recurring event, otherwise returns false.
249  
250 =head2 $item->Sensitivity
251  
252 Indicates the sensitivity of the item, which can be used to filter information
253 your user sees. Will be a string and one of the following four values, only:
254  
255 =over 4
256  
257 =item * Normal
258  
259 =item * Personal
260  
261 =item * Private
262  
263 =item * Confidential
264  
265 =back
266  
267 =head2 $item->DisplayTo (optional)
268  
269 When a client creates a calendar entry, there can be other people invited to
270 the event (usually via the To: box in Outlook, or similar). This property
271 contains an array ref of the display names ("Firstname Lastname") or the
272 parties invited to the event.
273  
274 =head2 $item->has_DisplayTo
275  
276 Will return true if there are entries in the C<< $item->DisplayTo >> property,
277 in other words there were invitees on this event, otherwise returns false.
278 Actually returns the number of entries in that list, which may be useful.
279  
280 =head2 $item->Organizer
281  
282 The display name (probably "Firstname Lastname") of the party responsible for
283 creating the entry.
284  
285 =head2 $item->IsCancelled
286  
287 True if the calendar item has been cancelled, otherwise false.
288  
289 =head2 $item->AppointmentState
290  
291 Contains a bitmask of flags on the entry, but you probably want to use
292 C<IsCancelled> instead.
293  
294 =head2 $item->Status (optional)
295  
296 Free/busy status for a calendar item, which can actually be one of the
297 following four string values:
298  
299 =over 4
300  
301 =item * Free
302  
303 =item * Tentative
304  
305 =item * Busy
306  
307 =item * OOF (means Out Of Office)
308  
309 =item * NoData (means something went wrong)
310  
311 =back
312  
313 If not provided the property will default to C<NoData>.
314  
315 =head2 $item->LegacyFreeBusyStatus (optional)
316  
317 This is an alias (the native name, in fact) for the C<< $item->Status >>
318 property.
319  
320 =head2 $item->IsDraft
321  
322 Indicates whether an item has not yet been sent.
323  
324 =head2 $item->IsAllDayEvent
325  
326 True if a calendar item is to be interpreted as lasting all day, otherwise
327 false.
328  
329 =head1 TODO
330  
331 There is currently no handling of time zone information whatsoever. I'm
332 waiting for my timezone to shift to UTC+1 in March before working on this, as
333 I don't really want to read the Exchange API docs. Patches are welcome if you
334 want to help out.
335  
336 =head1 SEE ALSO
337  
338 =over 4
339  
340 =item * L<http://msdn.microsoft.com/en-us/library/aa580675.aspx>
341  
342 =back
343  
344 =head1 AUTHOR
345  
346 Oliver Gorwits <oliver@cpan.org>
347  
348 =head1 COPYRIGHT AND LICENSE
349  
350 This software is copyright (c) 2014 by University of Oxford.
351  
352 This is free software; you can redistribute it and/or modify it under
353 the same terms as the Perl 5 programming language system itself.
354  
355 =cut
356  
« Calendar/Window.pm ↑ Summary Client/Contacts.pm »