stxt-viewpoint 1.0.0.beta.3
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 +7 -0
- data/Changelog.txt +1004 -0
- data/README.md +201 -0
- data/TODO +17 -0
- data/lib/ews/calendar_accessors.rb +46 -0
- data/lib/ews/connection.rb +120 -0
- data/lib/ews/connection_helper.rb +35 -0
- data/lib/ews/convert_accessors.rb +56 -0
- data/lib/ews/errors.rb +56 -0
- data/lib/ews/ews_client.rb +101 -0
- data/lib/ews/exceptions/exceptions.rb +61 -0
- data/lib/ews/folder_accessors.rb +264 -0
- data/lib/ews/impersonation.rb +30 -0
- data/lib/ews/item_accessors.rb +231 -0
- data/lib/ews/mailbox_accessors.rb +92 -0
- data/lib/ews/message_accessors.rb +93 -0
- data/lib/ews/push_subscription_accessors.rb +33 -0
- data/lib/ews/room_accessors.rb +48 -0
- data/lib/ews/roomlist_accessors.rb +47 -0
- data/lib/ews/soap/builders/ews_builder.rb +1257 -0
- data/lib/ews/soap/ews_response.rb +84 -0
- data/lib/ews/soap/ews_soap_availability_response.rb +58 -0
- data/lib/ews/soap/ews_soap_free_busy_response.rb +119 -0
- data/lib/ews/soap/ews_soap_response.rb +103 -0
- data/lib/ews/soap/ews_soap_room_response.rb +53 -0
- data/lib/ews/soap/ews_soap_roomlist_response.rb +54 -0
- data/lib/ews/soap/exchange_availability.rb +61 -0
- data/lib/ews/soap/exchange_data_services.rb +780 -0
- data/lib/ews/soap/exchange_notification.rb +146 -0
- data/lib/ews/soap/exchange_synchronization.rb +93 -0
- data/lib/ews/soap/exchange_time_zones.rb +56 -0
- data/lib/ews/soap/exchange_user_configuration.rb +33 -0
- data/lib/ews/soap/exchange_web_service.rb +264 -0
- data/lib/ews/soap/parsers/ews_parser.rb +43 -0
- data/lib/ews/soap/parsers/ews_sax_document.rb +70 -0
- data/lib/ews/soap/response_message.rb +80 -0
- data/lib/ews/soap/responses/create_attachment_response_message.rb +47 -0
- data/lib/ews/soap/responses/create_item_response_message.rb +25 -0
- data/lib/ews/soap/responses/find_item_response_message.rb +80 -0
- data/lib/ews/soap/responses/get_events_response_message.rb +53 -0
- data/lib/ews/soap/responses/send_notification_response_message.rb +59 -0
- data/lib/ews/soap/responses/subscribe_response_message.rb +35 -0
- data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +36 -0
- data/lib/ews/soap/responses/sync_folder_items_response_message.rb +36 -0
- data/lib/ews/soap.rb +63 -0
- data/lib/ews/templates/calendar_item.rb +78 -0
- data/lib/ews/templates/forward_item.rb +24 -0
- data/lib/ews/templates/message.rb +73 -0
- data/lib/ews/templates/reply_to_item.rb +25 -0
- data/lib/ews/templates/task.rb +74 -0
- data/lib/ews/types/attachment.rb +77 -0
- data/lib/ews/types/attendee.rb +27 -0
- data/lib/ews/types/calendar_folder.rb +50 -0
- data/lib/ews/types/calendar_item.rb +122 -0
- data/lib/ews/types/contact.rb +7 -0
- data/lib/ews/types/contacts_folder.rb +8 -0
- data/lib/ews/types/copied_event.rb +51 -0
- data/lib/ews/types/created_event.rb +24 -0
- data/lib/ews/types/deleted_event.rb +24 -0
- data/lib/ews/types/distribution_list.rb +7 -0
- data/lib/ews/types/event.rb +62 -0
- data/lib/ews/types/export_items_response_message.rb +52 -0
- data/lib/ews/types/file_attachment.rb +65 -0
- data/lib/ews/types/folder.rb +60 -0
- data/lib/ews/types/free_busy_changed_event.rb +24 -0
- data/lib/ews/types/generic_folder.rb +420 -0
- data/lib/ews/types/item.rb +438 -0
- data/lib/ews/types/item_attachment.rb +84 -0
- data/lib/ews/types/item_field_uri_map.rb +224 -0
- data/lib/ews/types/mailbox_user.rb +156 -0
- data/lib/ews/types/meeting_cancellation.rb +7 -0
- data/lib/ews/types/meeting_message.rb +7 -0
- data/lib/ews/types/meeting_request.rb +7 -0
- data/lib/ews/types/meeting_response.rb +7 -0
- data/lib/ews/types/message.rb +7 -0
- data/lib/ews/types/modified_event.rb +48 -0
- data/lib/ews/types/moved_event.rb +51 -0
- data/lib/ews/types/new_mail_event.rb +24 -0
- data/lib/ews/types/out_of_office.rb +147 -0
- data/lib/ews/types/search_folder.rb +8 -0
- data/lib/ews/types/status_event.rb +39 -0
- data/lib/ews/types/task.rb +37 -0
- data/lib/ews/types/tasks_folder.rb +27 -0
- data/lib/ews/types.rb +191 -0
- data/lib/viewpoint/logging/config.rb +24 -0
- data/lib/viewpoint/logging.rb +27 -0
- data/lib/viewpoint/string_utils.rb +44 -0
- data/lib/viewpoint.rb +109 -0
- metadata +191 -0
@@ -0,0 +1,70 @@
|
|
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
|
+
# Parse the incoming response document via a SAX parser instead of the
|
21
|
+
# traditional DOM parser. In early benchmarks this was performing about
|
22
|
+
# 132% faster than the DOM-based parser for large documents.
|
23
|
+
class EwsSaxDocument < Nokogiri::XML::SAX::Document
|
24
|
+
include Viewpoint::EWS
|
25
|
+
include Viewpoint::StringUtils
|
26
|
+
|
27
|
+
attr_reader :struct
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@struct = {}
|
31
|
+
@elems = []
|
32
|
+
end
|
33
|
+
|
34
|
+
def characters(string)
|
35
|
+
# FIXME: Move white space removal to somewhere else.
|
36
|
+
# This function can be called multiple times. In this case newlines in Text Bodies get stripped.
|
37
|
+
# See: https://github.com/zenchild/Viewpoint/issues/90
|
38
|
+
#string.strip!
|
39
|
+
return if string.empty?
|
40
|
+
if @elems.last[:text]
|
41
|
+
@elems.last[:text] += string
|
42
|
+
else
|
43
|
+
@elems.last[:text] = string
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def start_element_namespace(name, attributes = [], prefix = nil, uri = nil, ns = [])
|
48
|
+
name = ruby_case(name).to_sym
|
49
|
+
elem = {}
|
50
|
+
unless attributes.empty?
|
51
|
+
elem[:attribs] = attributes.collect{|a|
|
52
|
+
{ ruby_case(a.localname).to_sym => a.value}
|
53
|
+
}.inject(&:merge)
|
54
|
+
end
|
55
|
+
@elems << elem
|
56
|
+
end
|
57
|
+
|
58
|
+
def end_element_namespace name, prefix=nil, uri=nil
|
59
|
+
name = ruby_case(name).to_sym
|
60
|
+
elem = @elems.pop
|
61
|
+
if @elems.empty?
|
62
|
+
@struct[name] = elem
|
63
|
+
else
|
64
|
+
@elems.last[:elems] = [] unless @elems.last[:elems].is_a?(Array)
|
65
|
+
@elems.last[:elems] << {name => elem}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,80 @@
|
|
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 ResponseMessage
|
21
|
+
|
22
|
+
attr_reader :message, :type
|
23
|
+
|
24
|
+
def initialize(message)
|
25
|
+
@type = message.keys.first
|
26
|
+
@message = message[@type]
|
27
|
+
end
|
28
|
+
|
29
|
+
def response_class
|
30
|
+
message[:attribs][:response_class]
|
31
|
+
end
|
32
|
+
alias :status :response_class
|
33
|
+
|
34
|
+
def success?
|
35
|
+
response_class == 'Success'
|
36
|
+
end
|
37
|
+
|
38
|
+
def message_text
|
39
|
+
safe_hash_access message, [:elems, :message_text, :text]
|
40
|
+
end
|
41
|
+
|
42
|
+
def response_code
|
43
|
+
safe_hash_access message, [:elems, :response_code, :text]
|
44
|
+
end
|
45
|
+
alias :code :response_code
|
46
|
+
|
47
|
+
def message_xml
|
48
|
+
safe_hash_access message, [:elems, :message_xml, :text]
|
49
|
+
end
|
50
|
+
|
51
|
+
def items
|
52
|
+
safe_hash_access(message, [:elems, :items, :elems]) || []
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
|
59
|
+
def safe_hash_access(hsh, keys)
|
60
|
+
key = keys.shift
|
61
|
+
return nil unless hsh.is_a?(Hash) && hsh.has_key?(key)
|
62
|
+
|
63
|
+
if keys.empty?
|
64
|
+
hsh[key]
|
65
|
+
else
|
66
|
+
safe_hash_access hsh[key], keys
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end # Viewpoint::EWS::SOAP
|
72
|
+
|
73
|
+
require_relative './responses/create_item_response_message'
|
74
|
+
require_relative './responses/create_attachment_response_message'
|
75
|
+
require_relative './responses/find_item_response_message'
|
76
|
+
require_relative './responses/subscribe_response_message'
|
77
|
+
require_relative './responses/get_events_response_message'
|
78
|
+
require_relative './responses/send_notification_response_message'
|
79
|
+
require_relative './responses/sync_folder_items_response_message'
|
80
|
+
require_relative './responses/sync_folder_hierarchy_response_message'
|
@@ -0,0 +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
|
+
|
21
|
+
class CreateAttachmentResponseMessage < ResponseMessage
|
22
|
+
include Viewpoint::StringUtils
|
23
|
+
|
24
|
+
def attachments
|
25
|
+
return @attachments if @attachments
|
26
|
+
|
27
|
+
a = safe_hash_access message, [:elems, :attachments, :elems]
|
28
|
+
@attachments = a.nil? ? nil : parse_attachments(a)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
|
35
|
+
def parse_attachments(att)
|
36
|
+
att.collect do |a|
|
37
|
+
type = a.keys.first
|
38
|
+
klass = Viewpoint::EWS::Types.const_get(camel_case(type))
|
39
|
+
item = OpenStruct.new
|
40
|
+
item.ews = nil
|
41
|
+
klass.new(item, a[type])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end # CreateAttachmentResponseMessage
|
46
|
+
|
47
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,25 @@
|
|
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
|
+
|
21
|
+
class CreateItemResponseMessage < ResponseMessage
|
22
|
+
|
23
|
+
end # CreateItemResponseMessage
|
24
|
+
|
25
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,80 @@
|
|
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
|
+
|
21
|
+
class RootFolder
|
22
|
+
|
23
|
+
attr_reader :root
|
24
|
+
|
25
|
+
def initialize(root)
|
26
|
+
@root = root
|
27
|
+
end
|
28
|
+
|
29
|
+
def indexed_paging_offset
|
30
|
+
attrib :index_paging_offset
|
31
|
+
end
|
32
|
+
|
33
|
+
def numerator_offset
|
34
|
+
attrib :numerator_offset
|
35
|
+
end
|
36
|
+
|
37
|
+
def absolute_denominator
|
38
|
+
attrib :absolute_denominator
|
39
|
+
end
|
40
|
+
|
41
|
+
def includes_last_item_in_range
|
42
|
+
attrib :includes_last_item_in_range
|
43
|
+
end
|
44
|
+
|
45
|
+
def total_items_in_view
|
46
|
+
attrib :total_items_in_view
|
47
|
+
end
|
48
|
+
|
49
|
+
def items
|
50
|
+
root[:elems][0][:items][:elems] || []
|
51
|
+
end
|
52
|
+
|
53
|
+
def groups
|
54
|
+
root[:elems][0][:groups][:elems]
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
|
61
|
+
def attrib(key)
|
62
|
+
return nil unless root.has_key?(:attribs)
|
63
|
+
root[:attribs][key]
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
class FindItemResponseMessage < ResponseMessage
|
70
|
+
|
71
|
+
def root_folder
|
72
|
+
return @root_folder if @root_folder
|
73
|
+
|
74
|
+
rf = safe_hash_access message, [:elems, :root_folder]
|
75
|
+
@root_folder = rf.nil? ? nil : RootFolder.new(rf)
|
76
|
+
end
|
77
|
+
|
78
|
+
end # FindItemResponseMessage
|
79
|
+
|
80
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,53 @@
|
|
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 GetEventsResponseMessage < ResponseMessage
|
21
|
+
|
22
|
+
def notification
|
23
|
+
safe_hash_access message, [:elems, :notification, :elems]
|
24
|
+
end
|
25
|
+
|
26
|
+
def subscription_id
|
27
|
+
safe_hash_access notification[0], [:subscription_id, :text]
|
28
|
+
end
|
29
|
+
|
30
|
+
def previous_watermark
|
31
|
+
safe_hash_access notification[1], [:previous_watermark, :text]
|
32
|
+
end
|
33
|
+
|
34
|
+
def new_watermark
|
35
|
+
ev = notification.last
|
36
|
+
if ev
|
37
|
+
type = ev.keys.first
|
38
|
+
ev[type][:elems][0][:watermark][:text]
|
39
|
+
else
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def more_events?
|
45
|
+
safe_hash_access(notification[2], [:more_events, :text]) == 'true'
|
46
|
+
end
|
47
|
+
|
48
|
+
def events
|
49
|
+
notification[3..-1]
|
50
|
+
end
|
51
|
+
|
52
|
+
end # GetEventsResponseMessage
|
53
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,59 @@
|
|
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 SendNotificationResponseMessage < ResponseMessage
|
21
|
+
include Viewpoint::StringUtils
|
22
|
+
|
23
|
+
def notification
|
24
|
+
safe_hash_access message, [:elems, :notification, :elems]
|
25
|
+
end
|
26
|
+
|
27
|
+
def subscription_id
|
28
|
+
safe_hash_access notification[0], [:subscription_id, :text]
|
29
|
+
end
|
30
|
+
|
31
|
+
def previous_watermark
|
32
|
+
safe_hash_access notification[1], [:previous_watermark, :text]
|
33
|
+
end
|
34
|
+
|
35
|
+
def new_watermark
|
36
|
+
ev = notification.last
|
37
|
+
if ev
|
38
|
+
type = ev.keys.first
|
39
|
+
ev[type][:elems][0][:watermark][:text]
|
40
|
+
else
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def more_events?
|
46
|
+
safe_hash_access(notification[2], [:more_events, :text]) == 'true'
|
47
|
+
end
|
48
|
+
|
49
|
+
def events
|
50
|
+
@events ||=
|
51
|
+
notification[3..-1].collect do |ev|
|
52
|
+
type = ev.keys.first
|
53
|
+
klass = Viewpoint::EWS::Types.const_get(camel_case(type))
|
54
|
+
klass.new(nil, ev[type])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end # SendNotificationResponseMessage
|
59
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,35 @@
|
|
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 SubscribeResponseMessage < ResponseMessage
|
21
|
+
|
22
|
+
def subscription
|
23
|
+
safe_hash_access message, [:elems]
|
24
|
+
end
|
25
|
+
|
26
|
+
def subscription_id
|
27
|
+
safe_hash_access subscription, [:subscription_id, :text]
|
28
|
+
end
|
29
|
+
|
30
|
+
def watermark
|
31
|
+
safe_hash_access subscription, [:watermark, :text]
|
32
|
+
end
|
33
|
+
|
34
|
+
end # SubscribeResponseMessage
|
35
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,36 @@
|
|
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 SyncFolderHierarchyResponseMessage < ResponseMessage
|
21
|
+
|
22
|
+
def sync_state
|
23
|
+
safe_hash_access message, [:elems, :sync_state, :text]
|
24
|
+
end
|
25
|
+
|
26
|
+
def includes_last_folder_in_range?
|
27
|
+
ans = safe_hash_access message, [:elems, :includes_last_folder_in_range, :text]
|
28
|
+
ans.downcase == 'true'
|
29
|
+
end
|
30
|
+
|
31
|
+
def changes
|
32
|
+
safe_hash_access(message, [:elems, :changes, :elems]) || []
|
33
|
+
end
|
34
|
+
|
35
|
+
end # SyncFolderHierarchyResponseMessage
|
36
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,36 @@
|
|
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 SyncFolderItemsResponseMessage < ResponseMessage
|
21
|
+
|
22
|
+
def sync_state
|
23
|
+
safe_hash_access message, [:elems, :sync_state, :text]
|
24
|
+
end
|
25
|
+
|
26
|
+
def includes_last_item_in_range?
|
27
|
+
ans = safe_hash_access message, [:elems, :includes_last_item_in_range, :text]
|
28
|
+
ans.downcase == 'true'
|
29
|
+
end
|
30
|
+
|
31
|
+
def changes
|
32
|
+
safe_hash_access(message, [:elems, :changes, :elems]) || []
|
33
|
+
end
|
34
|
+
|
35
|
+
end # SyncFolderItemsResponseMessage
|
36
|
+
end # Viewpoint::EWS::SOAP
|
data/lib/ews/soap.rb
ADDED
@@ -0,0 +1,63 @@
|
|
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
|
+
# This module defines some constants and other niceties to make available to
|
20
|
+
# the underlying SOAP classes and modules that do the actual work.
|
21
|
+
module Viewpoint
|
22
|
+
module EWS
|
23
|
+
module SOAP
|
24
|
+
|
25
|
+
# CONSTANTS
|
26
|
+
|
27
|
+
NS_SOAP = 'soap'.freeze
|
28
|
+
NS_EWS_TYPES = 't'.freeze
|
29
|
+
NS_EWS_MESSAGES = 'm'.freeze
|
30
|
+
NAMESPACES = {
|
31
|
+
"xmlns:#{NS_SOAP}" => 'http://schemas.xmlsoap.org/soap/envelope/',
|
32
|
+
"xmlns:#{NS_EWS_TYPES}" => 'http://schemas.microsoft.com/exchange/services/2006/types',
|
33
|
+
"xmlns:#{NS_EWS_MESSAGES}" => 'http://schemas.microsoft.com/exchange/services/2006/messages',
|
34
|
+
}.freeze
|
35
|
+
|
36
|
+
# used in ResolveNames to determine where names are resolved
|
37
|
+
ActiveDirectory = 'ActiveDirectory'
|
38
|
+
ActiveDirectoryContacts = 'ActiveDirectoryContacts'
|
39
|
+
Contacts = 'Contacts'
|
40
|
+
ContactsActiveDirectory = 'ContactsActiveDirectory'
|
41
|
+
|
42
|
+
# Target specific Exchange Server versions
|
43
|
+
# @see http://msdn.microsoft.com/en-us/library/bb891876(v=exchg.140).aspx
|
44
|
+
VERSION_2007 = 'Exchange2007'
|
45
|
+
VERSION_2007_SP1 = 'Exchange2007_SP1'
|
46
|
+
VERSION_2010 = 'Exchange2010'
|
47
|
+
VERSION_2010_SP1 = 'Exchange2010_SP1'
|
48
|
+
VERSION_2010_SP2 = 'Exchange2010_SP2'
|
49
|
+
VERSION_2013 = 'Exchange2013'
|
50
|
+
VERSION_NONE = 'none'
|
51
|
+
|
52
|
+
HARD_DELETE = 'HardDelete'
|
53
|
+
SOFT_DELETE = 'SoftDelete'
|
54
|
+
MOVE_TO_DELETED_ITEMS = 'MoveToDeletedItems'
|
55
|
+
|
56
|
+
def initialize
|
57
|
+
@log = Logging.logger[self.class.name.to_s.to_sym]
|
58
|
+
@default_ns = NAMESPACES["xmlns:#{NS_EWS_MESSAGES}"]
|
59
|
+
end
|
60
|
+
|
61
|
+
end # SOAP
|
62
|
+
end # EWS
|
63
|
+
end # Viewpoint
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Viewpoint::EWS
|
2
|
+
module Template
|
3
|
+
# Template for creating CalendarItems
|
4
|
+
# @see http://msdn.microsoft.com/en-us/library/exchange/aa564765.aspx
|
5
|
+
class CalendarItem < OpenStruct
|
6
|
+
|
7
|
+
# Available parameters with the required ordering
|
8
|
+
PARAMETERS = %w{mime_content item_id parent_folder_id item_class subject sensitivity body attachments
|
9
|
+
date_time_received size categories in_reply_to is_submitted is_draft is_from_me is_resend is_unmodified
|
10
|
+
internet_message_headers date_time_sent date_time_created response_objects reminder_due_by reminder_is_set
|
11
|
+
reminder_minutes_before_start display_cc display_to has_attachments extended_property culture start end
|
12
|
+
original_start is_all_day_event legacy_free_busy_status location when is_meeting is_cancelled is_recurring
|
13
|
+
meeting_request_was_sent is_response_requested calendar_item_type my_response_type organizer
|
14
|
+
required_attendees optional_attendees resources conflicting_meeting_count adjacent_meeting_count
|
15
|
+
conflicting_meetings adjacent_meetings duration time_zone appointment_reply_time appointment_sequence_number
|
16
|
+
appointment_state recurrence first_occurrence last_occurrence modified_occurrences deleted_occurrences
|
17
|
+
meeting_time_zone start_time_zone end_time_zone conference_type allow_new_time_proposal is_online_meeting
|
18
|
+
meeting_workspace_url net_show_url effective_rights last_modified_name last_modified_time is_associated
|
19
|
+
web_client_read_form_query_string web_client_edit_form_query_string conversation_id unique_body
|
20
|
+
}.map(&:to_sym).freeze
|
21
|
+
|
22
|
+
# Returns a new CalendarItem template
|
23
|
+
def initialize(opts = {})
|
24
|
+
super opts.dup
|
25
|
+
end
|
26
|
+
|
27
|
+
# EWS CreateItem container
|
28
|
+
# @return [Hash]
|
29
|
+
def to_ews_create
|
30
|
+
structure = {}
|
31
|
+
structure[:message_disposition] = (draft ? 'SaveOnly' : 'SendAndSaveCopy')
|
32
|
+
structure[:send_meeting_invitations] = 'SendToNone'
|
33
|
+
|
34
|
+
if self.saved_item_folder_id
|
35
|
+
if self.saved_item_folder_id.kind_of?(Hash)
|
36
|
+
structure[:saved_item_folder_id] = saved_item_folder_id
|
37
|
+
else
|
38
|
+
structure[:saved_item_folder_id] = {id: saved_item_folder_id}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
structure[:items] = [{calendar_item: to_ews_item}]
|
43
|
+
structure
|
44
|
+
end
|
45
|
+
|
46
|
+
# EWS Item hash
|
47
|
+
#
|
48
|
+
# Puts all known parameters in the required ordering and structure
|
49
|
+
# @return [Hash]
|
50
|
+
def to_ews_item
|
51
|
+
item_parameters = {}
|
52
|
+
PARAMETERS.each do |key|
|
53
|
+
if !(value = self.send(key)).nil?
|
54
|
+
|
55
|
+
# Convert non duplicable values to String
|
56
|
+
case value
|
57
|
+
when NilClass, FalseClass, TrueClass, Symbol, Numeric
|
58
|
+
value = value.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
# Convert attributes
|
62
|
+
case key
|
63
|
+
when :start, :end
|
64
|
+
item_parameters[key] = {text: value.respond_to?(:iso8601) ? value.iso8601 : value}
|
65
|
+
when :body
|
66
|
+
item_parameters[key] = {body_type: self.body_type || 'Text', text: value.to_s}
|
67
|
+
else
|
68
|
+
item_parameters[key] = value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
item_parameters
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Viewpoint::EWS
|
2
|
+
module Template
|
3
|
+
class ForwardItem < Message
|
4
|
+
|
5
|
+
# Format this object for EWS backend consumption.
|
6
|
+
def to_ews
|
7
|
+
ews_opts, msg = to_ews_basic
|
8
|
+
msg[:reference_item_id] = reference_item_id
|
9
|
+
msg[:new_body_content] = {text: new_body_content, body_type: new_body_type}
|
10
|
+
ews_opts.merge({items: [{forward_item: msg}]})
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
|
16
|
+
def init_defaults!
|
17
|
+
super
|
18
|
+
self.new_body_content ||= ''
|
19
|
+
self.new_body_type ||= 'Text'
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|