viewpoint 0.1.24 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,20 @@
1
- #############################################################################
2
- # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
- #
4
- #
5
- # This file is part of Viewpoint.
6
- #
7
- # Viewpoint is free software: you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as published
9
- # by the Free Software Foundation, either version 3 of the License, or (at
10
- # your option) any later version.
11
- #
12
- # Viewpoint is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
- # Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License along
18
- # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
- #############################################################################
1
+ =begin
2
+ This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ =end
20
18
 
21
19
  module Viewpoint
22
20
  module EWS
@@ -1,22 +1,20 @@
1
- #############################################################################
2
- # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
- #
4
- #
5
- # This file is part of Viewpoint.
6
- #
7
- # Viewpoint is free software: you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as published
9
- # by the Free Software Foundation, either version 3 of the License, or (at
10
- # your option) any later version.
11
- #
12
- # Viewpoint is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
- # Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License along
18
- # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
- #############################################################################
1
+ =begin
2
+ This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ =end
20
18
 
21
19
  # This class is inherited by all folder subtypes such as Mail, Calendar,
22
20
  # Tasks and Search. It will serve as the brain for all of the methods that
@@ -36,7 +34,7 @@ module Viewpoint
36
34
  recoverableitemsroot recoverableitemsdeletions recoverableitemsversions
37
35
  recoverableitemspurges archiveroot archivemsgfolderroot archivedeleteditems
38
36
  archiverecoverableitemsroot archiverecoverableitemsdeletions
39
- archiverecoverableitemsversions archiverecoverableitemspurges}
37
+ archiverecoverableitemsversions archiverecoverableitemspurges publicfoldersroot}
40
38
 
41
39
  @@event_types = %w{CopiedEvent CreatedEvent DeletedEvent ModifiedEvent MovedEvent NewMailEvent}
42
40
 
@@ -46,6 +44,7 @@ module Viewpoint
46
44
  # delegate access to this folder or else this operation will fail.
47
45
  # @param [Hash] folder_shape
48
46
  # @option folder_shape [String] :base_shape IdOnly/Default/AllProperties
47
+ # @raise [EwsError] raised when the backend SOAP method returns an error.
49
48
  def self.get_folder(folder_id, act_as = nil, folder_shape = {:base_shape => 'Default'})
50
49
  resp = (Viewpoint::EWS::EWS.instance).ews.get_folder( [normalize_id(folder_id)], folder_shape, act_as )
51
50
  if(resp.status == 'Success')
@@ -60,11 +59,12 @@ module Viewpoint
60
59
  # Find subfolders of the passed root folder. If no parameters are passed
61
60
  # this method will search from the Root folder.
62
61
  # @param [String,Symbol] root An folder id, either a DistinguishedFolderId (must me a Symbol)
63
- # or a FolderId (String)
62
+ # or a FolderId (String). This is where to start the search from. Usually :root,:msgfolderroot,:publicfoldersroot
64
63
  # @param [String] traversal Shallow/Deep/SoftDeleted
65
64
  # @param [String] shape the shape to return IdOnly/Default/AllProperties
66
65
  # @param [optional, String] folder_type an optional folder type to limit the search to like 'IPF.Task'
67
66
  # @return [Array] Returns an Array of Folder or subclasses of Folder
67
+ # @raise [EwsError] raised when the backend SOAP method returns an error.
68
68
  def self.find_folders(root = :msgfolderroot, traversal = 'Shallow', shape = 'Default', folder_type = nil)
69
69
  if( folder_type.nil? )
70
70
  resp = (Viewpoint::EWS::EWS.instance).ews.find_folder( [normalize_id(root)], traversal, {:base_shape => shape} )
@@ -88,8 +88,11 @@ module Viewpoint
88
88
  end
89
89
 
90
90
  # Return a list of folder names
91
+ # @param [String,Symbol] root An folder id, either a DistinguishedFolderId (must me a Symbol)
92
+ # or a FolderId (String). This is where to start the search from. Usually :root,:msgfolderroot,:publicfoldersroot
91
93
  # @return [Array<String>] Return an Array of folder names.
92
- def self.folder_names
94
+ # @raise [EwsError] raised when the backend SOAP method returns an error.
95
+ def self.folder_names(root = :msgfolderroot)
93
96
  resp = (Viewpoint::EWS::EWS.instance).ews.find_folder([:msgfolderroot], 'Shallow')
94
97
  if(resp.status == 'Success')
95
98
  flds = []
@@ -104,17 +107,22 @@ module Viewpoint
104
107
 
105
108
  # Gets a folder by name. This name must match the folder name exactly.
106
109
  # @param [String] name The name of the folder to fetch.
110
+ # @param [String,Symbol] root An folder id, either a DistinguishedFolderId (must me a Symbol)
111
+ # or a FolderId (String). This is where to start the search from. Usually :root,:msgfolderroot,:publicfoldersroot
107
112
  # @param [String] shape the shape of the object to return IdOnly/Default/AllProperties
108
- # @return [GenericFolder,nil] will return the folder by the given name of nil if not found.
109
- def self.get_folder_by_name(name, shape = 'Default')
113
+ # @return [GenericFolder] will return the folder by the given name.
114
+ # @raise [EwsFolderNotFound] raised when a folder requested is not found
115
+ # @raise [EwsError] raised when the backend SOAP method returns an error.
116
+ def self.get_folder_by_name(name, root = :msgfolderroot, shape = 'Default', opts = {})
117
+ opts[:traversal] = 'Deep' unless opts.has_key?(:traversal)
110
118
  # For now the :field_uRI and :field_uRI_or_constant must be in an Array for Ruby 1.8.7 because Hashes
111
119
  # are not positional at insertion until 1.9
112
120
  restr = {:restriction =>
113
121
  {:is_equal_to =>
114
122
  [{:field_uRI => {:field_uRI=>'folder:DisplayName'}}, {:field_uRI_or_constant =>{:constant => {:value=>name}}}]}}
115
- resp = (Viewpoint::EWS::EWS.instance).ews.find_folder([:root], 'Deep', {:base_shape => shape}, restr)
123
+ resp = (Viewpoint::EWS::EWS.instance).ews.find_folder([root], opts[:traversal], {:base_shape => shape}, restr)
116
124
  if(resp.status == 'Success')
117
- return nil if resp.items.empty?
125
+ raise EwsFolderNotFound, "The folder requested is invalid or unavailable" if resp.items.empty?
118
126
  f = resp.items.first
119
127
  f_type = f.keys.first.to_s.camel_case
120
128
  eval "#{f_type}.new(f[f.keys.first])"
@@ -123,6 +131,28 @@ module Viewpoint
123
131
  end
124
132
  end
125
133
 
134
+ # Gets a folder by the given path. The default search path is :msgfolderroot so if you want to
135
+ # specify a path at a different root change that parameter.
136
+ # @param [String] path the fully qualified path to a folder at the given root
137
+ # @example "/myfolders/folder a/personal calendar"
138
+ # @param [String,Symbol] root An folder id, either a DistinguishedFolderId (must me a Symbol)
139
+ # or a FolderId (String). This is where to start the search from. Usually :root,:msgfolderroot,:publicfoldersroot
140
+ # @param [String] shape the shape of the object to return IdOnly/Default/AllProperties
141
+ # @return [GenericFolder] will return the folder by the given path
142
+ # @raise [EwsFolderNotFound] raised when a folder requested is not found
143
+ # @raise [EwsError] raised when the backend SOAP method returns an error.
144
+ def self.get_folder_by_path(path, root = :msgfolderroot, shape = 'Default')
145
+ parts = path.split(/\//)
146
+ parts = parts.slice(1..(parts.length)) if parts.first.empty?
147
+ retfld = nil
148
+ parts.each do |p|
149
+ fld = self.get_folder_by_name(p, root, shape, {:traversal => 'Shallow'})
150
+ root = fld.id
151
+ retfld = fld if(fld.display_name.downcase == p.downcase)
152
+ end
153
+ retfld
154
+ end
155
+
126
156
  attr_accessor :folder_id, :change_key, :parent_id, :sync_state
127
157
  attr_reader :subscription_id, :watermark
128
158
  alias :id :folder_id
@@ -196,7 +226,7 @@ module Viewpoint
196
226
  end
197
227
 
198
228
  # Checks a subscribed folder for events
199
- # @returns [Array] An array of Event items
229
+ # @return [Array] An array of Event items
200
230
  # @todo check for subscription expiry
201
231
  def get_events
202
232
  begin
@@ -275,22 +305,22 @@ module Viewpoint
275
305
  # @param [String,nil] exclude_str A string to exclude from matches against the subject. This is optional.
276
306
  def search_by_subject(match_str, exclude_str = nil)
277
307
  match = {:contains =>
278
- {
279
- :containment_mode => 'Substring',
280
- :containment_comparison => 'IgnoreCase',
281
- :field_uRI => {:field_uRI=>'item:Subject'},
282
- :constant => {:value =>match_str}
283
- }
308
+ [
309
+ {:containment_mode => 'Substring'},
310
+ {:containment_comparison => 'IgnoreCase'},
311
+ {:field_uRI => {:field_uRI=>'item:Subject'}},
312
+ {:constant => {:value =>match_str}}
313
+ ]
284
314
  }
285
315
  unless exclude_str.nil?
286
316
  excl = {:not =>
287
317
  {:contains =>
288
- {
289
- :containment_mode => 'Substring',
290
- :containment_comparison => 'IgnoreCase',
291
- :field_uRI => {:field_uRI=>'item:Subject'},
292
- :constant => {:value =>exclude_str}
293
- }
318
+ [
319
+ {:containment_mode => 'Substring'},
320
+ {:containment_comparison => 'IgnoreCase'},
321
+ {:field_uRI => {:field_uRI=>'item:Subject'}},
322
+ {:constant => {:value =>exclude_str}}
323
+ ]
294
324
  }
295
325
  }
296
326
 
@@ -1,23 +1,20 @@
1
- #############################################################################
2
- # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
- #
4
- #
5
- # This file is part of Viewpoint.
6
- #
7
- # Viewpoint is free software: you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as published
9
- # by the Free Software Foundation, either version 3 of the License, or (at
10
- # your option) any later version.
11
- #
12
- # Viewpoint is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
- # Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License along
18
- # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
- #############################################################################
1
+ =begin
2
+ This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
20
3
 
4
+ Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ =end
21
18
 
22
19
  # This class is inherited by all Item subtypes such as Message, Event,
23
20
  # and Task. It will serve as the brain for all of the methods that
@@ -1,22 +1,20 @@
1
- #############################################################################
2
- # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
- #
4
- #
5
- # This file is part of Viewpoint.
6
- #
7
- # Viewpoint is free software: you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as published
9
- # by the Free Software Foundation, either version 3 of the License, or (at
10
- # your option) any later version.
11
- #
12
- # Viewpoint is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
- # Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License along
18
- # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
- #############################################################################
1
+ =begin
2
+ This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ =end
20
18
 
21
19
  module Viewpoint
22
20
  module EWS
@@ -1,3 +1,21 @@
1
+ =begin
2
+ This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ =end
18
+
1
19
  module Viewpoint
2
20
  module EWS
3
21
  module ItemFieldUriMap
@@ -1,22 +1,20 @@
1
- #############################################################################
2
- # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
- #
4
- #
5
- # This file is part of Viewpoint.
6
- #
7
- # Viewpoint is free software: you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as published
9
- # by the Free Software Foundation, either version 3 of the License, or (at
10
- # your option) any later version.
11
- #
12
- # Viewpoint is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
- # Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License along
18
- # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
- #############################################################################
1
+ =begin
2
+ This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ =end
20
18
 
21
19
  module Viewpoint
22
20
  module EWS
@@ -28,10 +26,12 @@ module Viewpoint
28
26
  include Model
29
27
 
30
28
  # Resolve a user in the Exchange Data Store
31
- # @param [String] A user to resolve to.
29
+ # @param [String] resolve A user to resolve to.
32
30
  # @return [MailboxUser,Array] If it resolves to one user then it returns a MailboxUser.
33
31
  # If it resolves to more than one user an Array of MailboxUsers are returned. If an
34
32
  # error ocurrs an exception is raised.
33
+ # @todo - rename "resolve" to something more descriptive
34
+ # - standardize on a common return type???
35
35
  def self.find_user(resolve)
36
36
  resp = (Viewpoint::EWS::EWS.instance).ews.resolve_names(resolve)
37
37
  if(resp.status == 'Success')
@@ -1,22 +1,20 @@
1
- #############################################################################
2
- # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
- #
4
- #
5
- # This file is part of Viewpoint.
6
- #
7
- # Viewpoint is free software: you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as published
9
- # by the Free Software Foundation, either version 3 of the License, or (at
10
- # your option) any later version.
11
- #
12
- # Viewpoint is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
- # Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License along
18
- # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
- #############################################################################
1
+ =begin
2
+ This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ =end
20
18
 
21
19
  module Viewpoint
22
20
  module EWS
@@ -1,22 +1,20 @@
1
- #############################################################################
2
- # Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
3
- #
4
- #
5
- # This file is part of Viewpoint.
6
- #
7
- # Viewpoint is free software: you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as published
9
- # by the Free Software Foundation, either version 3 of the License, or (at
10
- # your option) any later version.
11
- #
12
- # Viewpoint is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
- # Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License along
18
- # with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
19
- #############################################################################
1
+ =begin
2
+ This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ =end
20
18
 
21
19
  module Viewpoint
22
20
  module EWS