viewpoint 0.1.23 → 0.1.24

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.
@@ -105,14 +105,16 @@ module Viewpoint
105
105
  # Gets a folder by name. This name must match the folder name exactly.
106
106
  # @param [String] name The name of the folder to fetch.
107
107
  # @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.
108
109
  def self.get_folder_by_name(name, shape = 'Default')
109
110
  # For now the :field_uRI and :field_uRI_or_constant must be in an Array for Ruby 1.8.7 because Hashes
110
111
  # are not positional at insertion until 1.9
111
112
  restr = {:restriction =>
112
113
  {:is_equal_to =>
113
114
  [{:field_uRI => {:field_uRI=>'folder:DisplayName'}}, {:field_uRI_or_constant =>{:constant => {:value=>name}}}]}}
114
- resp = (Viewpoint::EWS::EWS.instance).ews.find_folder([:msgfolderroot], 'Deep', {:base_shape => shape}, restr)
115
+ resp = (Viewpoint::EWS::EWS.instance).ews.find_folder([:root], 'Deep', {:base_shape => shape}, restr)
115
116
  if(resp.status == 'Success')
117
+ return nil if resp.items.empty?
116
118
  f = resp.items.first
117
119
  f_type = f.keys.first.to_s.camel_case
118
120
  eval "#{f_type}.new(f[f.keys.first])"
@@ -398,12 +400,19 @@ module Viewpoint
398
400
  # @param [String] name The name of the new folder
399
401
  def add_subfolder(name)
400
402
  resp = (Viewpoint::EWS::EWS.instance).ews.create_folder(@folder_id, name)
403
+ folder = resp.items.first
404
+ ftype = folder.keys.first
405
+ GenericFolder.get_folder(folder[ftype][:folder_id][:id])
401
406
  end
402
407
 
403
-
404
408
  # Deletes this folder from the Exchange Data Store
405
- def delete!
406
- resp = (Viewpoint::EWS::EWS.instance).ews.delete_folder(@folder_id)
409
+ # @param [Boolean] recycle_bin Send to the recycle bin instead of deleting (default: false)
410
+ # @return [TrueClass] This will return true because if an issue occurs it
411
+ # will be thrown in the SOAP Parser
412
+ def delete!(recycle_bin = false)
413
+ deltype = recycle_bin ? 'MoveToDeletedItems' : 'HardDelete'
414
+ resp = (Viewpoint::EWS::EWS.instance).ews.delete_folder(@folder_id, deltype)
415
+ true
407
416
  end
408
417
 
409
418
  private
@@ -43,6 +43,22 @@ module Viewpoint
43
43
  @response_message.items = folders
44
44
  end
45
45
 
46
+ def create_folder_response(opts)
47
+ if(@response_message.status == 'Success')
48
+ folders = []
49
+ (@response/"//#{NS_EWS_MESSAGES}:Folders/*").each do |f|
50
+ folders << xml_to_hash!(f.native_element)
51
+ end
52
+ @response_message.items = folders
53
+ else
54
+ raise EwsError, "#{@response_message.code}: #{@response_message.message}"
55
+ end
56
+ end
57
+
58
+ def delete_folder_response(opts)
59
+ raise EwsError, "#{@response_message.code}: #{@response_message.message}" unless @response_message.status == 'Success'
60
+ end
61
+
46
62
  def get_events_response(opts)
47
63
  if @response_message.status == 'Success'
48
64
  events = []
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: viewpoint
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.23
5
+ version: 0.1.24
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Wanek
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-27 00:00:00 -05:00
13
+ date: 2011-06-14 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  requirements: []
155
155
 
156
156
  rubyforge_project:
157
- rubygems_version: 1.5.0
157
+ rubygems_version: 1.6.2
158
158
  signing_key:
159
159
  specification_version: 3
160
160
  summary: A Ruby client access library for Microsoft Exchange Web Services (EWS)