viewpoint 1.2.0 → 2.0.0

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -6
  3. data/lib/ews/calendar_accessors.rb +37 -33
  4. data/lib/ews/connection.rb +152 -125
  5. data/lib/ews/connection_helper.rb +36 -33
  6. data/lib/ews/convert_accessors.rb +58 -54
  7. data/lib/ews/errors.rb +59 -53
  8. data/lib/ews/ews_client.rb +92 -79
  9. data/lib/ews/exceptions/exceptions.rb +61 -61
  10. data/lib/ews/folder_accessors.rb +235 -234
  11. data/lib/ews/impersonation.rb +29 -23
  12. data/lib/ews/item_accessors.rb +215 -213
  13. data/lib/ews/mailbox_accessors.rb +82 -79
  14. data/lib/ews/meeting_accessors.rb +38 -31
  15. data/lib/ews/message_accessors.rb +83 -81
  16. data/lib/ews/push_subscription_accessors.rb +29 -27
  17. data/lib/ews/room_accessors.rb +48 -46
  18. data/lib/ews/roomlist_accessors.rb +47 -45
  19. data/lib/ews/soap/builders/ews_builder.rb +1191 -1176
  20. data/lib/ews/soap/ews_response.rb +68 -73
  21. data/lib/ews/soap/ews_soap_availability_response.rb +57 -57
  22. data/lib/ews/soap/ews_soap_free_busy_response.rb +115 -117
  23. data/lib/ews/soap/ews_soap_response.rb +99 -101
  24. data/lib/ews/soap/ews_soap_room_response.rb +45 -45
  25. data/lib/ews/soap/ews_soap_roomlist_response.rb +45 -46
  26. data/lib/ews/soap/exchange_availability.rb +54 -52
  27. data/lib/ews/soap/exchange_data_services.rb +693 -711
  28. data/lib/ews/soap/exchange_notification.rb +123 -128
  29. data/lib/ews/soap/exchange_synchronization.rb +82 -82
  30. data/lib/ews/soap/exchange_time_zones.rb +41 -44
  31. data/lib/ews/soap/exchange_user_configuration.rb +30 -27
  32. data/lib/ews/soap/exchange_web_service.rb +237 -233
  33. data/lib/ews/soap/parsers/ews_parser.rb +46 -42
  34. data/lib/ews/soap/parsers/ews_sax_document.rb +63 -58
  35. data/lib/ews/soap/response_message.rb +69 -68
  36. data/lib/ews/soap/responses/create_attachment_response_message.rb +45 -45
  37. data/lib/ews/soap/responses/create_item_response_message.rb +26 -25
  38. data/lib/ews/soap/responses/find_item_response_message.rb +76 -78
  39. data/lib/ews/soap/responses/get_events_response_message.rb +52 -51
  40. data/lib/ews/soap/responses/send_notification_response_message.rb +53 -51
  41. data/lib/ews/soap/responses/subscribe_response_message.rb +37 -34
  42. data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +38 -35
  43. data/lib/ews/soap/responses/sync_folder_items_response_message.rb +38 -35
  44. data/lib/ews/soap.rb +27 -26
  45. data/lib/ews/templates/calendar_item.rb +64 -60
  46. data/lib/ews/templates/forward_item.rb +19 -17
  47. data/lib/ews/templates/message.rb +61 -58
  48. data/lib/ews/templates/reply_to_item.rb +20 -18
  49. data/lib/ews/templates/task.rb +55 -55
  50. data/lib/ews/types/attachment.rb +75 -74
  51. data/lib/ews/types/attendee.rb +27 -25
  52. data/lib/ews/types/calendar_folder.rb +58 -59
  53. data/lib/ews/types/calendar_item.rb +133 -131
  54. data/lib/ews/types/contact.rb +11 -5
  55. data/lib/ews/types/contacts_folder.rb +10 -5
  56. data/lib/ews/types/copied_event.rb +47 -48
  57. data/lib/ews/types/created_event.rb +22 -20
  58. data/lib/ews/types/deleted_event.rb +22 -20
  59. data/lib/ews/types/distribution_list.rb +11 -5
  60. data/lib/ews/types/event.rb +60 -59
  61. data/lib/ews/types/export_items_response_message.rb +54 -50
  62. data/lib/ews/types/file_attachment.rb +63 -61
  63. data/lib/ews/types/folder.rb +58 -57
  64. data/lib/ews/types/free_busy_changed_event.rb +22 -20
  65. data/lib/ews/types/generic_folder.rb +348 -372
  66. data/lib/ews/types/item.rb +401 -397
  67. data/lib/ews/types/item_attachment.rb +87 -80
  68. data/lib/ews/types/item_field_uri_map.rb +201 -200
  69. data/lib/ews/types/mailbox_user.rb +146 -154
  70. data/lib/ews/types/meeting_cancellation.rb +11 -5
  71. data/lib/ews/types/meeting_message.rb +11 -5
  72. data/lib/ews/types/meeting_request.rb +11 -5
  73. data/lib/ews/types/meeting_response.rb +11 -5
  74. data/lib/ews/types/message.rb +11 -5
  75. data/lib/ews/types/modified_event.rb +43 -45
  76. data/lib/ews/types/moved_event.rb +47 -48
  77. data/lib/ews/types/new_mail_event.rb +22 -20
  78. data/lib/ews/types/out_of_office.rb +145 -144
  79. data/lib/ews/types/post_item.rb +11 -5
  80. data/lib/ews/types/search_folder.rb +10 -5
  81. data/lib/ews/types/status_event.rb +37 -36
  82. data/lib/ews/types/task.rb +39 -33
  83. data/lib/ews/types/tasks_folder.rb +31 -25
  84. data/lib/ews/types.rb +134 -139
  85. data/lib/viewpoint/logging/config.rb +19 -19
  86. data/lib/viewpoint/logging.rb +23 -17
  87. data/lib/viewpoint/string_utils.rb +31 -32
  88. data/lib/viewpoint.rb +18 -18
  89. metadata +50 -25
  90. data/Changelog.txt +0 -1004
@@ -1,780 +1,762 @@
1
- module Viewpoint::EWS::SOAP
2
-
3
- # Exchange Data Service operations as listed in the EWS Documentation.
4
- # @see http://msdn.microsoft.com/en-us/library/bb409286.aspx
5
- module ExchangeDataServices
6
- include Viewpoint::EWS::SOAP
7
-
8
- # -------------- Item Operations -------------
9
-
10
- # Identifies items that are located in a specified folder
11
- # @see http://msdn.microsoft.com/en-us/library/aa566107.aspx
12
- #
13
- # @param [Hash] opts
14
- # @option opts [Array<Hash>] :parent_folder_ids An Array of folder id Hashes, either a
15
- # DistinguishedFolderId (must me a Symbol) or a FolderId (String)
16
- # [{:id => <myid>, :change_key => <ck>}, {:id => :root}]
17
- # @option opts [String] :traversal Shallow/Deep/SoftDeleted
18
- # @option opts [Hash] :item_shape defines the ItemShape node
19
- # @option item_shape [String] :base_shape IdOnly/Default/AllProperties
20
- # @option item_shape :additional_properties
21
- # See: http://msdn.microsoft.com/en-us/library/aa563810.aspx
22
- # @option opts [Hash] :calendar_view Limit FindItem by a start and end date
23
- # {:calendar_view => {:max_entries_returned => 2, :start_date =>
24
- # <DateTime Obj>, :end_date => <DateTime Obj>}}
25
- # @option opts [Hash] :contacts_view Limit FindItem between contact names
26
- # {:contacts_view => {:max_entries_returned => 2, :initial_name => 'Dan',
27
- # :final_name => 'Wally'}}
28
- # @example
29
- # { :parent_folder_ids => [{:id => root}],
30
- # :traversal => 'Shallow',
31
- # :item_shape => {:base_shape => 'Default'} }
32
- def find_item(opts)
33
- opts = opts.clone
34
- [:parent_folder_ids, :traversal, :item_shape].each do |k|
35
- validate_param(opts, k, true)
36
- end
37
- req = build_soap! do |type, builder|
38
- if(type == :header)
39
- else
40
- builder.nbuild.FindItem(:Traversal => camel_case(opts[:traversal])) {
41
- builder.nbuild.parent.default_namespace = @default_ns
42
- builder.item_shape!(opts[:item_shape])
43
- builder.indexed_page_item_view!(opts[:indexed_page_item_view]) if opts[:indexed_page_item_view]
44
- # @todo add FractionalPageFolderView
45
- builder.calendar_view!(opts[:calendar_view]) if opts[:calendar_view]
46
- builder.contacts_view!(opts[:contacts_view]) if opts[:contacts_view]
47
- builder.restriction!(opts[:restriction]) if opts[:restriction]
48
- builder.parent_folder_ids!(opts[:parent_folder_ids])
1
+ # frozen_string_literal: true
2
+
3
+ module Viewpoint
4
+ module EWS
5
+ module SOAP
6
+ # Exchange Data Service operations as listed in the EWS Documentation.
7
+ # @see http://msdn.microsoft.com/en-us/library/bb409286.aspx
8
+ module ExchangeDataServices
9
+ include Viewpoint::EWS::SOAP
10
+
11
+ # -------------- Item Operations -------------
12
+
13
+ # Identifies items that are located in a specified folder
14
+ # @see http://msdn.microsoft.com/en-us/library/aa566107.aspx
15
+ #
16
+ # @param [Hash] opts
17
+ # @option opts [Array<Hash>] :parent_folder_ids An Array of folder id Hashes, either a
18
+ # DistinguishedFolderId (must me a Symbol) or a FolderId (String)
19
+ # [{:id => <myid>, :change_key => <ck>}, {:id => :root}]
20
+ # @option opts [String] :traversal Shallow/Deep/SoftDeleted
21
+ # @option opts [Hash] :item_shape defines the ItemShape node
22
+ # @option item_shape [String] :base_shape IdOnly/Default/AllProperties
23
+ # @option item_shape :additional_properties
24
+ # See: http://msdn.microsoft.com/en-us/library/aa563810.aspx
25
+ # @option opts [Hash] :calendar_view Limit FindItem by a start and end date
26
+ # {:calendar_view => {:max_entries_returned => 2, :start_date =>
27
+ # <DateTime Obj>, :end_date => <DateTime Obj>}}
28
+ # @option opts [Hash] :contacts_view Limit FindItem between contact names
29
+ # {:contacts_view => {:max_entries_returned => 2, :initial_name => 'Dan',
30
+ # :final_name => 'Wally'}}
31
+ # @example
32
+ # { :parent_folder_ids => [{:id => root}],
33
+ # :traversal => 'Shallow',
34
+ # :item_shape => {:base_shape => 'Default'} }
35
+ def find_item(opts)
36
+ opts = opts.clone
37
+ %i[parent_folder_ids traversal item_shape].each do |k|
38
+ validate_param(opts, k, true)
39
+ end
40
+ req = build_soap! { |type, builder|
41
+ unless type == :header
42
+ builder.nbuild.FindItem(Traversal: camel_case(opts[:traversal])) {
43
+ builder.nbuild.parent.default_namespace = @default_ns
44
+ builder.item_shape!(opts[:item_shape])
45
+ builder.indexed_page_item_view!(opts[:indexed_page_item_view]) if opts[:indexed_page_item_view]
46
+ # @todo add FractionalPageFolderView
47
+ builder.calendar_view!(opts[:calendar_view]) if opts[:calendar_view]
48
+ builder.contacts_view!(opts[:contacts_view]) if opts[:contacts_view]
49
+ builder.restriction!(opts[:restriction]) if opts[:restriction]
50
+ builder.parent_folder_ids!(opts[:parent_folder_ids])
51
+ }
52
+ end
49
53
  }
54
+ do_soap_request(req, response_class: EwsResponse)
50
55
  end
51
- end
52
- do_soap_request(req, response_class: EwsResponse)
53
- end
54
56
 
55
- # Gets items from the Exchange store
56
- # @see http://msdn.microsoft.com/en-us/library/aa565934(v=EXCHG.140).aspx
57
- #
58
- # @param [Hash] opts
59
- # @option opts [Hash] :item_shape The item shape properties
60
- # Ex: {:base_shape => 'Default'}
61
- # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
62
- # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
63
- # Microsoft docs for more information.
64
- # @example
65
- # opts = {
66
- # :item_shape => {:base_shape => 'Default'},
67
- # :item_ids => [
68
- # {:item_id => {:id => 'id1'}},
69
- # {:occurrence_item_id => {:recurring_master_id => 'rid1', :change_key => 'ck', :instance_index => 1}},
70
- # {:recurring_master_item_id => {:occurrence_id => 'oid1', :change_key => 'ck'}}
71
- # ]}
72
- def get_item(opts)
73
- opts = opts.clone
74
- [:item_shape, :item_ids].each do |k|
75
- validate_param(opts, k, true)
76
- end
77
- req = build_soap! do |type, builder|
78
- if(type == :header)
79
- else
80
- builder.nbuild.GetItem {
81
- builder.nbuild.parent.default_namespace = @default_ns
82
- builder.item_shape!(opts[:item_shape])
83
- builder.item_ids!(opts[:item_ids])
57
+ # Gets items from the Exchange store
58
+ # @see http://msdn.microsoft.com/en-us/library/aa565934(v=EXCHG.140).aspx
59
+ #
60
+ # @param [Hash] opts
61
+ # @option opts [Hash] :item_shape The item shape properties
62
+ # Ex: {:base_shape => 'Default'}
63
+ # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
64
+ # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
65
+ # Microsoft docs for more information.
66
+ # @example
67
+ # opts = {
68
+ # :item_shape => {:base_shape => 'Default'},
69
+ # :item_ids => [
70
+ # {:item_id => {:id => 'id1'}},
71
+ # {:occurrence_item_id => {:recurring_master_id => 'rid1', :change_key => 'ck', :instance_index => 1}},
72
+ # {:recurring_master_item_id => {:occurrence_id => 'oid1', :change_key => 'ck'}}
73
+ # ]}
74
+ def get_item(opts)
75
+ opts = opts.clone
76
+ %i[item_shape item_ids].each do |k|
77
+ validate_param(opts, k, true)
78
+ end
79
+ req = build_soap! { |type, builder|
80
+ unless type == :header
81
+ builder.nbuild.GetItem {
82
+ builder.nbuild.parent.default_namespace = @default_ns
83
+ builder.item_shape!(opts[:item_shape])
84
+ builder.item_ids!(opts[:item_ids])
85
+ }
86
+ end
84
87
  }
88
+ do_soap_request(req, response_class: EwsResponse)
85
89
  end
86
- end
87
- do_soap_request(req, response_class: EwsResponse)
88
- end
89
90
 
90
- # Defines a request to create an item in the Exchange store.
91
- # @see http://msdn.microsoft.com/en-us/library/aa565209(v=EXCHG.140).aspx
92
- #
93
- # @param [Hash] opts
94
- # @option opts [String] :message_disposition How the item will be handled after it is created.
95
- # Only applicable for to e-mail. Must be one of 'SaveOnly', 'SendOnly', or 'SendAndSaveCopy'
96
- # @option opts [String] :send_meeting_invitations How meeting requests are handled after they
97
- # are created. Required for calendar items. Must be one of 'SendToNone', 'SendOnlyToAll',
98
- # 'SendToAllAndSaveCopy'
99
- # @option opts [Hash] :saved_item_folder_id A well formatted folder_id Hash. Ex: {:id => :inbox}
100
- # Will on work if 'SendOnly' is specified for :message_disposition
101
- # @option opts [Array<Hash>] :items This is a complex Hash that conforms to various Item types.
102
- # Please see the Microsoft documentation for this element.
103
- # @example
104
- # opts = {
105
- # message_disposition: 'SendAndSaveCopy',
106
- # items: [ {message:
107
- # {subject: 'test2',
108
- # body: {body_type: 'Text', text: 'this is a test'},
109
- # to_recipients: [{mailbox: {email_address: 'dan.wanek@gmail.com'}}]
110
- # }
111
- # }]}
112
- #
113
- # opts = {
114
- # send_meeting_invitations: 'SendToAllAndSaveCopy',
115
- # items: [ {calendar_item:
116
- # {subject: 'test cal item',
117
- # body: {body_type: 'Text', text: 'this is a test cal item'},
118
- # start: {text: Chronic.parse('tomorrow at 4pm').to_datetime.to_s},
119
- # end: {text: Chronic.parse('tomorrow at 5pm').to_datetime.to_s},
120
- # required_attendees: [
121
- # {attendee: {mailbox: {email_address: 'dan.wanek@gmail.com'}}},
122
- # ]
123
- # }
124
- # }]
125
- def create_item(opts)
126
- opts = opts.clone
127
- [:items].each do |k|
128
- validate_param(opts, k, true)
129
- end
130
- req = build_soap! do |type, builder|
131
- attribs = {}
132
- attribs['MessageDisposition'] = opts[:message_disposition] if opts[:message_disposition]
133
- attribs['SendMeetingInvitations'] = opts[:send_meeting_invitations] if opts[:send_meeting_invitations]
134
- if(type == :header)
135
- else
136
- builder.nbuild.CreateItem(attribs) {
137
- builder.nbuild.parent.default_namespace = @default_ns
138
- builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
139
- builder.nbuild.Items {
140
- opts[:items].each {|i|
141
- # The key can be any number of item types like :message,
142
- # :calendar, etc
143
- ikey = i.keys.first
144
- builder.send("#{ikey}!",i[ikey])
91
+ # Defines a request to create an item in the Exchange store.
92
+ # @see http://msdn.microsoft.com/en-us/library/aa565209(v=EXCHG.140).aspx
93
+ #
94
+ # @param [Hash] opts
95
+ # @option opts [String] :message_disposition How the item will be handled after it is created.
96
+ # Only applicable for to e-mail. Must be one of 'SaveOnly', 'SendOnly', or 'SendAndSaveCopy'
97
+ # @option opts [String] :send_meeting_invitations How meeting requests are handled after they
98
+ # are created. Required for calendar items. Must be one of 'SendToNone', 'SendOnlyToAll',
99
+ # 'SendToAllAndSaveCopy'
100
+ # @option opts [Hash] :saved_item_folder_id A well formatted folder_id Hash. Ex: {:id => :inbox}
101
+ # Will on work if 'SendOnly' is specified for :message_disposition
102
+ # @option opts [Array<Hash>] :items This is a complex Hash that conforms to various Item types.
103
+ # Please see the Microsoft documentation for this element.
104
+ # @example
105
+ # opts = {
106
+ # message_disposition: 'SendAndSaveCopy',
107
+ # items: [ {message:
108
+ # {subject: 'test2',
109
+ # body: {body_type: 'Text', text: 'this is a test'},
110
+ # to_recipients: [{mailbox: {email_address: 'dan.wanek@gmail.com'}}]
111
+ # }
112
+ # }]}
113
+ #
114
+ # opts = {
115
+ # send_meeting_invitations: 'SendToAllAndSaveCopy',
116
+ # items: [ {calendar_item:
117
+ # {subject: 'test cal item',
118
+ # body: {body_type: 'Text', text: 'this is a test cal item'},
119
+ # start: {text: Chronic.parse('tomorrow at 4pm').to_datetime.to_s},
120
+ # end: {text: Chronic.parse('tomorrow at 5pm').to_datetime.to_s},
121
+ # required_attendees: [
122
+ # {attendee: {mailbox: {email_address: 'dan.wanek@gmail.com'}}},
123
+ # ]
124
+ # }
125
+ # }]
126
+ def create_item(opts)
127
+ opts = opts.clone
128
+ [:items].each do |k|
129
+ validate_param(opts, k, true)
130
+ end
131
+ req = build_soap! { |type, builder|
132
+ attribs = {}
133
+ attribs['MessageDisposition'] = opts[:message_disposition] if opts[:message_disposition]
134
+ attribs['SendMeetingInvitations'] = opts[:send_meeting_invitations] if opts[:send_meeting_invitations]
135
+ unless type == :header
136
+ builder.nbuild.CreateItem(attribs) {
137
+ builder.nbuild.parent.default_namespace = @default_ns
138
+ builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
139
+ builder.nbuild.Items {
140
+ opts[:items].each { |i|
141
+ # The key can be any number of item types like :message,
142
+ # :calendar, etc
143
+ ikey = i.keys.first
144
+ builder.send("#{ikey}!", i[ikey])
145
+ }
146
+ }
145
147
  }
146
- }
148
+ end
147
149
  }
150
+ do_soap_request(req, response_class: EwsResponse)
148
151
  end
149
- end
150
- do_soap_request(req, response_class: EwsResponse)
151
- end
152
152
 
153
- # Used to modify the properties of an existing item in the Exchange store
154
- # @see http://msdn.microsoft.com/en-us/library/aa581084(v=exchg.140).aspx
155
- #
156
- # @param [Hash] opts
157
- # @option opts [String] :conflict_resolution Identifies the type of conflict resolution to
158
- # try during an update. The default value is AutoResolve. Available options are
159
- # 'NeverOverwrite', 'AutoResolve', 'AlwaysOverwrite'
160
- # @option opts [String] :message_disposition How the item will be handled after it is updated.
161
- # Only applicable for to e-mail. Must be one of 'SaveOnly', 'SendOnly', or 'SendAndSaveCopy'
162
- # @option opts [String] :send_meeting_invitations_or_cancellations How meeting requests are
163
- # handled after they are updated. Required for calendar items. Must be one of 'SendToNone',
164
- # 'SendOnlyToAll', 'SendOnlyToChanged', 'SendToAllAndSaveCopy', 'SendToChangedAndSaveCopy'
165
- # @option opts [Hash] :saved_item_folder_id A well formatted folder_id Hash. Ex: {:id => :sentitems}
166
- # Will on work if 'SendOnly' is specified for :message_disposition
167
- # @option opts [Array<Hash>] :item_changes an array of ItemChange elements that identify items
168
- # and the updates to apply to the items. See the Microsoft docs for more information.
169
- # @example
170
- # opts = {
171
- # :send_meeting_invitations_or_cancellations => 'SendOnlyToChangedAndSaveCopy',
172
- # :item_changes => [
173
- # { :item_id => {:id => 'id1'},
174
- # :updates => [
175
- # {:set_item_field => {
176
- # :field_uRI => {:field_uRI => 'item:Subject'},
177
- # # The following needs to conform to #build_xml! format for now
178
- # :calendar_item => { :sub_elements => [{:subject => {:text => 'Test Subject'}}]}
179
- # }}
180
- # ]
181
- # }
182
- # ]
183
- # }
184
- def update_item(opts)
185
- opts = opts.clone
186
- [:item_changes].each do |k|
187
- validate_param(opts, k, true)
188
- end
189
- req = build_soap! do |type, builder|
190
- attribs = {}
191
- attribs['MessageDisposition'] = opts[:message_disposition] if opts[:message_disposition]
192
- attribs['ConflictResolution'] = opts[:conflict_resolution] if opts[:conflict_resolution]
193
- attribs['SendMeetingInvitationsOrCancellations'] = opts[:send_meeting_invitations_or_cancellations] if opts[:send_meeting_invitations_or_cancellations]
194
- if(type == :header)
195
- else
196
- builder.nbuild.UpdateItem(attribs) {
197
- builder.nbuild.parent.default_namespace = @default_ns
198
- builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
199
- builder.item_changes!(opts[:item_changes])
153
+ # Used to modify the properties of an existing item in the Exchange store
154
+ # @see http://msdn.microsoft.com/en-us/library/aa581084(v=exchg.140).aspx
155
+ #
156
+ # @param [Hash] opts
157
+ # @option opts [String] :conflict_resolution Identifies the type of conflict resolution to
158
+ # try during an update. The default value is AutoResolve. Available options are
159
+ # 'NeverOverwrite', 'AutoResolve', 'AlwaysOverwrite'
160
+ # @option opts [String] :message_disposition How the item will be handled after it is updated.
161
+ # Only applicable for to e-mail. Must be one of 'SaveOnly', 'SendOnly', or 'SendAndSaveCopy'
162
+ # @option opts [String] :send_meeting_invitations_or_cancellations How meeting requests are
163
+ # handled after they are updated. Required for calendar items. Must be one of 'SendToNone',
164
+ # 'SendOnlyToAll', 'SendOnlyToChanged', 'SendToAllAndSaveCopy', 'SendToChangedAndSaveCopy'
165
+ # @option opts [Hash] :saved_item_folder_id A well formatted folder_id Hash. Ex: {:id => :sentitems}
166
+ # Will on work if 'SendOnly' is specified for :message_disposition
167
+ # @option opts [Array<Hash>] :item_changes an array of ItemChange elements that identify items
168
+ # and the updates to apply to the items. See the Microsoft docs for more information.
169
+ # @example
170
+ # opts = {
171
+ # :send_meeting_invitations_or_cancellations => 'SendOnlyToChangedAndSaveCopy',
172
+ # :item_changes => [
173
+ # { :item_id => {:id => 'id1'},
174
+ # :updates => [
175
+ # {:set_item_field => {
176
+ # :field_uRI => {:field_uRI => 'item:Subject'},
177
+ # # The following needs to conform to #build_xml! format for now
178
+ # :calendar_item => { :sub_elements => [{:subject => {:text => 'Test Subject'}}]}
179
+ # }}
180
+ # ]
181
+ # }
182
+ # ]
183
+ # }
184
+ def update_item(opts)
185
+ opts = opts.clone
186
+ [:item_changes].each do |k|
187
+ validate_param(opts, k, true)
188
+ end
189
+ req = build_soap! { |type, builder|
190
+ attribs = {}
191
+ attribs['MessageDisposition'] = opts[:message_disposition] if opts[:message_disposition]
192
+ attribs['ConflictResolution'] = opts[:conflict_resolution] if opts[:conflict_resolution]
193
+ if opts[:send_meeting_invitations_or_cancellations]
194
+ attribs['SendMeetingInvitationsOrCancellations'] =
195
+ opts[:send_meeting_invitations_or_cancellations]
196
+ end
197
+ unless type == :header
198
+ builder.nbuild.UpdateItem(attribs) {
199
+ builder.nbuild.parent.default_namespace = @default_ns
200
+ builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
201
+ builder.item_changes!(opts[:item_changes])
202
+ }
203
+ end
200
204
  }
205
+ do_soap_request(req, response_class: EwsResponse)
201
206
  end
202
- end
203
- do_soap_request(req, response_class: EwsResponse)
204
- end
205
207
 
206
- # Delete an item from a mailbox in the Exchange store
207
- # @see http://msdn.microsoft.com/en-us/library/aa580484(v=exchg.140).aspx
208
- #
209
- # @param [Hash] opts
210
- # @option opts [String] :delete_type Describes how an item is deleted. Must be one of
211
- # 'HardDelete', 'SoftDelete', or 'MoveToDeletedItems'
212
- # @option opts [String] :send_meeting_cancellations How meetings are handled after they
213
- # are deleted. Required for calendar items. Must be one of 'SendToNone', 'SendOnlyToAll',
214
- # 'SendToAllAndSaveCopy'
215
- # @option opts [String] :affected_task_occurrences Describes whether a task instance or a
216
- # task master is deleted by a DeleteItem Operation. This attribute is required when
217
- # tasks are deleted. Must be one of 'AllOccurrences' or 'SpecifiedOccurrenceOnly'
218
- # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
219
- # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
220
- # Microsoft docs for more information.
221
- # @example
222
- # opts = {
223
- # :delete_type => 'MoveToDeletedItems',
224
- # :item_ids => [{:item_id => {:id => 'id1'}}]
225
- # }
226
- # inst.delete_item(opts)
227
- def delete_item(opts)
228
- opts = opts.clone
229
- [:delete_type, :item_ids].each do |k|
230
- validate_param(opts, k, true)
231
- end
232
- req = build_soap! do |type, builder|
233
- attribs = {'DeleteType' => opts[:delete_type]}
234
- attribs['SendMeetingCancellations'] = opts[:send_meeting_cancellations] if opts[:send_meeting_cancellations]
235
- attribs['AffectedTaskOccurrences'] = opts[:affected_task_occurrences] if opts[:affected_task_occurrences]
236
- if(type == :header)
237
- else
238
- builder.nbuild.DeleteItem(attribs) {
239
- builder.nbuild.parent.default_namespace = @default_ns
240
- builder.item_ids!(opts[:item_ids])
208
+ # Delete an item from a mailbox in the Exchange store
209
+ # @see http://msdn.microsoft.com/en-us/library/aa580484(v=exchg.140).aspx
210
+ #
211
+ # @param [Hash] opts
212
+ # @option opts [String] :delete_type Describes how an item is deleted. Must be one of
213
+ # 'HardDelete', 'SoftDelete', or 'MoveToDeletedItems'
214
+ # @option opts [String] :send_meeting_cancellations How meetings are handled after they
215
+ # are deleted. Required for calendar items. Must be one of 'SendToNone', 'SendOnlyToAll',
216
+ # 'SendToAllAndSaveCopy'
217
+ # @option opts [String] :affected_task_occurrences Describes whether a task instance or a
218
+ # task master is deleted by a DeleteItem Operation. This attribute is required when
219
+ # tasks are deleted. Must be one of 'AllOccurrences' or 'SpecifiedOccurrenceOnly'
220
+ # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
221
+ # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
222
+ # Microsoft docs for more information.
223
+ # @example
224
+ # opts = {
225
+ # :delete_type => 'MoveToDeletedItems',
226
+ # :item_ids => [{:item_id => {:id => 'id1'}}]
227
+ # }
228
+ # inst.delete_item(opts)
229
+ def delete_item(opts)
230
+ opts = opts.clone
231
+ %i[delete_type item_ids].each do |k|
232
+ validate_param(opts, k, true)
233
+ end
234
+ req = build_soap! { |type, builder|
235
+ attribs = { 'DeleteType' => opts[:delete_type] }
236
+ attribs['SendMeetingCancellations'] = opts[:send_meeting_cancellations] if opts[:send_meeting_cancellations]
237
+ attribs['AffectedTaskOccurrences'] = opts[:affected_task_occurrences] if opts[:affected_task_occurrences]
238
+ unless type == :header
239
+ builder.nbuild.DeleteItem(attribs) {
240
+ builder.nbuild.parent.default_namespace = @default_ns
241
+ builder.item_ids!(opts[:item_ids])
242
+ }
243
+ end
241
244
  }
245
+ do_soap_request(req, response_class: EwsResponse)
242
246
  end
243
- end
244
- do_soap_request(req, response_class: EwsResponse)
245
- end
246
247
 
247
- # Used to move one or more items to a single destination folder.
248
- # @see http://msdn.microsoft.com/en-us/library/aa565781(v=exchg.140).aspx
249
- #
250
- # @param [Hash] opts
251
- # @option opts [Hash] :to_folder_id A well formatted folder_id Hash. Ex: {:id => :inbox}
252
- # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
253
- # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
254
- # Microsoft docs for more information.
255
- # @option opts [Boolean] :return_new_item_ids Indicates whether the item identifiers of
256
- # new items are returned in the response
257
- # @example
258
- # opts = {
259
- # :to_folder_id => {:id => :inbox},
260
- # :item_ids => [
261
- # {:item_id => {:id => 'id1'}},
262
- # {:item_id => {:id => 'id2'}},
263
- # ],
264
- # :return_new_item_ids => true
265
- # }
266
- # obj.move_item(opts)
267
- def move_item(opts)
268
- opts = opts.clone
269
- [:to_folder_id, :item_ids].each do |k|
270
- validate_param(opts, k, true)
271
- end
272
- return_new_ids = validate_param(opts, :return_new_item_ids, false, true)
273
-
274
- req = build_soap! do |type, builder|
275
- if(type == :header)
276
- else
277
- builder.nbuild.MoveItem {
278
- builder.nbuild.parent.default_namespace = @default_ns
279
- builder.to_folder_id!(opts[:to_folder_id])
280
- builder.item_ids!(opts[:item_ids])
281
- builder.return_new_item_ids!(return_new_ids)
248
+ # Used to move one or more items to a single destination folder.
249
+ # @see http://msdn.microsoft.com/en-us/library/aa565781(v=exchg.140).aspx
250
+ #
251
+ # @param [Hash] opts
252
+ # @option opts [Hash] :to_folder_id A well formatted folder_id Hash. Ex: {:id => :inbox}
253
+ # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
254
+ # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
255
+ # Microsoft docs for more information.
256
+ # @option opts [Boolean] :return_new_item_ids Indicates whether the item identifiers of
257
+ # new items are returned in the response
258
+ # @example
259
+ # opts = {
260
+ # :to_folder_id => {:id => :inbox},
261
+ # :item_ids => [
262
+ # {:item_id => {:id => 'id1'}},
263
+ # {:item_id => {:id => 'id2'}},
264
+ # ],
265
+ # :return_new_item_ids => true
266
+ # }
267
+ # obj.move_item(opts)
268
+ def move_item(opts)
269
+ opts = opts.clone
270
+ %i[to_folder_id item_ids].each do |k|
271
+ validate_param(opts, k, true)
272
+ end
273
+ return_new_ids = validate_param(opts, :return_new_item_ids, false, true)
274
+
275
+ req = build_soap! { |type, builder|
276
+ unless type == :header
277
+ builder.nbuild.MoveItem {
278
+ builder.nbuild.parent.default_namespace = @default_ns
279
+ builder.to_folder_id!(opts[:to_folder_id])
280
+ builder.item_ids!(opts[:item_ids])
281
+ builder.return_new_item_ids!(return_new_ids)
282
+ }
283
+ end
282
284
  }
285
+ do_soap_request(req, response_class: EwsResponse)
283
286
  end
284
- end
285
- do_soap_request(req, response_class: EwsResponse)
286
- end
287
287
 
288
- # Copies items and puts the items in a different folder
289
- # @see http://msdn.microsoft.com/en-us/library/aa565012(v=exchg.140).aspx
290
- #
291
- # @param [Hash] opts
292
- # @option opts [Hash] :to_folder_id A well formatted folder_id Hash. Ex: {:id => :inbox}
293
- # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
294
- # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
295
- # Microsoft docs for more information.
296
- # @option opts [Boolean] :return_new_item_ids Indicates whether the item identifiers of
297
- # new items are returned in the response
298
- # @example
299
- # opts = {
300
- # :to_folder_id => {:id => :inbox},
301
- # :item_ids => [
302
- # {:item_id => {:id => 'id1'}},
303
- # {:item_id => {:id => 'id2'}},
304
- # ],
305
- # :return_new_item_ids => true
306
- # }
307
- # obj.copy_item(opts)
308
- def copy_item(opts)
309
- opts = opts.clone
310
- [:to_folder_id, :item_ids].each do |k|
311
- validate_param(opts, k, true)
312
- end
313
- return_new_ids = validate_param(opts, :return_new_item_ids, false, true)
314
-
315
- req = build_soap! do |type, builder|
316
- if(type == :header)
317
- else
318
- builder.nbuild.CopyItem {
319
- builder.nbuild.parent.default_namespace = @default_ns
320
- builder.to_folder_id!(opts[:to_folder_id])
321
- builder.item_ids!(opts[:item_ids])
322
- builder.return_new_item_ids!(return_new_ids)
288
+ # Copies items and puts the items in a different folder
289
+ # @see http://msdn.microsoft.com/en-us/library/aa565012(v=exchg.140).aspx
290
+ #
291
+ # @param [Hash] opts
292
+ # @option opts [Hash] :to_folder_id A well formatted folder_id Hash. Ex: {:id => :inbox}
293
+ # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
294
+ # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
295
+ # Microsoft docs for more information.
296
+ # @option opts [Boolean] :return_new_item_ids Indicates whether the item identifiers of
297
+ # new items are returned in the response
298
+ # @example
299
+ # opts = {
300
+ # :to_folder_id => {:id => :inbox},
301
+ # :item_ids => [
302
+ # {:item_id => {:id => 'id1'}},
303
+ # {:item_id => {:id => 'id2'}},
304
+ # ],
305
+ # :return_new_item_ids => true
306
+ # }
307
+ # obj.copy_item(opts)
308
+ def copy_item(opts)
309
+ opts = opts.clone
310
+ %i[to_folder_id item_ids].each do |k|
311
+ validate_param(opts, k, true)
312
+ end
313
+ return_new_ids = validate_param(opts, :return_new_item_ids, false, true)
314
+
315
+ req = build_soap! { |type, builder|
316
+ unless type == :header
317
+ builder.nbuild.CopyItem {
318
+ builder.nbuild.parent.default_namespace = @default_ns
319
+ builder.to_folder_id!(opts[:to_folder_id])
320
+ builder.item_ids!(opts[:item_ids])
321
+ builder.return_new_item_ids!(return_new_ids)
322
+ }
323
+ end
323
324
  }
325
+ do_soap_request(req, response_class: EwsResponse)
324
326
  end
325
- end
326
- do_soap_request(req, response_class: EwsResponse)
327
- end
328
327
 
329
- # Used to send e-mail messages that are located in the Exchange store.
330
- # @see http://msdn.microsoft.com/en-us/library/aa580238(v=exchg.140).aspx
331
- #
332
- # @param [Hash] opts
333
- # @option opts [Boolean] :save_item_to_folder To save or not to save... save! :-)
334
- # @option opts [Hash] :saved_item_folder_id A well formatted folder_id Hash. Ex: {:id => :sentitems}
335
- # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
336
- # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
337
- # Microsoft docs for more information.
338
- # @example
339
- # opts = {
340
- # :save_item_to_folder => true,
341
- # :saved_item_folder_id => {:id => :sentitems},
342
- # :item_ids => [
343
- # {:item_id => {:id => 'id1'}},
344
- # {:item_id => {:id => 'id2'}},
345
- # ]}
346
- # obj.send_item(opts)
347
- def send_item(opts)
348
- opts = opts.clone
349
- [:item_ids].each do |k|
350
- validate_param(opts, k, true)
351
- end
352
-
353
- req = build_soap! do |type, builder|
354
- attribs = {}
355
- attribs['SaveItemToFolder'] = validate_param(opts, :save_item_to_folder, false, true)
356
- if(type == :header)
357
- else
358
- builder.nbuild.SendItem(attribs) {
359
- builder.nbuild.parent.default_namespace = @default_ns
360
- builder.item_ids!(opts[:item_ids])
361
- builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
328
+ # Used to send e-mail messages that are located in the Exchange store.
329
+ # @see http://msdn.microsoft.com/en-us/library/aa580238(v=exchg.140).aspx
330
+ #
331
+ # @param [Hash] opts
332
+ # @option opts [Boolean] :save_item_to_folder To save or not to save... save! :-)
333
+ # @option opts [Hash] :saved_item_folder_id A well formatted folder_id Hash. Ex: {:id => :sentitems}
334
+ # @option opts [Array<Hash>] :item_ids ItemIds Hash. The keys in these Hashes can be
335
+ # :item_id, :occurrence_item_id, or :recurring_master_item_id. Please see the
336
+ # Microsoft docs for more information.
337
+ # @example
338
+ # opts = {
339
+ # :save_item_to_folder => true,
340
+ # :saved_item_folder_id => {:id => :sentitems},
341
+ # :item_ids => [
342
+ # {:item_id => {:id => 'id1'}},
343
+ # {:item_id => {:id => 'id2'}},
344
+ # ]}
345
+ # obj.send_item(opts)
346
+ def send_item(opts)
347
+ opts = opts.clone
348
+ [:item_ids].each do |k|
349
+ validate_param(opts, k, true)
350
+ end
351
+
352
+ req = build_soap! { |type, builder|
353
+ attribs = {}
354
+ attribs['SaveItemToFolder'] = validate_param(opts, :save_item_to_folder, false, true)
355
+ unless type == :header
356
+ builder.nbuild.SendItem(attribs) {
357
+ builder.nbuild.parent.default_namespace = @default_ns
358
+ builder.item_ids!(opts[:item_ids])
359
+ builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
360
+ }
361
+ end
362
362
  }
363
+ do_soap_request(req, response_class: EwsResponse)
363
364
  end
364
- end
365
- do_soap_request(req, response_class: EwsResponse)
366
- end
367
365
 
368
- # Export items as a base64 string
369
- # @see http://msdn.microsoft.com/en-us/library/ff709503(v=exchg.140).aspx
370
- #
371
- # (Requires Exchange version equal or newer than VERSION 2010 SP 1)
372
- #
373
- # @param ids [Array] array of item ids. Can also be a single id value
374
- def export_items(ids)
375
- validate_version(VERSION_2010_SP1)
376
- ids = ids.clone
377
- [:item_ids].each do |k|
378
- validate_param(ids, k, true)
379
- end
380
- req = build_soap! do |type, builder|
381
- if(type == :header)
382
- else
383
- builder.export_item_ids!(ids[:item_ids])
366
+ # Export items as a base64 string
367
+ # @see http://msdn.microsoft.com/en-us/library/ff709503(v=exchg.140).aspx
368
+ #
369
+ # (Requires Exchange version equal or newer than VERSION 2010 SP 1)
370
+ #
371
+ # @param ids [Array] array of item ids. Can also be a single id value
372
+ def export_items(ids)
373
+ validate_version(VERSION_2010_SP1)
374
+ ids = ids.clone
375
+ [:item_ids].each do |k|
376
+ validate_param(ids, k, true)
377
+ end
378
+ req = build_soap! { |type, builder|
379
+ builder.export_item_ids!(ids[:item_ids]) unless type == :header
380
+ }
381
+ do_soap_request(req, response_class: EwsResponse)
384
382
  end
385
- end
386
- do_soap_request(req, response_class: EwsResponse)
387
- end
388
383
 
389
- # ------------- Folder Operations ------------
390
-
391
- # Creates folders, calendar folders, contacts folders, tasks folders, and search folders.
392
- # @see http://msdn.microsoft.com/en-us/library/aa563574.aspx CreateFolder
393
- #
394
- # @param [Hash] opts
395
- # @option opts [Hash] :parent_folder_id A hash with either the name of a
396
- # folder or it's numerical ID.
397
- # See: http://msdn.microsoft.com/en-us/library/aa565998.aspx
398
- # {:id => :root} or {:id => 'myfolderid#'}
399
- # @option opts [Array<Hash>] :folders An array of hashes of folder types
400
- # that conform to input for build_xml!
401
- # @example [
402
- # {:folder =>
403
- # {:display_name => "New Folder"}},
404
- # {:calendar_folder =>
405
- # {:folder_id => {:id => 'blah', :change_key => 'blah'}}}
406
- def create_folder(opts)
407
- opts = opts.clone
408
- req = build_soap! do |type, builder|
409
- if(type == :header)
410
- else
411
- builder.nbuild.CreateFolder {|x|
412
- x.parent.default_namespace = @default_ns
413
- builder.parent_folder_id!(opts[:parent_folder_id])
414
- builder.folders!(opts[:folders])
384
+ # ------------- Folder Operations ------------
385
+
386
+ # Creates folders, calendar folders, contacts folders, tasks folders, and search folders.
387
+ # @see http://msdn.microsoft.com/en-us/library/aa563574.aspx CreateFolder
388
+ #
389
+ # @param [Hash] opts
390
+ # @option opts [Hash] :parent_folder_id A hash with either the name of a
391
+ # folder or it's numerical ID.
392
+ # See: http://msdn.microsoft.com/en-us/library/aa565998.aspx
393
+ # {:id => :root} or {:id => 'myfolderid#'}
394
+ # @option opts [Array<Hash>] :folders An array of hashes of folder types
395
+ # that conform to input for build_xml!
396
+ # @example [
397
+ # {:folder =>
398
+ # {:display_name => "New Folder"}},
399
+ # {:calendar_folder =>
400
+ # {:folder_id => {:id => 'blah', :change_key => 'blah'}}}
401
+ def create_folder(opts)
402
+ opts = opts.clone
403
+ req = build_soap! { |type, builder|
404
+ unless type == :header
405
+ builder.nbuild.CreateFolder { |x|
406
+ x.parent.default_namespace = @default_ns
407
+ builder.parent_folder_id!(opts[:parent_folder_id])
408
+ builder.folders!(opts[:folders])
409
+ }
410
+ end
415
411
  }
412
+ do_soap_request(req)
416
413
  end
417
- end
418
- do_soap_request(req)
419
- end
420
414
 
421
- # Defines a request to copy folders in the Exchange store
422
- # @see http://msdn.microsoft.com/en-us/library/aa563949.aspx
423
- # @param [Hash] to_folder_id The target FolderId
424
- # {:id => <myid>, :change_key => <optional ck>}
425
- # @param [Array<Hash>] *sources The source Folders
426
- # {:id => <myid>, :change_key => <optional_ck>},
427
- # {:id => <myid2>, :change_key => <optional_ck>}
428
- def copy_folder(to_folder_id, *sources)
429
- req = build_soap! do |type, builder|
430
- if(type == :header)
431
- else
432
- builder.nbuild.CopyFolder {
433
- builder.nbuild.parent.default_namespace = @default_ns
434
- builder.to_folder_id!(to_folder_id)
435
- builder.folder_ids!(sources.flatten)
415
+ # Defines a request to copy folders in the Exchange store
416
+ # @see http://msdn.microsoft.com/en-us/library/aa563949.aspx
417
+ # @param [Hash] to_folder_id The target FolderId
418
+ # {:id => <myid>, :change_key => <optional ck>}
419
+ # @param [Array<Hash>] *sources The source Folders
420
+ # {:id => <myid>, :change_key => <optional_ck>},
421
+ # {:id => <myid2>, :change_key => <optional_ck>}
422
+ def copy_folder(to_folder_id, *sources)
423
+ req = build_soap! { |type, builder|
424
+ unless type == :header
425
+ builder.nbuild.CopyFolder {
426
+ builder.nbuild.parent.default_namespace = @default_ns
427
+ builder.to_folder_id!(to_folder_id)
428
+ builder.folder_ids!(sources.flatten)
429
+ }
430
+ end
436
431
  }
432
+ do_soap_request(req)
437
433
  end
438
- end
439
- do_soap_request(req)
440
- end
441
434
 
442
- # Deletes folders from a mailbox.
443
- # @see http://msdn.microsoft.com/en-us/library/aa564767.aspx DeleteFolder
444
- #
445
- # @param [Hash] opts
446
- # @option opts [Array<Hash>] :folder_ids An array of folder_ids in the form:
447
- # [ {:id => 'myfolderID##asdfs', :change_key => 'asdfasdf'},
448
- # {:id => :msgfolderroot} ] # Don't do this for real
449
- # @option opts [String,nil] :delete_type Type of delete to do:
450
- # HardDelete/SoftDelete/MoveToDeletedItems
451
- # @option opts [String,nil] :act_as User to act on behalf as. This user
452
- # must have been given delegate access to this folder or else this
453
- # operation will fail.
454
- def delete_folder(opts)
455
- req = build_soap! do |type, builder|
456
- if(type == :header)
457
- else
458
- builder.nbuild.DeleteFolder('DeleteType' => opts[:delete_type]) {
459
- builder.nbuild.parent.default_namespace = @default_ns
460
- builder.folder_ids!(opts[:folder_ids], opts[:act_as])
435
+ # Deletes folders from a mailbox.
436
+ # @see http://msdn.microsoft.com/en-us/library/aa564767.aspx DeleteFolder
437
+ #
438
+ # @param [Hash] opts
439
+ # @option opts [Array<Hash>] :folder_ids An array of folder_ids in the form:
440
+ # [ {:id => 'myfolderID##asdfs', :change_key => 'asdfasdf'},
441
+ # {:id => :msgfolderroot} ] # Don't do this for real
442
+ # @option opts [String,nil] :delete_type Type of delete to do:
443
+ # HardDelete/SoftDelete/MoveToDeletedItems
444
+ # @option opts [String,nil] :act_as User to act on behalf as. This user
445
+ # must have been given delegate access to this folder or else this
446
+ # operation will fail.
447
+ def delete_folder(opts)
448
+ req = build_soap! { |type, builder|
449
+ unless type == :header
450
+ builder.nbuild.DeleteFolder('DeleteType' => opts[:delete_type]) {
451
+ builder.nbuild.parent.default_namespace = @default_ns
452
+ builder.folder_ids!(opts[:folder_ids], opts[:act_as])
453
+ }
454
+ end
461
455
  }
456
+ do_soap_request(req)
462
457
  end
463
- end
464
- do_soap_request(req)
465
- end
466
-
467
- # Find subfolders of an identified folder
468
- # @see http://msdn.microsoft.com/en-us/library/aa563918.aspx
469
- #
470
- # @param [Hash] opts
471
- # @option opts [Array<Hash>] :parent_folder_ids An Array of folder id Hashes,
472
- # either a DistinguishedFolderId (must me a Symbol) or a FolderId (String)
473
- # [{:id => <myid>, :change_key => <ck>}, {:id => :root}]
474
- # @option opts [String] :traversal Shallow/Deep/SoftDeleted
475
- # @option opts [Hash] :folder_shape defines the FolderShape node
476
- # See: http://msdn.microsoft.com/en-us/library/aa494311.aspx
477
- # @option folder_shape [String] :base_shape IdOnly/Default/AllProperties
478
- # @option folder_shape :additional_properties
479
- # See: http://msdn.microsoft.com/en-us/library/aa563810.aspx
480
- # @option opts [Hash] :restriction A well formatted restriction Hash.
481
- # @example
482
- # { :parent_folder_ids => [{:id => root}],
483
- # :traversal => 'Deep',
484
- # :folder_shape => {:base_shape => 'Default'} }
485
- # @todo add FractionalPageFolderView
486
- def find_folder(opts)
487
- opts = opts.clone
488
- [:parent_folder_ids, :traversal, :folder_shape].each do |k|
489
- validate_param(opts, k, true)
490
- end
491
458
 
492
- req = build_soap! do |type, builder|
493
- if(type == :header)
494
- else
495
- builder.nbuild.FindFolder(:Traversal => camel_case(opts[:traversal])) {
496
- builder.nbuild.parent.default_namespace = @default_ns
497
- builder.folder_shape!(opts[:folder_shape])
498
- builder.restriction!(opts[:restriction]) if opts[:restriction]
499
- builder.parent_folder_ids!(opts[:parent_folder_ids])
459
+ # Find subfolders of an identified folder
460
+ # @see http://msdn.microsoft.com/en-us/library/aa563918.aspx
461
+ #
462
+ # @param [Hash] opts
463
+ # @option opts [Array<Hash>] :parent_folder_ids An Array of folder id Hashes,
464
+ # either a DistinguishedFolderId (must me a Symbol) or a FolderId (String)
465
+ # [{:id => <myid>, :change_key => <ck>}, {:id => :root}]
466
+ # @option opts [String] :traversal Shallow/Deep/SoftDeleted
467
+ # @option opts [Hash] :folder_shape defines the FolderShape node
468
+ # See: http://msdn.microsoft.com/en-us/library/aa494311.aspx
469
+ # @option folder_shape [String] :base_shape IdOnly/Default/AllProperties
470
+ # @option folder_shape :additional_properties
471
+ # See: http://msdn.microsoft.com/en-us/library/aa563810.aspx
472
+ # @option opts [Hash] :restriction A well formatted restriction Hash.
473
+ # @example
474
+ # { :parent_folder_ids => [{:id => root}],
475
+ # :traversal => 'Deep',
476
+ # :folder_shape => {:base_shape => 'Default'} }
477
+ # @todo add FractionalPageFolderView
478
+ def find_folder(opts)
479
+ opts = opts.clone
480
+ %i[parent_folder_ids traversal folder_shape].each do |k|
481
+ validate_param(opts, k, true)
482
+ end
483
+
484
+ req = build_soap! { |type, builder|
485
+ unless type == :header
486
+ builder.nbuild.FindFolder(Traversal: camel_case(opts[:traversal])) {
487
+ builder.nbuild.parent.default_namespace = @default_ns
488
+ builder.folder_shape!(opts[:folder_shape])
489
+ builder.restriction!(opts[:restriction]) if opts[:restriction]
490
+ builder.parent_folder_ids!(opts[:parent_folder_ids])
491
+ }
492
+ end
500
493
  }
494
+ do_soap_request(req)
501
495
  end
502
- end
503
- do_soap_request(req)
504
- end
505
496
 
506
- # Gets folders from the Exchange store
507
- # @see http://msdn.microsoft.com/en-us/library/aa580274.aspx
508
- #
509
- # @param [Hash] opts
510
- # @option opts [Array<Hash>] :folder_ids An array of folder_ids in the form:
511
- # [ {:id => 'myfolderID##asdfs', :change_key => 'asdfasdf'},
512
- # {:id => :msgfolderroot} ]
513
- # @option opts [Hash] :folder_shape defines the FolderShape node
514
- # @option folder_shape [String] :base_shape IdOnly/Default/AllProperties
515
- # @option folder_shape :additional_properties
516
- # @option opts [String,nil] :act_as User to act on behalf as. This user must
517
- # have been given delegate access to this folder or else this operation
518
- # will fail.
519
- # @example
520
- # { :folder_ids => [{:id => :msgfolderroot}],
521
- # :folder_shape => {:base_shape => 'Default'} }
522
- def get_folder(opts)
523
- opts = opts.clone
524
- [:folder_ids, :folder_shape].each do |k|
525
- validate_param(opts, k, true)
526
- end
527
- validate_param(opts[:folder_shape], :base_shape, true)
528
- req = build_soap! do |type, builder|
529
- if(type == :header)
530
- else
531
- builder.nbuild.GetFolder {
532
- builder.nbuild.parent.default_namespace = @default_ns
533
- builder.folder_shape!(opts[:folder_shape])
534
- builder.folder_ids!(opts[:folder_ids], opts[:act_as])
497
+ # Gets folders from the Exchange store
498
+ # @see http://msdn.microsoft.com/en-us/library/aa580274.aspx
499
+ #
500
+ # @param [Hash] opts
501
+ # @option opts [Array<Hash>] :folder_ids An array of folder_ids in the form:
502
+ # [ {:id => 'myfolderID##asdfs', :change_key => 'asdfasdf'},
503
+ # {:id => :msgfolderroot} ]
504
+ # @option opts [Hash] :folder_shape defines the FolderShape node
505
+ # @option folder_shape [String] :base_shape IdOnly/Default/AllProperties
506
+ # @option folder_shape :additional_properties
507
+ # @option opts [String,nil] :act_as User to act on behalf as. This user must
508
+ # have been given delegate access to this folder or else this operation
509
+ # will fail.
510
+ # @example
511
+ # { :folder_ids => [{:id => :msgfolderroot}],
512
+ # :folder_shape => {:base_shape => 'Default'} }
513
+ def get_folder(opts)
514
+ opts = opts.clone
515
+ %i[folder_ids folder_shape].each do |k|
516
+ validate_param(opts, k, true)
517
+ end
518
+ validate_param(opts[:folder_shape], :base_shape, true)
519
+ req = build_soap! { |type, builder|
520
+ unless type == :header
521
+ builder.nbuild.GetFolder {
522
+ builder.nbuild.parent.default_namespace = @default_ns
523
+ builder.folder_shape!(opts[:folder_shape])
524
+ builder.folder_ids!(opts[:folder_ids], opts[:act_as])
525
+ }
526
+ end
535
527
  }
528
+ do_soap_request(req)
536
529
  end
537
- end
538
- do_soap_request(req)
539
- end
540
530
 
541
- # Defines a request to move folders in the Exchange store
542
- # @see http://msdn.microsoft.com/en-us/library/aa566202.aspx
543
- # @param [Hash] to_folder_id The target FolderId
544
- # {:id => <myid>, :change_key => <optional ck>}
545
- # @param [Array<Hash>] *sources The source Folders
546
- # {:id => <myid>, :change_key => <optional_ck>},
547
- # {:id => <myid2>, :change_key => <optional_ck>}
548
- def move_folder(to_folder_id, *sources)
549
- req = build_soap! do |type, builder|
550
- if(type == :header)
551
- else
552
- builder.nbuild.MoveFolder {
553
- builder.nbuild.parent.default_namespace = @default_ns
554
- builder.to_folder_id!(to_folder_id)
555
- builder.folder_ids!(sources.flatten)
531
+ # Defines a request to move folders in the Exchange store
532
+ # @see http://msdn.microsoft.com/en-us/library/aa566202.aspx
533
+ # @param [Hash] to_folder_id The target FolderId
534
+ # {:id => <myid>, :change_key => <optional ck>}
535
+ # @param [Array<Hash>] *sources The source Folders
536
+ # {:id => <myid>, :change_key => <optional_ck>},
537
+ # {:id => <myid2>, :change_key => <optional_ck>}
538
+ def move_folder(to_folder_id, *sources)
539
+ req = build_soap! { |type, builder|
540
+ unless type == :header
541
+ builder.nbuild.MoveFolder {
542
+ builder.nbuild.parent.default_namespace = @default_ns
543
+ builder.to_folder_id!(to_folder_id)
544
+ builder.folder_ids!(sources.flatten)
545
+ }
546
+ end
556
547
  }
548
+ do_soap_request(req)
557
549
  end
558
- end
559
- do_soap_request(req)
560
- end
561
550
 
562
- # Update properties for a specified folder
563
- # There is a lot more building in this method because most of the builders
564
- # are only used for this operation so there was no need to externalize them
565
- # for re-use.
566
- # @see http://msdn.microsoft.com/en-us/library/aa580519(v=EXCHG.140).aspx
567
- # @param [Array<Hash>] folder_changes an Array of well formatted Hashes
568
- def update_folder(folder_changes)
569
- req = build_soap! do |type, builder|
570
- if(type == :header)
571
- else
572
- builder.nbuild.UpdateFolder {
573
- builder.nbuild.parent.default_namespace = @default_ns
574
- builder.nbuild.FolderChanges {
575
- folder_changes.each do |fc|
576
- builder[NS_EWS_TYPES].FolderChange {
577
- builder.dispatch_folder_id!(fc)
578
- builder[NS_EWS_TYPES].Updates {
579
- # @todo finish implementation
580
- }
551
+ # Update properties for a specified folder
552
+ # There is a lot more building in this method because most of the builders
553
+ # are only used for this operation so there was no need to externalize them
554
+ # for re-use.
555
+ # @see http://msdn.microsoft.com/en-us/library/aa580519(v=EXCHG.140).aspx
556
+ # @param [Array<Hash>] folder_changes an Array of well formatted Hashes
557
+ def update_folder(folder_changes)
558
+ req = build_soap! { |type, builder|
559
+ unless type == :header
560
+ builder.nbuild.UpdateFolder {
561
+ builder.nbuild.parent.default_namespace = @default_ns
562
+ builder.nbuild.FolderChanges {
563
+ folder_changes.each do |fc|
564
+ builder[NS_EWS_TYPES].FolderChange {
565
+ builder.dispatch_folder_id!(fc)
566
+ builder[NS_EWS_TYPES].Updates {
567
+ # @todo finish implementation
568
+ }
569
+ }
570
+ end
581
571
  }
582
- end
583
- }
572
+ }
573
+ end
584
574
  }
575
+ do_soap_request(req)
585
576
  end
586
- end
587
- do_soap_request(req)
588
- end
589
577
 
590
- # Empties folders in a mailbox.
591
- # @see http://msdn.microsoft.com/en-us/library/ff709484.aspx
592
- # @param [Hash] opts
593
- # @option opts [String] :delete_type Must be one of
594
- # ExchangeDataServices::HARD_DELETE, SOFT_DELETE, or MOVE_TO_DELETED_ITEMS
595
- # @option opts [Boolean] :delete_sub_folders
596
- # @option opts [Array<Hash>] :folder_ids An array of folder_ids in the form:
597
- # [ {:id => 'myfolderID##asdfs', :change_key => 'asdfasdf'},
598
- # {:id => 'blah'} ]
599
- # @todo Finish
600
- def empty_folder(opts)
601
- validate_version(VERSION_2010_SP1)
602
- ef_opts = {}
603
- [:delete_type, :delete_sub_folders].each do |k|
604
- ef_opts[camel_case(k)] = validate_param(opts, k, true)
605
- end
606
- fids = validate_param opts, :folder_ids, true
607
-
608
- req = build_soap! do |type, builder|
609
- if(type == :header)
610
- else
611
- builder.nbuild.EmptyFolder(ef_opts) {|x|
612
- builder.nbuild.parent.default_namespace = @default_ns
613
- builder.folder_ids!(fids)
578
+ # Empties folders in a mailbox.
579
+ # @see http://msdn.microsoft.com/en-us/library/ff709484.aspx
580
+ # @param [Hash] opts
581
+ # @option opts [String] :delete_type Must be one of
582
+ # ExchangeDataServices::HARD_DELETE, SOFT_DELETE, or MOVE_TO_DELETED_ITEMS
583
+ # @option opts [Boolean] :delete_sub_folders
584
+ # @option opts [Array<Hash>] :folder_ids An array of folder_ids in the form:
585
+ # [ {:id => 'myfolderID##asdfs', :change_key => 'asdfasdf'},
586
+ # {:id => 'blah'} ]
587
+ # @todo Finish
588
+ def empty_folder(opts)
589
+ validate_version(VERSION_2010_SP1)
590
+ ef_opts = {}
591
+ %i[delete_type delete_sub_folders].each do |k|
592
+ ef_opts[camel_case(k)] = validate_param(opts, k, true)
593
+ end
594
+ fids = validate_param opts, :folder_ids, true
595
+
596
+ req = build_soap! { |type, builder|
597
+ unless type == :header
598
+ builder.nbuild.EmptyFolder(ef_opts) { |_x|
599
+ builder.nbuild.parent.default_namespace = @default_ns
600
+ builder.folder_ids!(fids)
601
+ }
602
+ end
614
603
  }
604
+ do_soap_request(req)
615
605
  end
616
- end
617
- do_soap_request(req)
618
- end
619
606
 
620
- # ----------- Attachment Operations ----------
621
-
622
- # Used to retrieve existing attachments on items in the Exchange store
623
- # @see http://msdn.microsoft.com/en-us/library/aa494316.aspx
624
- # @param [Hash] opts
625
- # @option opts [Array] :attachment_ids Attachment Ids to fetch
626
- # @option opts [Hash] :attachment_shape Attachment shape
627
- # include_mime_content: true or false (optional)
628
- # body_type: "Best" | "HTML" | "Text" (optional)
629
- # filter_html_content: true or false (optional)
630
- # additional_properties: @todo finish implementation
631
- def get_attachment(opts)
632
- opts = opts.clone
633
- [:attachment_ids].each do |k|
634
- validate_param(opts, k, true)
635
- end
636
- req = build_soap! do |type, builder|
637
- if(type == :header)
638
- else
639
- builder.nbuild.GetAttachment {|x|
640
- builder.nbuild.parent.default_namespace = @default_ns
641
- builder.attachment_ids!(opts[:attachment_ids])
607
+ # ----------- Attachment Operations ----------
608
+
609
+ # Used to retrieve existing attachments on items in the Exchange store
610
+ # @see http://msdn.microsoft.com/en-us/library/aa494316.aspx
611
+ # @param [Hash] opts
612
+ # @option opts [Array] :attachment_ids Attachment Ids to fetch
613
+ # @option opts [Hash] :attachment_shape Attachment shape
614
+ # include_mime_content: true or false (optional)
615
+ # body_type: "Best" | "HTML" | "Text" (optional)
616
+ # filter_html_content: true or false (optional)
617
+ # additional_properties: @todo finish implementation
618
+ def get_attachment(opts)
619
+ opts = opts.clone
620
+ [:attachment_ids].each do |k|
621
+ validate_param(opts, k, true)
622
+ end
623
+ req = build_soap! { |type, builder|
624
+ unless type == :header
625
+ builder.nbuild.GetAttachment { |_x|
626
+ builder.nbuild.parent.default_namespace = @default_ns
627
+ builder.attachment_ids!(opts[:attachment_ids])
628
+ }
629
+ end
642
630
  }
631
+ do_soap_request(req)
643
632
  end
644
- end
645
- do_soap_request(req)
646
- end
647
633
 
648
- # Creates either an item or file attachment and attaches it to the specified item.
649
- # @see http://msdn.microsoft.com/en-us/library/aa565877.aspx
650
- # @param [Hash] opts
651
- # @option opts [Hash] :parent_id {id: <id>, change_key: <ck>}
652
- # @option opts [Array<Hash>] :files An Array of Base64 encoded Strings with
653
- # an associated name:
654
- # {:name => <name>, :content => <Base64 encoded string>}
655
- # @option opts [Array] :items Exchange Items to attach to this Item
656
- # @todo Need to implement attachment of Item types
657
- def create_attachment(opts)
658
- opts = opts.clone
659
- [:parent_id].each do |k|
660
- validate_param(opts, k, true)
661
- end
662
- validate_param(opts, :files, false, [])
663
- validate_param(opts, :items, false, [])
664
-
665
- req = build_soap! do |type, builder|
666
- if(type == :header)
667
- else
668
- builder.nbuild.CreateAttachment {|x|
669
- builder.nbuild.parent.default_namespace = @default_ns
670
- builder.parent_item_id!(opts[:parent_id])
671
- x.Attachments {
672
- opts[:files].each do |fa|
673
- builder.file_attachment!(fa)
674
- end
675
- opts[:items].each do |ia|
676
- builder.item_attachment!(ia)
677
- end
678
- opts[:inline_files].each do |fi|
679
- builder.inline_attachment!(fi)
680
- end
681
- }
634
+ # Creates either an item or file attachment and attaches it to the specified item.
635
+ # @see http://msdn.microsoft.com/en-us/library/aa565877.aspx
636
+ # @param [Hash] opts
637
+ # @option opts [Hash] :parent_id {id: <id>, change_key: <ck>}
638
+ # @option opts [Array<Hash>] :files An Array of Base64 encoded Strings with
639
+ # an associated name:
640
+ # {:name => <name>, :content => <Base64 encoded string>}
641
+ # @option opts [Array] :items Exchange Items to attach to this Item
642
+ # @todo Need to implement attachment of Item types
643
+ def create_attachment(opts)
644
+ opts = opts.clone
645
+ [:parent_id].each do |k|
646
+ validate_param(opts, k, true)
647
+ end
648
+ validate_param(opts, :files, false, [])
649
+ validate_param(opts, :items, false, [])
650
+
651
+ req = build_soap! { |type, builder|
652
+ unless type == :header
653
+ builder.nbuild.CreateAttachment { |x|
654
+ builder.nbuild.parent.default_namespace = @default_ns
655
+ builder.parent_item_id!(opts[:parent_id])
656
+ x.Attachments {
657
+ opts[:files].each do |fa|
658
+ builder.file_attachment!(fa)
659
+ end
660
+ opts[:items].each do |ia|
661
+ builder.item_attachment!(ia)
662
+ end
663
+ opts[:inline_files].each do |fi|
664
+ builder.inline_attachment!(fi)
665
+ end
666
+ }
667
+ }
668
+ end
682
669
  }
670
+ do_soap_request(req, response_class: EwsResponse)
683
671
  end
684
- end
685
- do_soap_request(req, response_class: EwsResponse)
686
- end
687
-
688
672
 
689
- # ------------ Utility Operations ------------
690
-
691
- # Exposes the full membership of distribution lists.
692
- # @see http://msdn.microsoft.com/en-us/library/aa494152.aspx ExpandDL
693
- #
694
- # @todo Fully support all of the ExpandDL operations. Today it just supports
695
- # taking an e-mail address as an argument
696
- # @param [Hash] opts
697
- # @option opts [String] :email_address The e-mail address of the
698
- # distribution to resolve
699
- # @option opts [Hash] :item_id The ItemId of the private distribution to resolve.
700
- # {:id => 'my id'}
701
- def expand_dl(opts)
702
- opts = opts.clone
703
- req = build_soap! do |type, builder|
704
- if(type == :header)
705
- else
706
- builder.nbuild.ExpandDL {|x|
707
- x.parent.default_namespace = @default_ns
708
- x.Mailbox {|mb|
709
- key = :email_address
710
- mb[NS_EWS_TYPES].EmailAddress(opts[key]) if opts[key]
711
- builder.item_id! if opts[:item_id]
673
+ # ------------ Utility Operations ------------
674
+
675
+ # Exposes the full membership of distribution lists.
676
+ # @see http://msdn.microsoft.com/en-us/library/aa494152.aspx ExpandDL
677
+ #
678
+ # @todo Fully support all of the ExpandDL operations. Today it just supports
679
+ # taking an e-mail address as an argument
680
+ # @param [Hash] opts
681
+ # @option opts [String] :email_address The e-mail address of the
682
+ # distribution to resolve
683
+ # @option opts [Hash] :item_id The ItemId of the private distribution to resolve.
684
+ # {:id => 'my id'}
685
+ def expand_dl(opts)
686
+ opts = opts.clone
687
+ req = build_soap! { |type, builder|
688
+ unless type == :header
689
+ builder.nbuild.ExpandDL { |x|
690
+ x.parent.default_namespace = @default_ns
691
+ x.Mailbox { |mb|
692
+ key = :email_address
693
+ mb[NS_EWS_TYPES].EmailAddress(opts[key]) if opts[key]
694
+ builder.item_id! if opts[:item_id]
695
+ }
696
+ }
697
+ end
712
698
  }
713
- }
699
+ do_soap_request(req)
714
700
  end
715
- end
716
- do_soap_request(req)
717
- end
718
701
 
719
- # Resolve ambiguous e-mail addresses and display names
720
- # @see http://msdn.microsoft.com/en-us/library/aa565329.aspx ResolveNames
721
- # @see http://msdn.microsoft.com/en-us/library/aa581054.aspx UnresolvedEntry
722
- # @param [Hash] opts
723
- # @option opts [String] :name the unresolved entry
724
- # @option opts [Boolean] :full_contact_data (true) Whether or not to return
725
- # the full contact details.
726
- # @option opts [String] :search_scope where to seach for this entry, one of
727
- # SOAP::Contacts, SOAP::ActiveDirectory, SOAP::ActiveDirectoryContacts
728
- # (default), SOAP::ContactsActiveDirectory
729
- # @option opts [String, FolderId] :parent_folder_id either the name of a
730
- # folder or it's numerical ID.
731
- # @see http://msdn.microsoft.com/en-us/library/aa565998.aspx
732
- def resolve_names(opts)
733
- opts = opts.clone
734
- fcd = opts.has_key?(:full_contact_data) ? opts[:full_contact_data] : true
735
- req = build_soap! do |type, builder|
736
- if(type == :header)
737
- else
738
- builder.nbuild.ResolveNames {|x|
739
- x.parent['ReturnFullContactData'] = fcd.to_s
740
- x.parent['SearchScope'] = opts[:search_scope] if opts[:search_scope]
741
- x.parent.default_namespace = @default_ns
742
- # @todo builder.nbuild.ParentFolderIds
743
- x.UnresolvedEntry(opts[:name])
744
- }
702
+ # Resolve ambiguous e-mail addresses and display names
703
+ # @see http://msdn.microsoft.com/en-us/library/aa565329.aspx ResolveNames
704
+ # @see http://msdn.microsoft.com/en-us/library/aa581054.aspx UnresolvedEntry
705
+ # @param [Hash] opts
706
+ # @option opts [String] :name the unresolved entry
707
+ # @option opts [Boolean] :full_contact_data (true) Whether or not to return
708
+ # the full contact details.
709
+ # @option opts [String] :search_scope where to seach for this entry, one of
710
+ # SOAP::Contacts, SOAP::ActiveDirectory, SOAP::ActiveDirectoryContacts
711
+ # (default), SOAP::ContactsActiveDirectory
712
+ # @option opts [String, FolderId] :parent_folder_id either the name of a
713
+ # folder or it's numerical ID.
714
+ # @see http://msdn.microsoft.com/en-us/library/aa565998.aspx
715
+ def resolve_names(opts)
716
+ opts = opts.clone
717
+ fcd = opts.key?(:full_contact_data) ? opts[:full_contact_data] : true
718
+ req = build_soap! { |type, builder|
719
+ unless type == :header
720
+ builder.nbuild.ResolveNames { |x|
721
+ x.parent['ReturnFullContactData'] = fcd.to_s
722
+ x.parent['SearchScope'] = opts[:search_scope] if opts[:search_scope]
723
+ x.parent.default_namespace = @default_ns
724
+ # @todo builder.nbuild.ParentFolderIds
725
+ x.UnresolvedEntry(opts[:name])
726
+ }
727
+ end
728
+ }
729
+ do_soap_request(req)
745
730
  end
746
- end
747
- do_soap_request(req)
748
- end
749
-
750
- # Converts item and folder identifiers between formats.
751
- # @see http://msdn.microsoft.com/en-us/library/bb799665.aspx
752
- # @todo Needs to be finished
753
- def convert_id(opts)
754
- opts = opts.clone
755
731
 
756
- [:id, :format, :destination_format, :mailbox ].each do |k|
757
- validate_param(opts, k, true)
758
- end
759
-
760
- req = build_soap! do |type, builder|
761
- if(type == :header)
762
- else
763
- builder.nbuild.ConvertId {|x|
764
- builder.nbuild.parent.default_namespace = @default_ns
765
- x.parent['DestinationFormat'] = opts[:destination_format].to_s.camel_case
766
- x.SourceIds { |x|
767
- x[NS_EWS_TYPES].AlternateId { |x|
768
- x.parent['Format'] = opts[:format].to_s.camel_case
769
- x.parent['Id'] = opts[:id]
770
- x.parent['Mailbox'] = opts[:mailbox]
732
+ # Converts item and folder identifiers between formats.
733
+ # @see http://msdn.microsoft.com/en-us/library/bb799665.aspx
734
+ # @todo Needs to be finished
735
+ def convert_id(opts)
736
+ opts = opts.clone
737
+
738
+ %i[id format destination_format mailbox].each do |k|
739
+ validate_param(opts, k, true)
740
+ end
741
+
742
+ req = build_soap! { |type, builder|
743
+ unless type == :header
744
+ builder.nbuild.ConvertId { |x|
745
+ builder.nbuild.parent.default_namespace = @default_ns
746
+ x.parent['DestinationFormat'] = opts[:destination_format].to_s.camel_case
747
+ x.SourceIds { |x|
748
+ x[NS_EWS_TYPES].AlternateId { |x|
749
+ x.parent['Format'] = opts[:format].to_s.camel_case
750
+ x.parent['Id'] = opts[:id]
751
+ x.parent['Mailbox'] = opts[:mailbox]
752
+ }
753
+ }
771
754
  }
772
- }
755
+ end
773
756
  }
757
+ do_soap_request(req, response_class: EwsResponse)
774
758
  end
775
759
  end
776
- do_soap_request(req, response_class: EwsResponse)
777
760
  end
778
-
779
- end #ExchangeDataServices
761
+ end
780
762
  end