File Coverage

blib/lib/EWS/Client/DistributionList.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 10 100.0


line stmt bran cond sub pod time code
1             package EWS::Client::DistributionList;
2             BEGIN {
3 1     1   23 $EWS::Client::DistributionList::VERSION = '1.143070';
4             }
5 1     1   4 use Moose;
  1         1  
  1         9  
6              
7             with 'EWS::DistributionList::Role::Reader';
8              
9             # could add future roles for updates, here
10              
11             has client => (
12             is => 'ro',
13             isa => 'EWS::Client',
14             required => 1,
15             weak_ref => 1,
16             );
17              
18             __PACKAGE__->meta->make_immutable;
19 1     1   5112 no Moose;
  1         2  
  1         4  
20             1;
21              
22             # ABSTRACT: Distribution List Entries from Microsoft Exchange Server
23              
24              
25              
26             =pod
27              
28             =head1 NAME
29              
30             EWS::Client::DistributionList - Distribution List Entries from Microsoft Exchange Server
31              
32             =head1 VERSION
33              
34             version 1.143070
35              
36             =head1 SYNOPSIS
37              
38             First set up your Exchange Web Services client as per EWS::Client:
39              
40             use EWS::Client;
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 retrieve the distribution list entries:
49              
50             my $entries = $ews->distribution_list->retrieve( email => 'group@example.com');
51             # OR
52             $entries = $ews->distribution_list->expand('group@example.com');
53              
54             print "I retrieved ". $entries->count ." items\n";
55              
56             while ($entries->has_next) {
57             print $entries->next->EmailAddress, "\n";
58             }
59              
60             =head1 DESCRIPTION
61              
62             This module allows you to retrieve the set of Distribution List entries for an email address
63             on a Microsoft Exchange server. At present only read operations are supported.
64             The results are available in an iterator and convenience methods exist to
65             access the properties of each entry.
66              
67             =head1 METHODS
68              
69             =head2 CONSTRUCTOR
70              
71             =head2 EWS::Client::DistributionList->new( \%arguments )
72              
73             You would not normally call this constructor. Use the EWS::Client
74             constructor instead.
75              
76             Instantiates a new distribution list reader. Note that the action of performing a query
77             for a set of results is separated from this step, so you can perform multiple
78             queries using this same object. Pass the following arguments in a hash ref:
79              
80             =over 4
81              
82             =item C<client> => C<EWS::Client> object (required)
83              
84             An instance of C<EWS::Client> which has been configured with your server
85             location, user credentials and SOAP APIs. This will be stored as a weak
86             reference.
87              
88             =back
89              
90             =head2 QUERY AND RESULT SET
91              
92             =head2 $distribution_list->retrieve( \%arguments )
93              
94             Query the Exchange server and retrieve Mailbox members of the distribution list. Accepts the following arguments:
95              
96             =over 4
97              
98             =item C<distribution_email> => String (required)
99              
100             Passing the primary SMTP address of a distribution list will retrieve the
101             members for that list, assuming it is public or you have right to see the
102             private list. If you do not have rights, an error will be thrown.
103              
104             If you pass one of the account's secondary SMTP addresses this module
105             I<should> be able to divine the primary SMTP address required.
106              
107             =item C<impersonate> => String (optional)
108              
109             In addition to passing the 'distribution_email', passing the primary SMTP address of another account
110             will retrieve the requested private distribution list for the impersonated user. If you do not have
111             sufficient rights to I<Impersonate> that user, an error will be thrown.
112              
113             By default the C<retrieve()> method will return distribution list members for
114             public distribution lists or private lists you have access to using the
115             account under which you authenticated to the Exchange server (that is, the credentials
116             passed to the EWS::Client constructor). This argument will change that
117             behaviour.
118              
119             =back
120              
121             The returned object contains the collection of distribution list members and is of type
122             C<EWS::DistributionList::ResultSet>. It's an iterator, so you can walk through the
123             list of entries (see the synposis, above). For example:
124              
125             my $entries = $distribution_list->retrieve({distribution_email => 'group@example.com'});
126              
127             =head2 $distribution_list->expand( $string )
128              
129             This is a convenience method for passing a just a distribution_email attribute:
130              
131             $distribution_list->expand('group@example.com');
132             #is identical to:
133             $distribution_list->retrieve({distribution_email => 'group@example.com'});
134              
135             =head2 $entries->next
136              
137             Provides the next mailbox in the collection of distribution list entries, or C<undef> if
138             there are no more mailboxes to return. Usually used in a loop along with
139             C<has_next> like so:
140              
141             while ($entries->has_next) {
142             print $entries->next->Name, "\n";
143             }
144              
145             =head2 $entries->peek
146              
147             Returns the next item without moving the state of the iterator forward. It
148             returns C<undef> if it is at the end of the collection and there are no more
149             mailboxes to return.
150              
151             =head2 $entries->has_next
152              
153             Returns a true value if there is another entry in the collection after the
154             current item, otherwise returns a false value.
155              
156             =head2 $entries->reset
157              
158             Resets the iterator's cursor, so you can walk through the entries again from
159             the start.
160              
161             =head2 $entries->count
162              
163             Returns the number of entries returned by the C<retrieve> server query.
164              
165             =head2 $entries->mailboxes
166              
167             Returns an array ref containing all the entries returned by the C<retrieve>
168             server query. They are each objects of type C<EWS::DistributionList::Mailbox>.
169              
170             =head2 MAILBOX PROPERTIES
171              
172             =head2 $mailbox->Name
173              
174             Attribute contains the name of the mailbox user..
175              
176             =head2 $mailbox->EmailAddress
177              
178             Attribute contains the Simple Mail Transfer Protocol (SMTP) address of a mailbox user.
179              
180             =head2 $mailbox->MailboxType
181              
182             Attribute contains mailbox type of a mailbox user.
183              
184             =head2 $mailbox->RoutingType
185              
186             Attribute contains routing that is used for the mailbox. The default is SMTP.
187              
188             =head1 SEE ALSO
189              
190             =over 4
191              
192             =item * L<http://msdn.microsoft.com/en-us/library/aa580675.aspx>
193              
194             =back
195              
196             =head1 AUTHOR
197              
198             Oliver Gorwits <oliver@cpan.org>
199             John Judd <jjudd@cpan.org>
200              
201             =head1 COPYRIGHT AND LICENSE
202              
203             This software is copyright (c) 2013 by University of Oxford.
204              
205             This is free software; you can redistribute it and/or modify it under
206             the same terms as the Perl 5 programming language system itself.
207              
208             =head1 AUTHOR
209              
210             Oliver Gorwits <oliver@cpan.org>
211              
212             =head1 COPYRIGHT AND LICENSE
213              
214             This software is copyright (c) 2014 by University of Oxford.
215              
216             This is free software; you can redistribute it and/or modify it under
217             the same terms as the Perl 5 programming language system itself.
218              
219             =cut
220              
221              
222             __END__
223