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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1bd4e910abc2cfbe08db2972b5903dfb283c4e9a8d98bd804b93f094709ae7b2
|
|
4
|
+
data.tar.gz: d6cd479428246450510e96931a72fb84eb50d148cbd33d95fd0278db24931d71
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f2a594e47277ccf9b74756ce63f6f9c25c43569db772109b0c7a5616719018b83f5d1de774f3c1afbe8253df8541275b737b69ae25c3e43e431fa525aa05849
|
|
7
|
+
data.tar.gz: c2588831f25737a7e57968295c3d75f64c50b7780b83f6f93826a0c03b98fec2d13af93e95504ccbe63b674fa74b19563d9218231a4488af0964d7b337ce4863
|
data/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Viewpoint for Exchange Web Services
|
|
2
|
-
[](https://github.com/WinRb/Viewpoint/actions/workflows/ci.yml)
|
|
3
3
|
[](https://rubygems.org/gems/viewpoint)
|
|
4
|
-
[](https://github.com/WinRb/Viewpoint/blob/
|
|
5
|
-
[](
|
|
6
|
-
[](
|
|
4
|
+
[](https://github.com/WinRb/Viewpoint/blob/main/LICENSE)
|
|
5
|
+
[](https://github.com/WinRb/Viewpoint/wiki)
|
|
6
|
+
[](https://www.rubydoc.info/github/WinRb/Viewpoint/frames)
|
|
7
7
|
|
|
8
8
|
Viewpoint for EWS provides a thin Ruby layer on top of Microsoft Exchange
|
|
9
9
|
Web Services(EWS). It also includes a bunch of model classes that add an
|
|
@@ -57,7 +57,7 @@ out of the picture this is no longer required. Go crazy ;)
|
|
|
57
57
|
|
|
58
58
|
The version 1.0 API is quite a departure from the 0.1.x code base. If you have a lot of legacy code and aren't suffering from performance issues, think twice about upgrading. That said, I hope you'll find the new API much clean and more intuitive than previous versions.
|
|
59
59
|
|
|
60
|
-
I also try and document the code to the base of my ability. Included in that code are links to the official Microsoft EWS documentation that might be helpful when troubleshooting "interesting" issues. You can either generate the documentation yourself with yard or check it out on [rdoc.info](
|
|
60
|
+
I also try and document the code to the base of my ability. Included in that code are links to the official Microsoft EWS documentation that might be helpful when troubleshooting "interesting" issues. You can either generate the documentation yourself with yard or check it out on [rdoc.info](https://www.rubydoc.info/github/WinRb/Viewpoint/frames).
|
|
61
61
|
|
|
62
62
|
Note the `cli` variable in the setup code directly below. I will use that variable throughout without the setup code.
|
|
63
63
|
|
|
@@ -70,7 +70,12 @@ endpoint = 'https://example.com/ews/Exchange.asmx'
|
|
|
70
70
|
user = 'username'
|
|
71
71
|
pass = 'password'
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
# Basic authentication
|
|
74
|
+
cli = Viewpoint::EWSClient.new({ endpoint: endpoint, type: 'basic', user: user, password: pass })
|
|
75
|
+
|
|
76
|
+
# OAuth bearer-token authentication
|
|
77
|
+
token = 'your-oauth-bearer-token'
|
|
78
|
+
cli = Viewpoint::EWSClient.new({ endpoint: endpoint, type: 'oauth', token: token })
|
|
74
79
|
```
|
|
75
80
|
|
|
76
81
|
There are also various options you can pass to EWSClient.
|
|
@@ -1,34 +1,38 @@
|
|
|
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
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is a cotribution to Viewpoint; the Ruby library for Microsoft Exchange Web Services.
|
|
4
|
+
#
|
|
5
|
+
# Copyright © 2013 Mark McCahill <mark.mccahill@duke.edu>
|
|
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
|
+
# Calendar operations mixed into the EWS client.
|
|
22
|
+
module CalendarAccessors
|
|
23
|
+
include Viewpoint::EWS
|
|
24
|
+
|
|
25
|
+
def event_busy_type(the_event)
|
|
26
|
+
the_event[:calendar_event][:elems][2][:busy_type][:text]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def event_start_time(the_event)
|
|
30
|
+
the_event[:calendar_event][:elems][0][:start_time][:text]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def event_end_time(the_event)
|
|
34
|
+
the_event[:calendar_event][:elems][1][:end_time][:text]
|
|
35
|
+
end
|
|
36
|
+
end
|
|
24
37
|
end
|
|
25
|
-
|
|
26
|
-
def event_start_time( the_event )
|
|
27
|
-
the_event[:calendar_event][:elems][0][:start_time][:text]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def event_end_time( the_event )
|
|
31
|
-
the_event[:calendar_event][:elems][1][:end_time][:text]
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end # Viewpoint::EWS::CalendarAccessors
|
|
38
|
+
end
|
data/lib/ews/connection.rb
CHANGED
|
@@ -1,140 +1,167 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
18
|
require 'httpclient'
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@
|
|
45
|
-
opts[:trust_ca
|
|
46
|
-
|
|
20
|
+
module Viewpoint
|
|
21
|
+
module EWS
|
|
22
|
+
# HTTP connection to the Exchange server.
|
|
23
|
+
class Connection
|
|
24
|
+
include Viewpoint::EWS::ConnectionHelper
|
|
25
|
+
include Viewpoint::EWS
|
|
26
|
+
|
|
27
|
+
attr_reader :endpoint
|
|
28
|
+
|
|
29
|
+
SUPPORTED_HTTPCLIENT_OPTS = %i[agent_name default_header].freeze
|
|
30
|
+
|
|
31
|
+
# @param [Hash] auth authentication details
|
|
32
|
+
# @option auth [String] :endpoint the URL of the web service.
|
|
33
|
+
# @example https://<site>/ews/Exchange.asmx
|
|
34
|
+
# @option auth [String] :type the authentication type: 'basic' or 'oauth'
|
|
35
|
+
# @option auth [String] :user the user to authenticate as (basic auth)
|
|
36
|
+
# @option auth [String] :password the user password (basic auth)
|
|
37
|
+
# @option auth [String] :token the OAuth bearer token (oauth auth)
|
|
38
|
+
# @param [Hash] opts Misc config options (mostly for development)
|
|
39
|
+
# @option opts [Fixnum] :ssl_verify_mode
|
|
40
|
+
# @option opts [Fixnum] :receive_timeout override the default receive timeout
|
|
41
|
+
# seconds
|
|
42
|
+
# @option opts [Fixnum] :connect_timeout override the default connect timeout
|
|
43
|
+
# seconds
|
|
44
|
+
# @option opts [OpenSSL::X509::Store] :cert_store a custom cert store
|
|
45
|
+
# @option opts [Array] :trust_ca an array of hashed dir paths or a file
|
|
46
|
+
# @option opts [String] :user_agent the http user agent to use in all requests
|
|
47
|
+
def initialize(auth, opts = {})
|
|
48
|
+
@log = Viewpoint::EWS.root_logger
|
|
49
|
+
|
|
50
|
+
@auth_type = auth[:type]
|
|
51
|
+
@auth_token = auth[:token]
|
|
52
|
+
|
|
53
|
+
httpclient_opts = opts.slice(*SUPPORTED_HTTPCLIENT_OPTS)
|
|
54
|
+
@httpcli = HTTPClient.new(**httpclient_opts)
|
|
55
|
+
|
|
56
|
+
if opts[:cert_store].is_a?(OpenSSL::X509::Store)
|
|
57
|
+
@log.debug 'Applying custom cert_store provided via opts[:cert_store]'
|
|
58
|
+
# Assign the provided store directly
|
|
59
|
+
@httpcli.ssl_config.cert_store = opts[:cert_store]
|
|
60
|
+
|
|
61
|
+
@log.debug 'Skipping original :trust_ca handling due to provided :cert_store.'
|
|
62
|
+
elsif opts[:trust_ca]
|
|
63
|
+
@httpcli.ssl_config.clear_cert_store
|
|
64
|
+
opts[:trust_ca].each do |ca|
|
|
65
|
+
@httpcli.ssl_config.add_trust_ca ca
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
@httpcli.ssl_config.verify_mode = opts[:ssl_verify_mode] if opts[:ssl_verify_mode]
|
|
70
|
+
@httpcli.ssl_config.ssl_version = opts[:ssl_version] if opts[:ssl_version]
|
|
71
|
+
# Up the keep-alive so we don't have to do the NTLM dance as often.
|
|
72
|
+
@httpcli.keep_alive_timeout = 60
|
|
73
|
+
@httpcli.receive_timeout = opts[:receive_timeout] if opts[:receive_timeout]
|
|
74
|
+
@httpcli.connect_timeout = opts[:connect_timeout] if opts[:connect_timeout]
|
|
75
|
+
@endpoint = auth[:endpoint]
|
|
47
76
|
end
|
|
48
|
-
end
|
|
49
77
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@httpcli.keep_alive_timeout = 60
|
|
54
|
-
@httpcli.receive_timeout = opts[:receive_timeout] if opts[:receive_timeout]
|
|
55
|
-
@httpcli.connect_timeout = opts[:connect_timeout] if opts[:connect_timeout]
|
|
56
|
-
@endpoint = endpoint
|
|
57
|
-
end
|
|
78
|
+
def set_auth(user, pass)
|
|
79
|
+
@httpcli.set_auth(@endpoint.to_s, user, pass)
|
|
80
|
+
end
|
|
58
81
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
# Authenticate to the web service. You don't have to do this because
|
|
83
|
+
# authentication will happen on the first request if you don't do it here.
|
|
84
|
+
# @return [Boolean] true if authentication is successful, false otherwise
|
|
85
|
+
def authenticate
|
|
86
|
+
get && true
|
|
87
|
+
end
|
|
62
88
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
89
|
+
# Every Connection class must have the dispatch method. It is what sends the
|
|
90
|
+
# SOAP request to the server and calls the parser method on the EWS instance.
|
|
91
|
+
#
|
|
92
|
+
# This was originally in the ExchangeWebService class but it was added here
|
|
93
|
+
# to make the processing chain easier to modify. For example, it allows the
|
|
94
|
+
# reactor pattern to handle the request with a callback.
|
|
95
|
+
# @param ews [Viewpoint::EWS::SOAP::ExchangeWebService] used to call
|
|
96
|
+
# #parse_soap_response
|
|
97
|
+
# @param soapmsg [String]
|
|
98
|
+
# @param opts [Hash] misc opts for handling the Response
|
|
99
|
+
def dispatch(ews, soapmsg, opts)
|
|
100
|
+
respmsg = post(soapmsg)
|
|
101
|
+
@log.debug <<~LOG
|
|
102
|
+
Received SOAP Response:
|
|
103
|
+
----------------
|
|
104
|
+
#{Nokogiri::XML(respmsg).to_xml}
|
|
105
|
+
----------------
|
|
106
|
+
LOG
|
|
107
|
+
opts[:raw_response] ? respmsg : ews.parse_soap_response(respmsg, opts)
|
|
108
|
+
end
|
|
69
109
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
# @param ews [Viewpoint::EWS::SOAP::ExchangeWebService] used to call
|
|
77
|
-
# #parse_soap_response
|
|
78
|
-
# @param soapmsg [String]
|
|
79
|
-
# @param opts [Hash] misc opts for handling the Response
|
|
80
|
-
def dispatch(ews, soapmsg, opts)
|
|
81
|
-
respmsg = post(soapmsg)
|
|
82
|
-
@log.debug <<-EOF.gsub(/^ {6}/, '')
|
|
83
|
-
Received SOAP Response:
|
|
84
|
-
----------------
|
|
85
|
-
#{Nokogiri::XML(respmsg).to_xml}
|
|
86
|
-
----------------
|
|
87
|
-
EOF
|
|
88
|
-
opts[:raw_response] ? respmsg : ews.parse_soap_response(respmsg, opts)
|
|
89
|
-
end
|
|
110
|
+
# Send a GET to the web service
|
|
111
|
+
# @return [String] If the request is successful (200) it returns the body of
|
|
112
|
+
# the response.
|
|
113
|
+
def get
|
|
114
|
+
check_response(@httpcli.get(@endpoint))
|
|
115
|
+
end
|
|
90
116
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
117
|
+
# Send a POST to the web service
|
|
118
|
+
# @return [String] If the request is successful (200) it returns the body of
|
|
119
|
+
# the response.
|
|
120
|
+
def post(xmldoc)
|
|
121
|
+
headers = { 'Content-Type' => 'text/xml' }
|
|
122
|
+
headers['Authorization'] = "Bearer #{@auth_token}" if oauth_token?
|
|
123
|
+
check_response(@httpcli.post(@endpoint, xmldoc, headers))
|
|
124
|
+
end
|
|
97
125
|
|
|
98
|
-
|
|
99
|
-
# @return [String] If the request is successful (200) it returns the body of
|
|
100
|
-
# the response.
|
|
101
|
-
def post(xmldoc)
|
|
102
|
-
headers = {'Content-Type' => 'text/xml'}
|
|
103
|
-
check_response( @httpcli.post(@endpoint, xmldoc, headers) )
|
|
104
|
-
end
|
|
126
|
+
private
|
|
105
127
|
|
|
128
|
+
# True when a non-empty OAuth bearer token was supplied.
|
|
129
|
+
def oauth_token?
|
|
130
|
+
@auth_type == 'oauth' && @auth_token.is_a?(String) && !@auth_token.empty?
|
|
131
|
+
end
|
|
106
132
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
def check_response(resp)
|
|
134
|
+
case resp.status
|
|
135
|
+
when 200
|
|
136
|
+
resp.body
|
|
137
|
+
when 302
|
|
138
|
+
# @todo redirect
|
|
139
|
+
raise Errors::UnhandledResponseError.new('Unhandled HTTP Redirect', resp)
|
|
140
|
+
when 401
|
|
141
|
+
raise Errors::UnauthorizedResponseError.new('Unauthorized request', resp)
|
|
142
|
+
when 500
|
|
143
|
+
unless resp.headers['Content-Type'] =~ /xml/
|
|
144
|
+
raise Errors::ServerError.new("Internal Server Error. Message: #{resp.body}", resp)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
err_string, err_code = parse_soap_error(resp.body)
|
|
148
|
+
raise Errors::SoapResponseError.new("SOAP Error: Message: #{err_string} Code: #{err_code}", resp, err_code,
|
|
149
|
+
err_string)
|
|
150
|
+
|
|
151
|
+
else
|
|
152
|
+
raise Errors::ResponseError.new("HTTP Error Code: #{resp.status}, Msg: #{resp.body}", resp)
|
|
153
|
+
end
|
|
124
154
|
end
|
|
125
|
-
else
|
|
126
|
-
raise Errors::ResponseError.new("HTTP Error Code: #{resp.status}, Msg: #{resp.body}", resp)
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
155
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
156
|
+
# @param [String] xml to parse the errors from.
|
|
157
|
+
def parse_soap_error(xml)
|
|
158
|
+
ndoc = Nokogiri::XML(xml)
|
|
159
|
+
ns = ndoc.collect_namespaces
|
|
160
|
+
err_string = ndoc.xpath('//faultstring', ns).text
|
|
161
|
+
err_code = ndoc.xpath('//faultcode', ns).text
|
|
162
|
+
@log.debug "Internal SOAP error. Message: #{err_string}, Code: #{err_code}"
|
|
163
|
+
[err_string, err_code]
|
|
164
|
+
end
|
|
165
|
+
end
|
|
138
166
|
end
|
|
139
|
-
|
|
140
167
|
end
|
|
@@ -1,35 +1,38 @@
|
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
# Helpers for building authenticated HTTP connections.
|
|
22
|
+
module ConnectionHelper
|
|
23
|
+
def init_logging!
|
|
24
|
+
@log = Viewpoint::EWS.root_logger
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @param [String] xml to parse the errors from.
|
|
28
|
+
def parse_soap_error(xml)
|
|
29
|
+
ndoc = Nokogiri::XML(xml)
|
|
30
|
+
ns = ndoc.collect_namespaces
|
|
31
|
+
err_string = ndoc.xpath('//faultstring', ns).text
|
|
32
|
+
err_code = ndoc.xpath('//faultcode', ns).text
|
|
33
|
+
@log.debug "Internal SOAP error. Message: #{err_string}, Code: #{err_code}"
|
|
34
|
+
[err_string, err_code]
|
|
35
|
+
end
|
|
36
|
+
end
|
|
33
37
|
end
|
|
34
|
-
|
|
35
38
|
end
|
|
@@ -1,56 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
module Viewpoint
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
|
|
4
|
+
#
|
|
5
|
+
# Copyright © 2013 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
|
+
module Viewpoint
|
|
19
|
+
module EWS
|
|
20
|
+
# Convert operations mixed into the EWS client.
|
|
21
|
+
module ConvertAccessors
|
|
22
|
+
include Viewpoint::EWS
|
|
23
|
+
|
|
24
|
+
# This is a class method that converts identifiers between formats.
|
|
25
|
+
# @param [String] id The id to be converted
|
|
26
|
+
# @param [Hash] opts Misc options to control request
|
|
27
|
+
# @option opts [Symbol] :format :ews_legacy_id/:ews_id/:entry_id/:hex_entry_id/:store_id/:owa_id
|
|
28
|
+
# @option opts [Symbol] :destination_format :ews_legacy_id/:ews_id/:entry_id/:hex_entry_id/:store_id/:owa_id
|
|
29
|
+
# @option opts [String] :mailbox Mailbox, if required
|
|
30
|
+
# @return [EwsResponse] Returns an EwsResponse containing the convert response message
|
|
31
|
+
|
|
32
|
+
def convert_id(id, opts = {})
|
|
33
|
+
args = convert_id_args(id, opts.clone)
|
|
34
|
+
obj = OpenStruct.new(opts: args)
|
|
35
|
+
yield obj if block_given?
|
|
36
|
+
resp = ews.convert_id(args)
|
|
37
|
+
convert_id_parser(resp)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def convert_id_args(id, opts)
|
|
43
|
+
{ id: id }.merge opts
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def convert_id_parser(resp)
|
|
47
|
+
rm = resp.response_messages[0]
|
|
48
|
+
|
|
49
|
+
if rm && rm.status == 'Success'
|
|
50
|
+
# @todo create custom response class
|
|
51
|
+
rm
|
|
52
|
+
else
|
|
53
|
+
rm.respond_to?(:code) ? rm.code : 'Unknown'
|
|
54
|
+
rm.respond_to?(:message_text) ? rm.message_text : 'Unknown'
|
|
55
|
+
raise EwsError, "Could not convert id. #{rm.code}: #{rm.message_text}"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
53
58
|
end
|
|
54
59
|
end
|
|
55
|
-
|
|
56
|
-
end # Viewpoint::EWS::ItemAccessors
|
|
60
|
+
end
|