viewpoint 1.0.0.beta.1 → 1.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 +7 -0
- data/README.md +16 -11
- data/lib/ews/connection.rb +15 -6
- data/lib/ews/convert_accessors.rb +56 -0
- data/lib/ews/errors.rb +56 -0
- data/lib/ews/ews_client.rb +33 -3
- data/lib/ews/exceptions/exceptions.rb +2 -0
- data/lib/ews/folder_accessors.rb +66 -1
- data/lib/ews/impersonation.rb +30 -0
- data/lib/ews/item_accessors.rb +77 -3
- data/lib/ews/mailbox_accessors.rb +6 -1
- data/lib/ews/message_accessors.rb +9 -2
- data/lib/ews/room_accessors.rb +48 -0
- data/lib/ews/roomlist_accessors.rb +47 -0
- data/lib/ews/soap.rb +1 -0
- data/lib/ews/soap/builders/ews_builder.rb +303 -48
- data/lib/ews/soap/ews_response.rb +2 -1
- data/lib/ews/soap/ews_soap_free_busy_response.rb +13 -3
- data/lib/ews/soap/ews_soap_response.rb +1 -1
- 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_data_services.rb +49 -11
- data/lib/ews/soap/exchange_synchronization.rb +93 -0
- data/lib/ews/soap/exchange_time_zones.rb +56 -0
- data/lib/ews/soap/exchange_web_service.rb +36 -66
- data/lib/ews/soap/parsers/ews_sax_document.rb +8 -4
- data/lib/ews/soap/response_message.rb +3 -1
- data/lib/ews/soap/responses/create_attachment_response_message.rb +2 -1
- data/lib/ews/soap/responses/send_notification_response_message.rb +2 -1
- data/lib/{extensions/string.rb → ews/soap/responses/sync_folder_hierarchy_response_message.rb} +18 -17
- data/lib/ews/soap/responses/sync_folder_items_response_message.rb +36 -0
- data/lib/ews/templates/calendar_item.rb +78 -0
- data/lib/ews/templates/message.rb +8 -1
- data/lib/ews/templates/task.rb +74 -0
- data/lib/ews/types.rb +59 -11
- data/lib/ews/types/calendar_folder.rb +42 -0
- data/lib/ews/types/calendar_item.rb +93 -1
- data/lib/ews/types/export_items_response_message.rb +52 -0
- data/lib/ews/types/generic_folder.rb +70 -2
- data/lib/ews/types/item.rb +64 -4
- data/lib/ews/types/item_attachment.rb +41 -3
- data/lib/ews/types/item_field_uri_map.rb +1 -1
- data/lib/ews/types/task.rb +30 -0
- data/lib/ews/types/tasks_folder.rb +19 -0
- data/lib/viewpoint.rb +14 -14
- data/lib/viewpoint/logging.rb +27 -0
- data/lib/viewpoint/logging/config.rb +24 -0
- data/lib/viewpoint/string_utils.rb +76 -0
- metadata +82 -76
@@ -20,6 +20,7 @@ module Viewpoint::EWS::SOAP
|
|
20
20
|
|
21
21
|
# A Generic Class for SOAP returns.
|
22
22
|
class EwsResponse
|
23
|
+
include Viewpoint::StringUtils
|
23
24
|
|
24
25
|
def initialize(sax_hash)
|
25
26
|
@resp = sax_hash
|
@@ -70,7 +71,7 @@ module Viewpoint::EWS::SOAP
|
|
70
71
|
def class_by_name(cname)
|
71
72
|
begin
|
72
73
|
if(cname.instance_of? Symbol)
|
73
|
-
cname = cname
|
74
|
+
cname = camel_case(cname)
|
74
75
|
end
|
75
76
|
Viewpoint::EWS::SOAP.const_get(cname)
|
76
77
|
rescue NameError => e
|
@@ -46,7 +46,8 @@ module Viewpoint::EWS::SOAP
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def calendar_event_array
|
49
|
-
get_user_availability_response[1][:free_busy_view][:elems]
|
49
|
+
result = find_in_hash_list(get_user_availability_response[1][:free_busy_view][:elems], :calendar_event_array)
|
50
|
+
result ? result[:elems] : []
|
50
51
|
end
|
51
52
|
|
52
53
|
def working_hours
|
@@ -54,7 +55,7 @@ module Viewpoint::EWS::SOAP
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def response_message
|
57
|
-
get_user_availability_response
|
58
|
+
find_in_hash_list(get_user_availability_response, :response_message)
|
58
59
|
end
|
59
60
|
|
60
61
|
def response_class
|
@@ -63,7 +64,8 @@ module Viewpoint::EWS::SOAP
|
|
63
64
|
alias :status :response_class
|
64
65
|
|
65
66
|
def response_code
|
66
|
-
response_message[:elems]
|
67
|
+
result = find_in_hash_list(response_message[:elems], :response_code)
|
68
|
+
result ? result[:text] : nil
|
67
69
|
end
|
68
70
|
alias :code :response_code
|
69
71
|
|
@@ -103,6 +105,14 @@ module Viewpoint::EWS::SOAP
|
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
108
|
+
# Find the first element in a list of hashes or return nil
|
109
|
+
# Example:
|
110
|
+
# find_in_hash_list([{:foo => :bar}, {:bar => :baz}], :foo)
|
111
|
+
# => :bar
|
112
|
+
def find_in_hash_list(collection, key)
|
113
|
+
result = collection.find { |hsh| hsh.keys.include?(key) }
|
114
|
+
result ? result[key] : nil
|
115
|
+
end
|
106
116
|
|
107
117
|
end # EwsSoapFreeBusyResponse
|
108
118
|
|
@@ -45,7 +45,7 @@ module Viewpoint::EWS::SOAP
|
|
45
45
|
|
46
46
|
def response_messages
|
47
47
|
key = response.keys.first
|
48
|
-
response[key][:elems][
|
48
|
+
response[key][:elems].find{|e| e.keys.include? :response_messages }[:response_messages][:elems]
|
49
49
|
end
|
50
50
|
|
51
51
|
def response_message
|
@@ -0,0 +1,53 @@
|
|
1
|
+
=begin
|
2
|
+
This file is a contribution to Viewpoint; the Ruby library for Microsoft Exchange Web Services.
|
3
|
+
|
4
|
+
Copyright © 2013 Camille Baldock <viewpoint@camillebaldock.co.uk>
|
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
|
+
# A class for roomlists SOAP returns.
|
22
|
+
# @attr_reader [String] :message The text from the EWS element <m:ResponseCode>
|
23
|
+
class EwsSoapRoomResponse < EwsSoapResponse
|
24
|
+
|
25
|
+
def response_messages
|
26
|
+
key = response.keys.first
|
27
|
+
subresponse = response[key][:elems][1]
|
28
|
+
response_class = subresponse.keys.first
|
29
|
+
subresponse[response_class][:elems]
|
30
|
+
end
|
31
|
+
|
32
|
+
def roomsArray
|
33
|
+
response[:get_rooms_response][:elems][1][:rooms][:elems]
|
34
|
+
end
|
35
|
+
|
36
|
+
def success?
|
37
|
+
response.first[1][:attribs][:response_class] == "Success"
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def simplify!
|
43
|
+
if response_messages
|
44
|
+
response_messages.each do |rm|
|
45
|
+
key = rm.keys.first
|
46
|
+
rm[key][:elems] = rm[key][:elems].inject(&:merge)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end # EwsSoapRoomResponse
|
52
|
+
|
53
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,54 @@
|
|
1
|
+
=begin
|
2
|
+
This file is a contribution to Viewpoint; the Ruby library for Microsoft Exchange Web Services.
|
3
|
+
|
4
|
+
Copyright © 2013 Camille Baldock <viewpoint@camillebaldock.co.uk>
|
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
|
+
# A class for roomlists SOAP returns.
|
22
|
+
# @attr_reader [String] :message The text from the EWS element <m:ResponseCode>
|
23
|
+
class EwsSoapRoomlistResponse < EwsSoapResponse
|
24
|
+
|
25
|
+
def response_messages
|
26
|
+
key = response.keys.first
|
27
|
+
subresponse = response[key][:elems][1]
|
28
|
+
response_class = subresponse.keys.first
|
29
|
+
subresponse[response_class][:elems]
|
30
|
+
end
|
31
|
+
|
32
|
+
def roomListsArray
|
33
|
+
response[:get_room_lists_response][:elems][1][:room_lists][:elems]
|
34
|
+
end
|
35
|
+
|
36
|
+
def success?
|
37
|
+
response.first[1][:attribs][:response_class] == "Success"
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
|
43
|
+
def simplify!
|
44
|
+
if response_messages
|
45
|
+
response_messages.each do |rm|
|
46
|
+
key = rm.keys.first
|
47
|
+
rm[key][:elems] = rm[key][:elems].inject(&:merge)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end # EwsSoapRoomlistResponse
|
53
|
+
|
54
|
+
end # Viewpoint::EWS::SOAP
|
@@ -37,9 +37,10 @@ module Viewpoint::EWS::SOAP
|
|
37
37
|
req = build_soap! do |type, builder|
|
38
38
|
if(type == :header)
|
39
39
|
else
|
40
|
-
builder.nbuild.FindItem(:Traversal => opts[:traversal]
|
40
|
+
builder.nbuild.FindItem(:Traversal => camel_case(opts[:traversal])) {
|
41
41
|
builder.nbuild.parent.default_namespace = @default_ns
|
42
42
|
builder.item_shape!(opts[:item_shape])
|
43
|
+
builder.indexed_page_item_view!(opts[:indexed_page_item_view]) if opts[:indexed_page_item_view]
|
43
44
|
# @todo add FractionalPageFolderView
|
44
45
|
builder.calendar_view!(opts[:calendar_view]) if opts[:calendar_view]
|
45
46
|
builder.contacts_view!(opts[:contacts_view]) if opts[:contacts_view]
|
@@ -137,11 +138,11 @@ module Viewpoint::EWS::SOAP
|
|
137
138
|
builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
|
138
139
|
builder.nbuild.Items {
|
139
140
|
opts[:items].each {|i|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
141
|
+
# The key can be any number of item types like :message,
|
142
|
+
# :calendar, etc
|
143
|
+
ikey = i.keys.first
|
144
|
+
builder.send("#{ikey}!",i[ikey])
|
145
|
+
}
|
145
146
|
}
|
146
147
|
}
|
147
148
|
end
|
@@ -364,6 +365,26 @@ module Viewpoint::EWS::SOAP
|
|
364
365
|
do_soap_request(req, response_class: EwsResponse)
|
365
366
|
end
|
366
367
|
|
368
|
+
# Export items as a base64 string
|
369
|
+
# @see http://msdn.microsoft.com/en-us/library/ff709503(v=exchg.140).aspx
|
370
|
+
#
|
371
|
+
# (Requires Exchange version equal or newer than VERSION 2010 SP 1)
|
372
|
+
#
|
373
|
+
# @param ids [Array] array of item ids. Can also be a single id value
|
374
|
+
def export_items(ids)
|
375
|
+
validate_version(VERSION_2010_SP1)
|
376
|
+
ids = ids.clone
|
377
|
+
[:item_ids].each do |k|
|
378
|
+
validate_param(ids, k, true)
|
379
|
+
end
|
380
|
+
req = build_soap! do |type, builder|
|
381
|
+
if(type == :header)
|
382
|
+
else
|
383
|
+
builder.export_item_ids!(ids[:item_ids])
|
384
|
+
end
|
385
|
+
end
|
386
|
+
do_soap_request(req, response_class: EwsResponse)
|
387
|
+
end
|
367
388
|
|
368
389
|
# ------------- Folder Operations ------------
|
369
390
|
|
@@ -471,7 +492,7 @@ module Viewpoint::EWS::SOAP
|
|
471
492
|
req = build_soap! do |type, builder|
|
472
493
|
if(type == :header)
|
473
494
|
else
|
474
|
-
builder.nbuild.FindFolder(:Traversal => opts[:traversal]
|
495
|
+
builder.nbuild.FindFolder(:Traversal => camel_case(opts[:traversal])) {
|
475
496
|
builder.nbuild.parent.default_namespace = @default_ns
|
476
497
|
builder.folder_shape!(opts[:folder_shape])
|
477
498
|
builder.restriction!(opts[:restriction]) if opts[:restriction]
|
@@ -580,7 +601,7 @@ module Viewpoint::EWS::SOAP
|
|
580
601
|
validate_version(VERSION_2010_SP1)
|
581
602
|
ef_opts = {}
|
582
603
|
[:delete_type, :delete_sub_folders].each do |k|
|
583
|
-
ef_opts[k
|
604
|
+
ef_opts[camel_case(k)] = validate_param(opts, k, true)
|
584
605
|
end
|
585
606
|
fids = validate_param opts, :folder_ids, true
|
586
607
|
|
@@ -654,6 +675,9 @@ module Viewpoint::EWS::SOAP
|
|
654
675
|
opts[:items].each do |ia|
|
655
676
|
builder.item_attachment!(ia)
|
656
677
|
end
|
678
|
+
opts[:inline_files].each do |fi|
|
679
|
+
builder.inline_attachment!(fi)
|
680
|
+
end
|
657
681
|
}
|
658
682
|
}
|
659
683
|
end
|
@@ -728,14 +752,28 @@ module Viewpoint::EWS::SOAP
|
|
728
752
|
# @todo Needs to be finished
|
729
753
|
def convert_id(opts)
|
730
754
|
opts = opts.clone
|
755
|
+
|
756
|
+
[:id, :format, :destination_format, :mailbox ].each do |k|
|
757
|
+
validate_param(opts, k, true)
|
758
|
+
end
|
759
|
+
|
731
760
|
req = build_soap! do |type, builder|
|
732
761
|
if(type == :header)
|
733
762
|
else
|
734
|
-
|
735
|
-
|
763
|
+
builder.nbuild.ConvertId {|x|
|
764
|
+
builder.nbuild.parent.default_namespace = @default_ns
|
765
|
+
x.parent['DestinationFormat'] = opts[:destination_format].to_s.camel_case
|
766
|
+
x.SourceIds { |x|
|
767
|
+
x[NS_EWS_TYPES].AlternateId { |x|
|
768
|
+
x.parent['Format'] = opts[:format].to_s.camel_case
|
769
|
+
x.parent['Id'] = opts[:id]
|
770
|
+
x.parent['Mailbox'] = opts[:mailbox]
|
771
|
+
}
|
772
|
+
}
|
773
|
+
}
|
736
774
|
end
|
737
775
|
end
|
738
|
-
do_soap_request(req)
|
776
|
+
do_soap_request(req, response_class: EwsResponse)
|
739
777
|
end
|
740
778
|
|
741
779
|
end #ExchangeDataServices
|
@@ -0,0 +1,93 @@
|
|
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
|
+
# Exchange Synchronization operations as listed in the EWS Documentation.
|
22
|
+
# @see http://msdn.microsoft.com/en-us/library/bb409286.aspx
|
23
|
+
module ExchangeSynchronization
|
24
|
+
include Viewpoint::EWS::SOAP
|
25
|
+
|
26
|
+
# Defines a request to synchronize a folder hierarchy on a client
|
27
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580990.aspx
|
28
|
+
# @param [Hash] opts
|
29
|
+
# @option opts [Hash] :folder_shape The folder shape properties
|
30
|
+
# Ex: {:base_shape => 'Default', :additional_properties => 'bla bla bla'}
|
31
|
+
# @option opts [Hash] :sync_folder_id An optional Hash that represents a FolderId or
|
32
|
+
# DistinguishedFolderId.
|
33
|
+
# Ex: {:id => :inbox}
|
34
|
+
# @option opts [Hash] :sync_state The Base64 sync state id. If this is the
|
35
|
+
# first time syncing this does not need to be passed.
|
36
|
+
def sync_folder_hierarchy(opts)
|
37
|
+
opts = opts.clone
|
38
|
+
req = build_soap! do |type, builder|
|
39
|
+
if(type == :header)
|
40
|
+
else
|
41
|
+
builder.nbuild.SyncFolderHierarchy {
|
42
|
+
builder.nbuild.parent.default_namespace = @default_ns
|
43
|
+
builder.folder_shape!(opts[:folder_shape])
|
44
|
+
builder.sync_folder_id!(opts[:sync_folder_id]) if opts[:sync_folder_id]
|
45
|
+
builder.sync_state!(opts[:sync_state]) if opts[:sync_state]
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
do_soap_request(req, response_class: EwsResponse)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Synchronizes items between the Exchange server and the client
|
53
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563967(v=EXCHG.140).aspx
|
54
|
+
# @param [Hash] opts
|
55
|
+
# @option opts [Hash] :item_shape The item shape properties
|
56
|
+
# Ex: {:base_shape => 'Default', :additional_properties => 'bla bla bla'}
|
57
|
+
# @option opts [Hash] :sync_folder_id A Hash that represents a FolderId or
|
58
|
+
# DistinguishedFolderId. [ Ex: {:id => :inbox} ] OPTIONAL
|
59
|
+
# @option opts [String] :sync_state The Base64 sync state id. If this is the
|
60
|
+
# first time syncing this does not need to be passed. OPTIONAL on first call
|
61
|
+
# @option opts [Array <String>] :ignore An Array of ItemIds for items to ignore
|
62
|
+
# during the sync process. Ex: [{:id => 'id1', :change_key => 'ck'}, {:id => 'id2'}]
|
63
|
+
# OPTIONAL
|
64
|
+
# @option opts [Integer] :max_changes_returned ('required') The amount of items to sync per call.
|
65
|
+
# @option opts [String] :sync_scope specifies whether just items or items and folder associated
|
66
|
+
# information are returned. OPTIONAL
|
67
|
+
# options: 'NormalItems' or 'NormalAndAssociatedItems'
|
68
|
+
# @example
|
69
|
+
# { :item_shape => {:base_shape => 'Default'},
|
70
|
+
# :sync_folder_id => {:id => :inbox},
|
71
|
+
# :sync_state => myBase64id,
|
72
|
+
# :max_changes_returned => 256 }
|
73
|
+
def sync_folder_items(opts)
|
74
|
+
opts = opts.clone
|
75
|
+
req = build_soap! do |type, builder|
|
76
|
+
if(type == :header)
|
77
|
+
else
|
78
|
+
builder.nbuild.SyncFolderItems {
|
79
|
+
builder.nbuild.parent.default_namespace = @default_ns
|
80
|
+
builder.item_shape!(opts[:item_shape])
|
81
|
+
builder.sync_folder_id!(opts[:sync_folder_id]) if opts[:sync_folder_id]
|
82
|
+
builder.sync_state!(opts[:sync_state]) if opts[:sync_state]
|
83
|
+
builder.ignore!(opts[:ignore]) if opts[:ignore]
|
84
|
+
builder.max_changes_returned!(opts[:max_changes_returned])
|
85
|
+
builder.sync_scope!(opts[:sync_scope]) if opts[:sync_scope]
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
do_soap_request(req, response_class: EwsResponse)
|
90
|
+
end
|
91
|
+
|
92
|
+
end #ExchangeSynchronization
|
93
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Viewpoint::EWS::SOAP
|
2
|
+
|
3
|
+
module ExchangeTimeZones
|
4
|
+
include Viewpoint::EWS::SOAP
|
5
|
+
|
6
|
+
# Request list of server known time zones
|
7
|
+
# @param full [Boolean] Request full time zone definition? Returns only name and id if false.
|
8
|
+
# @param ids [Array] Returns only the specified time zones instead of all if present
|
9
|
+
# @return [Array] Array of Objects responding to #id() and #name()
|
10
|
+
# @example Retrieving server zime zones
|
11
|
+
# ews_client = Viewpoint::EWSClient.new # ...
|
12
|
+
# zones = ews_client.ews.get_time_zones
|
13
|
+
# @todo Implement TimeZoneDefinition with sub elements Periods, TransitionsGroups and Transitions
|
14
|
+
def get_time_zones(full = false, ids = nil)
|
15
|
+
req = build_soap! do |type, builder|
|
16
|
+
unless type == :header
|
17
|
+
builder.get_server_time_zones!(full: full, ids: ids)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
result = do_soap_request req, response_class: EwsSoapResponse
|
21
|
+
|
22
|
+
if result.success?
|
23
|
+
zones = []
|
24
|
+
result.response_messages.each do |message|
|
25
|
+
elements = message[:get_server_time_zones_response_message][:elems][:time_zone_definitions][:elems]
|
26
|
+
elements.each do |definition|
|
27
|
+
data = {
|
28
|
+
id: definition[:time_zone_definition][:attribs][:id],
|
29
|
+
name: definition[:time_zone_definition][:attribs][:name]
|
30
|
+
}
|
31
|
+
zones << OpenStruct.new(data)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
zones
|
35
|
+
else
|
36
|
+
raise EwsError, "Could not get time zones"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Sets the time zone context header
|
41
|
+
# @param id [String] Identifier of a Microsoft well known time zone
|
42
|
+
# @example Set time zone context for connection
|
43
|
+
# ews_client = Viewpoint::EWSClient.new # ...
|
44
|
+
# ews_client.set_time_zone 'AUS Central Standard Time'
|
45
|
+
# # subsequent request will send the TimeZoneContext header
|
46
|
+
# @see EWSClient#set_time_zone
|
47
|
+
def set_time_zone_context(id)
|
48
|
+
if id
|
49
|
+
@time_zone_context = {id: id}
|
50
|
+
else
|
51
|
+
@time_zone_context = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -20,12 +20,15 @@ module Viewpoint::EWS::SOAP
|
|
20
20
|
class ExchangeWebService
|
21
21
|
include Viewpoint::EWS
|
22
22
|
include Viewpoint::EWS::SOAP
|
23
|
+
include Viewpoint::StringUtils
|
23
24
|
include ExchangeDataServices
|
24
25
|
include ExchangeNotification
|
25
26
|
include ExchangeAvailability
|
26
27
|
include ExchangeUserConfiguration
|
28
|
+
include ExchangeSynchronization
|
29
|
+
include ExchangeTimeZones
|
27
30
|
|
28
|
-
attr_accessor :server_version, :auto_deepen, :connection
|
31
|
+
attr_accessor :server_version, :auto_deepen, :no_auto_deepen_behavior, :connection, :impersonation_type, :impersonation_address
|
29
32
|
|
30
33
|
# @param [Viewpoint::EWS::Connection] connection the connection object
|
31
34
|
# @param [Hash] opts additional options to the web service
|
@@ -38,70 +41,9 @@ module Viewpoint::EWS::SOAP
|
|
38
41
|
@connection = connection
|
39
42
|
@server_version = opts[:server_version] ? opts[:server_version] : VERSION_2010
|
40
43
|
@auto_deepen = true
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
# @see http://msdn.microsoft.com/en-us/library/aa580990.aspx
|
45
|
-
# @param [Hash] opts
|
46
|
-
# @option opts [Hash] :folder_shape The folder shape properties
|
47
|
-
# Ex: {:base_shape => 'Default', :additional_properties => 'bla bla bla'}
|
48
|
-
# @option opts [Hash] :sync_folder_id An optional Hash that represents a FolderId or
|
49
|
-
# DistinguishedFolderId.
|
50
|
-
# Ex: {:id => :inbox}
|
51
|
-
# @option opts [Hash] :sync_state The Base64 sync state id. If this is the
|
52
|
-
# first time syncing this does not need to be passed.
|
53
|
-
def sync_folder_hierarchy(opts)
|
54
|
-
req = build_soap! do |type, builder|
|
55
|
-
if(type == :header)
|
56
|
-
else
|
57
|
-
builder.nbuild.SyncFolderHierarchy {
|
58
|
-
builder.nbuild.parent.default_namespace = @default_ns
|
59
|
-
builder.folder_shape!(opts[:folder_shape])
|
60
|
-
builder.sync_folder_id!(opts[:sync_folder_id]) if opts[:sync_folder_id]
|
61
|
-
builder.sync_state!(opts[:sync_state]) if opts[:sync_state]
|
62
|
-
}
|
63
|
-
end
|
64
|
-
end
|
65
|
-
do_soap_request(req)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Synchronizes items between the Exchange server and the client
|
69
|
-
# @see http://msdn.microsoft.com/en-us/library/aa563967(v=EXCHG.140).aspx
|
70
|
-
# @param [Hash] opts
|
71
|
-
# @option opts [Hash] :item_shape The item shape properties
|
72
|
-
# Ex: {:base_shape => 'Default', :additional_properties => 'bla bla bla'}
|
73
|
-
# @option opts [Hash] :sync_folder_id A Hash that represents a FolderId or
|
74
|
-
# DistinguishedFolderId. [ Ex: {:id => :inbox} ] OPTIONAL
|
75
|
-
# @option opts [String] :sync_state The Base64 sync state id. If this is the
|
76
|
-
# first time syncing this does not need to be passed. OPTIONAL on first call
|
77
|
-
# @option opts [Array <String>] :ignore An Array of ItemIds for items to ignore
|
78
|
-
# during the sync process. Ex: [{:id => 'id1', :change_key => 'ck'}, {:id => 'id2'}]
|
79
|
-
# OPTIONAL
|
80
|
-
# @option opts [Integer] :max_changes_returned ('required') The amount of items to sync per call.
|
81
|
-
# @option opts [String] :sync_scope specifies whether just items or items and folder associated
|
82
|
-
# information are returned. OPTIONAL
|
83
|
-
# options: 'NormalItems' or 'NormalAndAssociatedItems'
|
84
|
-
# @example
|
85
|
-
# { :item_shape => {:base_shape => 'Default'},
|
86
|
-
# :sync_folder_id => {:id => :inbox},
|
87
|
-
# :sync_state => myBase64id,
|
88
|
-
# :max_changes_returned => 256 }
|
89
|
-
def sync_folder_items(opts)
|
90
|
-
req = build_soap! do |type, builder|
|
91
|
-
if(type == :header)
|
92
|
-
else
|
93
|
-
builder.nbuild.SyncFolderItems {
|
94
|
-
builder.nbuild.parent.default_namespace = @default_ns
|
95
|
-
builder.item_shape!(opts[:item_shape])
|
96
|
-
builder.sync_folder_id!(opts[:sync_folder_id]) if opts[:sync_folder_id]
|
97
|
-
builder.sync_state!(opts[:sync_state]) if opts[:sync_state]
|
98
|
-
builder.ignore!(opts[:ignore]) if opts[:ignore]
|
99
|
-
builder.max_changes_returned!(opts[:max_changes_returned])
|
100
|
-
builder.sync_scope!(opts[:sync_scope]) if opts[:sync_scope]
|
101
|
-
}
|
102
|
-
end
|
103
|
-
end
|
104
|
-
do_soap_request(req)
|
44
|
+
@no_auto_deepen_behavior = :raise
|
45
|
+
@impersonation_type = ""
|
46
|
+
@impersonation_address = ""
|
105
47
|
end
|
106
48
|
|
107
49
|
def delete_attachment
|
@@ -226,6 +168,33 @@ module Viewpoint::EWS::SOAP
|
|
226
168
|
do_soap_request(req, response_class: EwsSoapFreeBusyResponse)
|
227
169
|
end
|
228
170
|
|
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)
|
181
|
+
}
|
182
|
+
end
|
183
|
+
end
|
184
|
+
do_soap_request(req, response_class: EwsSoapRoomResponse)
|
185
|
+
end
|
186
|
+
|
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!
|
194
|
+
end
|
195
|
+
end
|
196
|
+
do_soap_request(req, response_class: EwsSoapRoomlistResponse)
|
197
|
+
end
|
229
198
|
|
230
199
|
# Send the SOAP request to the endpoint and parse it.
|
231
200
|
# @param [String] soapmsg an XML formatted string
|
@@ -286,7 +255,8 @@ module Viewpoint::EWS::SOAP
|
|
286
255
|
|
287
256
|
# Build the common elements in the SOAP message and yield to any custom elements.
|
288
257
|
def build_soap!(&block)
|
289
|
-
opts = { :server_version => server_version }
|
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
|
290
260
|
EwsBuilder.new.build!(opts, &block)
|
291
261
|
end
|
292
262
|
|