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,264 +1,268 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
1
+ # frozen_string_literal: true
3
2
 
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
3
+ # This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
4
+ #
5
+ # Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
5
18
 
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
19
+ module Viewpoint
20
+ module EWS
21
+ module SOAP
22
+ # Low-level SOAP web service interface to Exchange.
23
+ class ExchangeWebService
24
+ include Viewpoint::EWS
25
+ include Viewpoint::EWS::SOAP
26
+ include Viewpoint::StringUtils
27
+ include ExchangeDataServices
28
+ include ExchangeNotification
29
+ include ExchangeAvailability
30
+ include ExchangeUserConfiguration
31
+ include ExchangeSynchronization
32
+ include ExchangeTimeZones
9
33
 
10
- http://www.apache.org/licenses/LICENSE-2.0
34
+ attr_accessor :server_version, :auto_deepen, :no_auto_deepen_behavior, :connection, :impersonation_type,
35
+ :impersonation_address
11
36
 
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
-
19
- module Viewpoint::EWS::SOAP
20
- class ExchangeWebService
21
- include Viewpoint::EWS
22
- include Viewpoint::EWS::SOAP
23
- include Viewpoint::StringUtils
24
- include ExchangeDataServices
25
- include ExchangeNotification
26
- include ExchangeAvailability
27
- include ExchangeUserConfiguration
28
- include ExchangeSynchronization
29
- include ExchangeTimeZones
30
-
31
- attr_accessor :server_version, :auto_deepen, :no_auto_deepen_behavior, :connection, :impersonation_type, :impersonation_address
32
-
33
- # @param [Viewpoint::EWS::Connection] connection the connection object
34
- # @param [Hash] opts additional options to the web service
35
- # @option opts [String] :server_version what version to target with the
36
- # requests. Must be one of the contants VERSION_2007, VERSION_2007_SP1,
37
- # VERSION_2010, VERSION_2010_SP1, VERSION_2010_SP2, or VERSION_NONE. The
38
- # default is VERSION_2010.
39
- def initialize(connection, opts = {})
40
- super()
41
- @connection = connection
42
- @server_version = opts[:server_version] ? opts[:server_version] : VERSION_2010
43
- @auto_deepen = true
44
- @no_auto_deepen_behavior = :raise
45
- @impersonation_type = ""
46
- @impersonation_address = ""
47
- end
37
+ # @param [Viewpoint::EWS::Connection] connection the connection object
38
+ # @param [Hash] opts additional options to the web service
39
+ # @option opts [String] :server_version what version to target with the
40
+ # requests. Must be one of the contants VERSION_2007, VERSION_2007_SP1,
41
+ # VERSION_2010, VERSION_2010_SP1, VERSION_2010_SP2, or VERSION_NONE. The
42
+ # default is VERSION_2010.
43
+ def initialize(connection, opts = {})
44
+ super()
45
+ @connection = connection
46
+ @server_version = opts[:server_version] || VERSION_2010
47
+ @auto_deepen = true
48
+ @no_auto_deepen_behavior = :raise
49
+ @impersonation_type = ''
50
+ @impersonation_address = ''
51
+ end
48
52
 
49
- def delete_attachment
50
- action = "#{SOAP_ACTION_PREFIX}/DeleteAttachment"
51
- resp = invoke("#{NS_EWS_MESSAGES}:DeleteAttachment", action) do |delete_attachment|
52
- build_delete_attachment!(delete_attachment)
53
- end
54
- parse_delete_attachment(resp)
55
- end
53
+ def delete_attachment
54
+ action = "#{SOAP_ACTION_PREFIX}/DeleteAttachment"
55
+ resp = invoke("#{NS_EWS_MESSAGES}:DeleteAttachment", action) { |delete_attachment|
56
+ build_delete_attachment!(delete_attachment)
57
+ }
58
+ parse_delete_attachment(resp)
59
+ end
56
60
 
57
- def create_managed_folder
58
- action = "#{SOAP_ACTION_PREFIX}/CreateManagedFolder"
59
- resp = invoke("#{NS_EWS_MESSAGES}:CreateManagedFolder", action) do |create_managed_folder|
60
- build_create_managed_folder!(create_managed_folder)
61
- end
62
- parse_create_managed_folder(resp)
63
- end
61
+ def create_managed_folder
62
+ action = "#{SOAP_ACTION_PREFIX}/CreateManagedFolder"
63
+ resp = invoke("#{NS_EWS_MESSAGES}:CreateManagedFolder", action) { |create_managed_folder|
64
+ build_create_managed_folder!(create_managed_folder)
65
+ }
66
+ parse_create_managed_folder(resp)
67
+ end
64
68
 
65
- # Retrieves the delegate settings for a specific mailbox.
66
- # @see http://msdn.microsoft.com/en-us/library/bb799735.aspx
67
- #
68
- # @param [String] owner The user that is delegating permissions
69
- def get_delegate(owner)
70
- action = "#{SOAP_ACTION_PREFIX}/GetDelegate"
71
- resp = invoke("#{NS_EWS_MESSAGES}:GetDelegate", action) do |root|
72
- root.set_attr('IncludePermissions', 'true')
73
- build!(root) do
74
- mailbox!(root, {:email_address => {:text => owner}})
69
+ # Retrieves the delegate settings for a specific mailbox.
70
+ # @see http://msdn.microsoft.com/en-us/library/bb799735.aspx
71
+ #
72
+ # @param [String] owner The user that is delegating permissions
73
+ def get_delegate(owner)
74
+ action = "#{SOAP_ACTION_PREFIX}/GetDelegate"
75
+ resp = invoke("#{NS_EWS_MESSAGES}:GetDelegate", action) { |root|
76
+ root.set_attr('IncludePermissions', 'true')
77
+ build!(root) do
78
+ mailbox!(root, { email_address: { text: owner } })
79
+ end
80
+ }
81
+ parse_soap_response(resp)
75
82
  end
76
- end
77
- parse_soap_response(resp)
78
- end
79
83
 
80
- # Adds one or more delegates to a principal's mailbox and sets specific access permissions.
81
- # @see http://msdn.microsoft.com/en-us/library/bb856527.aspx
82
- #
83
- # @param [String] owner The user that is delegating permissions
84
- # @param [String] delegate The user that is being given delegate permission
85
- # @param [Hash] permissions A hash of permissions that will be delegated.
86
- # This Hash will eventually be passed to add_hierarchy! in the builder so it is in that format.
87
- def add_delegate(owner, delegate, permissions)
88
- action = "#{SOAP_ACTION_PREFIX}/AddDelegate"
89
- resp = invoke("#{NS_EWS_MESSAGES}:AddDelegate", action) do |root|
90
- build!(root) do
91
- add_delegate!(owner, delegate, permissions)
84
+ # Adds one or more delegates to a principal's mailbox and sets specific access permissions.
85
+ # @see http://msdn.microsoft.com/en-us/library/bb856527.aspx
86
+ #
87
+ # @param [String] owner The user that is delegating permissions
88
+ # @param [String] delegate The user that is being given delegate permission
89
+ # @param [Hash] permissions A hash of permissions that will be delegated.
90
+ # This Hash will eventually be passed to add_hierarchy! in the builder so it is in that format.
91
+ def add_delegate(owner, delegate, permissions)
92
+ action = "#{SOAP_ACTION_PREFIX}/AddDelegate"
93
+ resp = invoke("#{NS_EWS_MESSAGES}:AddDelegate", action) { |root|
94
+ build!(root) do
95
+ add_delegate!(owner, delegate, permissions)
96
+ end
97
+ }
98
+ parse_soap_response(resp)
92
99
  end
93
- end
94
- parse_soap_response(resp)
95
- end
96
100
 
97
- # Removes one or more delegates from a user's mailbox.
98
- # @see http://msdn.microsoft.com/en-us/library/bb856564.aspx
99
- #
100
- # @param [String] owner The user that is delegating permissions
101
- # @param [String] delegate The user that is being given delegate permission
102
- def remove_delegate(owner, delegate)
103
- action = "#{SOAP_ACTION_PREFIX}/RemoveDelegate"
104
- resp = invoke("#{NS_EWS_MESSAGES}:RemoveDelegate", action) do |root|
105
- build!(root) do
106
- remove_delegate!(owner, delegate)
101
+ # Removes one or more delegates from a user's mailbox.
102
+ # @see http://msdn.microsoft.com/en-us/library/bb856564.aspx
103
+ #
104
+ # @param [String] owner The user that is delegating permissions
105
+ # @param [String] delegate The user that is being given delegate permission
106
+ def remove_delegate(owner, delegate)
107
+ action = "#{SOAP_ACTION_PREFIX}/RemoveDelegate"
108
+ resp = invoke("#{NS_EWS_MESSAGES}:RemoveDelegate", action) { |root|
109
+ build!(root) do
110
+ remove_delegate!(owner, delegate)
111
+ end
112
+ }
113
+ parse_soap_response(resp)
107
114
  end
108
- end
109
- parse_soap_response(resp)
110
- end
111
115
 
112
- # Updates delegate permissions on a principal's mailbox
113
- # @see http://msdn.microsoft.com/en-us/library/bb856529.aspx
114
- #
115
- # @param [String] owner The user that is delegating permissions
116
- # @param [String] delegate The user that is being given delegate permission
117
- # @param [Hash] permissions A hash of permissions that will be delegated.
118
- # This Hash will eventually be passed to add_hierarchy! in the builder so it is in that format.
119
- def update_delegate(owner, delegate, permissions)
120
- action = "#{SOAP_ACTION_PREFIX}/UpdateDelegate"
121
- resp = invoke("#{NS_EWS_MESSAGES}:UpdateDelegate", action) do |root|
122
- build!(root) do
123
- add_delegate!(owner, delegate, permissions)
116
+ # Updates delegate permissions on a principal's mailbox
117
+ # @see http://msdn.microsoft.com/en-us/library/bb856529.aspx
118
+ #
119
+ # @param [String] owner The user that is delegating permissions
120
+ # @param [String] delegate The user that is being given delegate permission
121
+ # @param [Hash] permissions A hash of permissions that will be delegated.
122
+ # This Hash will eventually be passed to add_hierarchy! in the builder so it is in that format.
123
+ def update_delegate(owner, delegate, permissions)
124
+ action = "#{SOAP_ACTION_PREFIX}/UpdateDelegate"
125
+ resp = invoke("#{NS_EWS_MESSAGES}:UpdateDelegate", action) { |root|
126
+ build!(root) do
127
+ add_delegate!(owner, delegate, permissions)
128
+ end
129
+ }
130
+ parse_soap_response(resp)
124
131
  end
125
- end
126
- parse_soap_response(resp)
127
- end
128
132
 
129
- # Provides detailed information about the availability of a set of users, rooms, and resources
130
- # within a specified time window.
131
- # @see http://msdn.microsoft.com/en-us/library/aa564001.aspx
132
- # @param [Hash] opts
133
- # @option opts [Hash] :time_zone The TimeZone data
134
- # Example: {:bias => 'UTC offset in minutes',
135
- # :standard_time => {:bias => 480, :time => '02:00:00',
136
- # :day_order => 5, :month => 10, :day_of_week => 'Sunday'},
137
- # :daylight_time => {same options as :standard_time}}
138
- # @option opts [Array<Hash>] :mailbox_data Data for the mailbox to query
139
- # Example: [{:attendee_type => 'Organizer|Required|Optional|Room|Resource',
140
- # :email =>{:name => 'name', :address => 'email', :routing_type => 'SMTP'},
141
- # :exclude_conflicts => true|false }]
142
- # @option opts [Hash] :free_busy_view_options
143
- # Example: {:time_window => {:start_time => DateTime,:end_time => DateTime},
144
- # :merged_free_busy_interval_in_minutes => minute_int,
145
- # :requested_view => None|MergedOnly|FreeBusy|FreeBusyMerged|Detailed
146
- # |DetailedMerged} (optional)
147
- # @option opts [Hash] :suggestions_view_options (optional)
148
- # @todo Finish out :suggestions_view_options
149
- def get_user_availability(opts)
150
- opts = opts.clone
151
- req = build_soap! do |type, builder|
152
- if(type == :header)
153
- else
154
- builder.nbuild.GetUserAvailabilityRequest {|x|
155
- x.parent.default_namespace = @default_ns
156
- builder.time_zone!(opts[:time_zone])
157
- builder.nbuild.MailboxDataArray {
158
- opts[:mailbox_data].each do |mbd|
159
- builder.mailbox_data!(mbd)
160
- end
133
+ # Provides detailed information about the availability of a set of users, rooms, and resources
134
+ # within a specified time window.
135
+ # @see http://msdn.microsoft.com/en-us/library/aa564001.aspx
136
+ # @param [Hash] opts
137
+ # @option opts [Hash] :time_zone The TimeZone data
138
+ # Example: {:bias => 'UTC offset in minutes',
139
+ # :standard_time => {:bias => 480, :time => '02:00:00',
140
+ # :day_order => 5, :month => 10, :day_of_week => 'Sunday'},
141
+ # :daylight_time => {same options as :standard_time}}
142
+ # @option opts [Array<Hash>] :mailbox_data Data for the mailbox to query
143
+ # Example: [{:attendee_type => 'Organizer|Required|Optional|Room|Resource',
144
+ # :email =>{:name => 'name', :address => 'email', :routing_type => 'SMTP'},
145
+ # :exclude_conflicts => true|false }]
146
+ # @option opts [Hash] :free_busy_view_options
147
+ # Example: {:time_window => {:start_time => DateTime,:end_time => DateTime},
148
+ # :merged_free_busy_interval_in_minutes => minute_int,
149
+ # :requested_view => None|MergedOnly|FreeBusy|FreeBusyMerged|Detailed
150
+ # |DetailedMerged} (optional)
151
+ # @option opts [Hash] :suggestions_view_options (optional)
152
+ # @todo Finish out :suggestions_view_options
153
+ def get_user_availability(opts)
154
+ opts = opts.clone
155
+ req = build_soap! { |type, builder|
156
+ unless type == :header
157
+ builder.nbuild.GetUserAvailabilityRequest { |x|
158
+ x.parent.default_namespace = @default_ns
159
+ builder.time_zone!(opts[:time_zone])
160
+ builder.nbuild.MailboxDataArray do
161
+ opts[:mailbox_data].each do |mbd|
162
+ builder.mailbox_data!(mbd)
163
+ end
164
+ end
165
+ builder.free_busy_view_options!(opts[:free_busy_view_options])
166
+ builder.suggestions_view_options!(opts[:suggestions_view_options])
167
+ }
168
+ end
161
169
  }
162
- builder.free_busy_view_options!(opts[:free_busy_view_options])
163
- builder.suggestions_view_options!(opts[:suggestions_view_options])
164
- }
170
+
171
+ do_soap_request(req, response_class: EwsSoapFreeBusyResponse)
165
172
  end
166
- end
167
173
 
168
- do_soap_request(req, response_class: EwsSoapFreeBusyResponse)
169
- end
174
+ # Gets the rooms that are in the specified room distribution list
175
+ # @see http://msdn.microsoft.com/en-us/library/aa563465.aspx
176
+ # @param [string] room_distribution_list
177
+ def get_rooms(room_distribution_list)
178
+ req = build_soap! { |type, builder|
179
+ unless type == :header
180
+ builder.nbuild.GetRooms { |x|
181
+ x.parent.default_namespace = @default_ns
182
+ builder.room_list!(room_distribution_list)
183
+ }
184
+ end
185
+ }
186
+ do_soap_request(req, response_class: EwsSoapRoomResponse)
187
+ end
170
188
 
171
- # Gets the rooms that are in the specified room distribution list
172
- # @see http://msdn.microsoft.com/en-us/library/aa563465.aspx
173
- # @param [string] roomDistributionList
174
- def get_rooms(roomDistributionList)
175
- req = build_soap! do |type, builder|
176
- if(type == :header)
177
- else
178
- builder.nbuild.GetRooms {|x|
179
- x.parent.default_namespace = @default_ns
180
- builder.room_list!(roomDistributionList)
189
+ # Gets the room lists that are available within the Exchange organization.
190
+ # @see http://msdn.microsoft.com/en-us/library/aa563465.aspx
191
+ def get_room_lists # rubocop:disable Naming/AccessorMethodName -- public API name
192
+ req = build_soap! { |type, builder|
193
+ builder.room_lists! unless type == :header
181
194
  }
195
+ do_soap_request(req, response_class: EwsSoapRoomlistResponse)
182
196
  end
183
- end
184
- do_soap_request(req, response_class: EwsSoapRoomResponse)
185
- end
186
197
 
187
- # Gets the room lists that are available within the Exchange organization.
188
- # @see http://msdn.microsoft.com/en-us/library/aa563465.aspx
189
- def get_room_lists
190
- req = build_soap! do |type, builder|
191
- if(type == :header)
192
- else
193
- builder.room_lists!
198
+ # Send the SOAP request to the endpoint and parse it.
199
+ # @param [String] soapmsg an XML formatted string
200
+ # @todo make this work for Viewpoint (imported from SPWS)
201
+ # @param [Hash] opts misc options
202
+ # @option opts [Boolean] :raw_response if true do not parse and return
203
+ # the raw response string.
204
+ def do_soap_request(soapmsg, opts = {})
205
+ @log.debug <<~LOG
206
+ Sending SOAP Request:
207
+ ----------------
208
+ #{soapmsg}
209
+ ----------------
210
+ LOG
211
+ connection.dispatch(self, soapmsg, opts)
194
212
  end
195
- end
196
- do_soap_request(req, response_class: EwsSoapRoomlistResponse)
197
- end
198
213
 
199
- # Send the SOAP request to the endpoint and parse it.
200
- # @param [String] soapmsg an XML formatted string
201
- # @todo make this work for Viewpoint (imported from SPWS)
202
- # @param [Hash] opts misc options
203
- # @option opts [Boolean] :raw_response if true do not parse and return
204
- # the raw response string.
205
- def do_soap_request(soapmsg, opts = {})
206
- @log.debug <<-EOF.gsub(/^ {8}/, '')
207
- Sending SOAP Request:
208
- ----------------
209
- #{soapmsg}
210
- ----------------
211
- EOF
212
- connection.dispatch(self, soapmsg, opts)
213
- end
214
+ # @param [String] response the SOAP response string
215
+ # @param [Hash] opts misc options to send to the parser
216
+ # @option opts [Class] :response_class the response class
217
+ def parse_soap_response(soapmsg, opts = {})
218
+ raise EwsError, "Can't parse an empty response. Please check your endpoint." if soapmsg.nil?
214
219
 
215
- # @param [String] response the SOAP response string
216
- # @param [Hash] opts misc options to send to the parser
217
- # @option opts [Class] :response_class the response class
218
- def parse_soap_response(soapmsg, opts = {})
219
- raise EwsError, "Can't parse an empty response. Please check your endpoint." if(soapmsg.nil?)
220
- opts[:response_class] ||= EwsSoapResponse
221
- EwsParser.new(soapmsg).parse(opts)
222
- end
220
+ opts[:response_class] ||= EwsSoapResponse
221
+ EwsParser.new(soapmsg).parse(opts)
222
+ end
223
223
 
224
+ private
224
225
 
225
- private
226
- # Private Methods (Builders and Parsers)
226
+ # Private Methods (Builders and Parsers)
227
227
 
228
- # Validate or set default values for options parameters.
229
- # @param [Hash] opts The options parameter passed to an EWS operation
230
- # @param [Symbol] key The key in the Hash we are validating
231
- # @param [Boolean] required Whether or not this key is required
232
- # @param [Object] default_val If the key is not required use this as a
233
- # default value for the operation.
234
- def validate_param(opts, key, required, default_val = nil)
235
- if required
236
- raise EwsBadArgumentError, "Required parameter(#{key}) not passed." unless opts.has_key?(key)
237
- opts[key]
238
- else
239
- raise EwsBadArgumentError, "Default value not supplied." unless default_val
240
- opts.has_key?(key) ? opts[key] : default_val
241
- end
242
- end
228
+ # Validate or set default values for options parameters.
229
+ # @param [Hash] opts The options parameter passed to an EWS operation
230
+ # @param [Symbol] key The key in the Hash we are validating
231
+ # @param [Boolean] required Whether or not this key is required
232
+ # @param [Object] default_val If the key is not required use this as a
233
+ # default value for the operation.
234
+ def validate_param(opts, key, required, default_val = nil)
235
+ if required
236
+ raise EwsBadArgumentError, "Required parameter(#{key}) not passed." unless opts.key?(key)
243
237
 
244
- # Some operations only exist for certain versions of Exchange Server.
245
- # This method should be called with the required version and we'll throw
246
- # an exception of the currently set @server_version does not comply.
247
- def validate_version(exchange_version)
248
- if server_version < exchange_version
249
- msg = 'The operation you are attempting to use is not compatible with'
250
- msg << " your configured Exchange Server version(#{server_version})."
251
- msg << " You must be running at least version (#{exchange_version})."
252
- raise EwsServerVersionError, msg
253
- end
254
- end
238
+ opts[key]
239
+ else
240
+ raise EwsBadArgumentError, 'Default value not supplied.' unless default_val
255
241
 
256
- # Build the common elements in the SOAP message and yield to any custom elements.
257
- def build_soap!(&block)
258
- opts = { :server_version => server_version, :impersonation_type => impersonation_type, :impersonation_mail => impersonation_address }
259
- opts[:time_zone_context] = @time_zone_context if @time_zone_context
260
- EwsBuilder.new.build!(opts, &block)
261
- end
242
+ opts.key?(key) ? opts[key] : default_val
243
+ end
244
+ end
262
245
 
263
- end # class ExchangeWebService
264
- end # Viewpoint
246
+ # Some operations only exist for certain versions of Exchange Server.
247
+ # This method should be called with the required version and we'll throw
248
+ # an exception of the currently set @server_version does not comply.
249
+ def validate_version(exchange_version)
250
+ return unless server_version < exchange_version
251
+
252
+ msg = +'The operation you are attempting to use is not compatible with'
253
+ msg << " your configured Exchange Server version(#{server_version})."
254
+ msg << " You must be running at least version (#{exchange_version})."
255
+ raise EwsServerVersionError, msg
256
+ end
257
+
258
+ # Build the common elements in the SOAP message and yield to any custom elements.
259
+ def build_soap!(&block)
260
+ opts = { server_version: server_version, impersonation_type: impersonation_type,
261
+ impersonation_mail: impersonation_address }
262
+ opts[:time_zone_context] = @time_zone_context if @time_zone_context
263
+ EwsBuilder.new.build!(opts, &block)
264
+ end
265
+ end
266
+ end
267
+ end
268
+ end
@@ -1,43 +1,47 @@
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
-
19
- module Viewpoint::EWS::SOAP
20
- class EwsParser
21
- include Viewpoint::EWS
22
-
23
- # @param [String] soap_resp
24
- def initialize(soap_resp)
25
- @soap_resp = soap_resp
26
- @sax_doc = EwsSaxDocument.new
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
4
+ #
5
+ # Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ module Viewpoint
20
+ module EWS
21
+ module SOAP
22
+ # Parses SOAP responses into Ruby hashes.
23
+ class EwsParser
24
+ include Viewpoint::EWS
25
+
26
+ # @param [String] soap_resp
27
+ def initialize(soap_resp)
28
+ @soap_resp = soap_resp
29
+ @sax_doc = EwsSaxDocument.new
30
+ end
31
+
32
+ def parse(opts = {})
33
+ opts[:response_class] ||= EwsSoapResponse
34
+ @soap_resp.gsub!(/&#x([0-8bcef]|1[0-9a-f]);/i, '')
35
+ sax_parser.parse(@soap_resp)
36
+ opts[:response_class].new @sax_doc.struct
37
+ end
38
+
39
+ private
40
+
41
+ def sax_parser
42
+ @sax_parser ||= Nokogiri::XML::SAX::Parser.new(@sax_doc)
43
+ end
44
+ end
27
45
  end
28
-
29
- def parse(opts = {})
30
- opts[:response_class] ||= EwsSoapResponse
31
- @soap_resp.gsub!(/&#x([0-8bcef]|1[0-9a-f]);/i, '')
32
- sax_parser.parse(@soap_resp)
33
- opts[:response_class].new @sax_doc.struct
34
- end
35
-
36
- private
37
-
38
- def sax_parser
39
- @parser ||= Nokogiri::XML::SAX::Parser.new(@sax_doc)
40
- end
41
-
42
- end # EwsParser
43
- end # Viewpoint
46
+ end
47
+ end