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.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/lib/ews/calendar_accessors.rb +37 -33
- data/lib/ews/connection.rb +152 -125
- data/lib/ews/connection_helper.rb +36 -33
- data/lib/ews/convert_accessors.rb +58 -54
- data/lib/ews/errors.rb +59 -53
- data/lib/ews/ews_client.rb +92 -79
- data/lib/ews/exceptions/exceptions.rb +61 -61
- data/lib/ews/folder_accessors.rb +235 -234
- data/lib/ews/impersonation.rb +29 -23
- data/lib/ews/item_accessors.rb +215 -213
- data/lib/ews/mailbox_accessors.rb +82 -79
- data/lib/ews/meeting_accessors.rb +38 -31
- data/lib/ews/message_accessors.rb +83 -81
- data/lib/ews/push_subscription_accessors.rb +29 -27
- data/lib/ews/room_accessors.rb +48 -46
- data/lib/ews/roomlist_accessors.rb +47 -45
- data/lib/ews/soap/builders/ews_builder.rb +1191 -1176
- data/lib/ews/soap/ews_response.rb +68 -73
- data/lib/ews/soap/ews_soap_availability_response.rb +57 -57
- data/lib/ews/soap/ews_soap_free_busy_response.rb +115 -117
- data/lib/ews/soap/ews_soap_response.rb +99 -101
- data/lib/ews/soap/ews_soap_room_response.rb +45 -45
- data/lib/ews/soap/ews_soap_roomlist_response.rb +45 -46
- data/lib/ews/soap/exchange_availability.rb +54 -52
- data/lib/ews/soap/exchange_data_services.rb +693 -711
- data/lib/ews/soap/exchange_notification.rb +123 -128
- data/lib/ews/soap/exchange_synchronization.rb +82 -82
- data/lib/ews/soap/exchange_time_zones.rb +41 -44
- data/lib/ews/soap/exchange_user_configuration.rb +30 -27
- data/lib/ews/soap/exchange_web_service.rb +237 -233
- data/lib/ews/soap/parsers/ews_parser.rb +46 -42
- data/lib/ews/soap/parsers/ews_sax_document.rb +63 -58
- data/lib/ews/soap/response_message.rb +69 -68
- data/lib/ews/soap/responses/create_attachment_response_message.rb +45 -45
- data/lib/ews/soap/responses/create_item_response_message.rb +26 -25
- data/lib/ews/soap/responses/find_item_response_message.rb +76 -78
- data/lib/ews/soap/responses/get_events_response_message.rb +52 -51
- data/lib/ews/soap/responses/send_notification_response_message.rb +53 -51
- data/lib/ews/soap/responses/subscribe_response_message.rb +37 -34
- data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +38 -35
- data/lib/ews/soap/responses/sync_folder_items_response_message.rb +38 -35
- data/lib/ews/soap.rb +27 -26
- data/lib/ews/templates/calendar_item.rb +64 -60
- data/lib/ews/templates/forward_item.rb +19 -17
- data/lib/ews/templates/message.rb +61 -58
- data/lib/ews/templates/reply_to_item.rb +20 -18
- data/lib/ews/templates/task.rb +55 -55
- data/lib/ews/types/attachment.rb +75 -74
- data/lib/ews/types/attendee.rb +27 -25
- data/lib/ews/types/calendar_folder.rb +58 -59
- data/lib/ews/types/calendar_item.rb +133 -131
- data/lib/ews/types/contact.rb +11 -5
- data/lib/ews/types/contacts_folder.rb +10 -5
- data/lib/ews/types/copied_event.rb +47 -48
- data/lib/ews/types/created_event.rb +22 -20
- data/lib/ews/types/deleted_event.rb +22 -20
- data/lib/ews/types/distribution_list.rb +11 -5
- data/lib/ews/types/event.rb +60 -59
- data/lib/ews/types/export_items_response_message.rb +54 -50
- data/lib/ews/types/file_attachment.rb +63 -61
- data/lib/ews/types/folder.rb +58 -57
- data/lib/ews/types/free_busy_changed_event.rb +22 -20
- data/lib/ews/types/generic_folder.rb +348 -372
- data/lib/ews/types/item.rb +401 -397
- data/lib/ews/types/item_attachment.rb +87 -80
- data/lib/ews/types/item_field_uri_map.rb +201 -200
- data/lib/ews/types/mailbox_user.rb +146 -154
- data/lib/ews/types/meeting_cancellation.rb +11 -5
- data/lib/ews/types/meeting_message.rb +11 -5
- data/lib/ews/types/meeting_request.rb +11 -5
- data/lib/ews/types/meeting_response.rb +11 -5
- data/lib/ews/types/message.rb +11 -5
- data/lib/ews/types/modified_event.rb +43 -45
- data/lib/ews/types/moved_event.rb +47 -48
- data/lib/ews/types/new_mail_event.rb +22 -20
- data/lib/ews/types/out_of_office.rb +145 -144
- data/lib/ews/types/post_item.rb +11 -5
- data/lib/ews/types/search_folder.rb +10 -5
- data/lib/ews/types/status_event.rb +37 -36
- data/lib/ews/types/task.rb +39 -33
- data/lib/ews/types/tasks_folder.rb +31 -25
- data/lib/ews/types.rb +134 -139
- data/lib/viewpoint/logging/config.rb +19 -19
- data/lib/viewpoint/logging.rb +23 -17
- data/lib/viewpoint/string_utils.rb +31 -32
- data/lib/viewpoint.rb +18 -18
- metadata +50 -25
- data/Changelog.txt +0 -1004
|
@@ -1,264 +1,268 @@
|
|
|
1
|
-
|
|
2
|
-
This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
34
|
+
attr_accessor :server_version, :auto_deepen, :no_auto_deepen_behavior, :connection, :impersonation_type,
|
|
35
|
+
:impersonation_address
|
|
11
36
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
170
|
+
|
|
171
|
+
do_soap_request(req, response_class: EwsSoapFreeBusyResponse)
|
|
165
172
|
end
|
|
166
|
-
end
|
|
167
173
|
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
226
|
-
# Private Methods (Builders and Parsers)
|
|
226
|
+
# Private Methods (Builders and Parsers)
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
264
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
module Viewpoint
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|