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
data/lib/ews/types/attachment.rb
CHANGED
|
@@ -1,77 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
module Viewpoint
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class
|
|
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
|
-
|
|
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 Types
|
|
22
|
+
# A generic Attachment. This class should not be instantiated directly. You
|
|
23
|
+
# should use one of the subclasses like FileAttachment or ItemAttachment.
|
|
24
|
+
class Attachment
|
|
25
|
+
include Viewpoint::EWS
|
|
26
|
+
include Viewpoint::EWS::Types
|
|
27
|
+
include Viewpoint::EWS::Types::Item
|
|
28
|
+
|
|
29
|
+
ATTACH_KEY_PATHS = {
|
|
30
|
+
id: %i[attachment_id attribs id],
|
|
31
|
+
parent_item_id: %i[attachment_id attribs root_item_id],
|
|
32
|
+
parent_change_key: %i[attachment_id attribs root_item_change_key],
|
|
33
|
+
name: %i[name text],
|
|
34
|
+
content_type: %i[content_type text],
|
|
35
|
+
content_id: [:content_id],
|
|
36
|
+
size: %i[size text],
|
|
37
|
+
last_modified_time: %i[last_modified_time text],
|
|
38
|
+
is_inline?: %i[is_inline text]
|
|
39
|
+
}.freeze
|
|
40
|
+
|
|
41
|
+
ATTACH_KEY_TYPES = {
|
|
42
|
+
is_inline?: ->(str) { str.downcase == 'true' },
|
|
43
|
+
last_modified_type: ->(str) { DateTime.parse(str) },
|
|
44
|
+
size: lambda(&:to_i),
|
|
45
|
+
content_id: :fix_content_id
|
|
46
|
+
}.freeze
|
|
47
|
+
|
|
48
|
+
ATTACH_KEY_ALIAS = {}.freeze
|
|
49
|
+
|
|
50
|
+
# @param [Hash] attachment The attachment ews_item
|
|
51
|
+
def initialize(item, attachment)
|
|
52
|
+
@item = item
|
|
53
|
+
super(item.ews, attachment)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def key_paths
|
|
59
|
+
@key_paths ||= ATTACH_KEY_PATHS
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def key_types
|
|
63
|
+
@key_types ||= ATTACH_KEY_TYPES
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def key_alias
|
|
67
|
+
@key_alias ||= ATTACH_KEY_ALIAS
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Sometimes the SOAP response comes back with two identical content_ids.
|
|
71
|
+
# This method fishes them out no matter which way them come.
|
|
72
|
+
def fix_content_id(content_id)
|
|
73
|
+
content_id.is_a?(Array) ? content_id.last[:text] : content_id[:text]
|
|
74
|
+
end
|
|
75
|
+
end
|
|
52
76
|
end
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
private
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def key_paths
|
|
59
|
-
@key_paths ||= ATTACH_KEY_PATHS
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def key_types
|
|
63
|
-
@key_types ||= ATTACH_KEY_TYPES
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def key_alias
|
|
67
|
-
@key_alias ||= ATTACH_KEY_ALIAS
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Sometimes the SOAP response comes back with two identical content_ids.
|
|
71
|
-
# This method fishes them out no matter which way them come.
|
|
72
|
-
def fix_content_id(content_id)
|
|
73
|
-
content_id.is_a?(Array) ? content_id.last[:text] : content_id[:text]
|
|
74
|
-
end
|
|
75
|
-
|
|
76
77
|
end
|
|
77
78
|
end
|
data/lib/ews/types/attendee.rb
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
=end
|
|
18
|
-
|
|
19
|
-
module Viewpoint::EWS::Types
|
|
20
|
-
|
|
21
|
-
# This represents a Mailbox object in the Exchange data store
|
|
22
|
-
# @see http://msdn.microsoft.com/en-us/library/aa565036.aspx MSDN docs
|
|
23
|
-
# @todo Design a Class method that resolves to an Array of MailboxUsers
|
|
24
|
-
class Attendee < MailboxUser
|
|
25
|
-
end # Attendee
|
|
26
|
-
|
|
27
|
-
end # Viewpoint::EWS::Types
|
|
19
|
+
module Viewpoint
|
|
20
|
+
module EWS
|
|
21
|
+
module Types
|
|
22
|
+
# This represents a Mailbox object in the Exchange data store
|
|
23
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565036.aspx MSDN docs
|
|
24
|
+
# @todo Design a Class method that resolves to an Array of MailboxUsers
|
|
25
|
+
class Attendee < MailboxUser
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,67 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
class CalendarFolder
|
|
3
|
-
include Viewpoint::EWS
|
|
4
|
-
include Viewpoint::EWS::Types
|
|
5
|
-
include Viewpoint::EWS::Types::GenericFolder
|
|
1
|
+
# frozen_string_literal: true
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[
|
|
16
|
-
{:field_uRI => {:field_uRI=>'calendar:Start'}},
|
|
17
|
-
{:field_uRI_or_constant=>{:constant => {:value =>start_date}}}
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
{:is_less_than_or_equal_to =>
|
|
21
|
-
[
|
|
22
|
-
{:field_uRI => {:field_uRI=>'calendar:End'}},
|
|
23
|
-
{:field_uRI_or_constant=>{:constant => {:value =>end_date}}}
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
end
|
|
29
|
-
end
|
|
3
|
+
module Viewpoint
|
|
4
|
+
module EWS
|
|
5
|
+
module Types
|
|
6
|
+
# Calendar Folder EWS data type.
|
|
7
|
+
class CalendarFolder
|
|
8
|
+
include Viewpoint::EWS
|
|
9
|
+
include Viewpoint::EWS::Types
|
|
10
|
+
include Viewpoint::EWS::Types::GenericFolder
|
|
30
11
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
12
|
+
# Fetch items between a given time period
|
|
13
|
+
# @param [DateTime] start_date the time to start fetching Items from
|
|
14
|
+
# @param [DateTime] end_date the time to stop fetching Items from
|
|
15
|
+
def items_between(start_date, end_date, _opts = {})
|
|
16
|
+
items do |obj|
|
|
17
|
+
obj.restriction = { and: [
|
|
18
|
+
{ is_greater_than_or_equal_to: [
|
|
19
|
+
{ field_uRI: { field_uRI: 'calendar:Start' } },
|
|
20
|
+
{ field_uRI_or_constant: { constant: { value: start_date } } }
|
|
21
|
+
] },
|
|
22
|
+
{ is_less_than_or_equal_to: [
|
|
23
|
+
{ field_uRI: { field_uRI: 'calendar:End' } },
|
|
24
|
+
{ field_uRI_or_constant: { constant: { value: end_date } } }
|
|
25
|
+
] }
|
|
26
|
+
] }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
43
29
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
30
|
+
# Fetch items between a given time period using a calendar view.
|
|
31
|
+
# The calendar view will include occurences of recurring calendar items
|
|
32
|
+
# next to the regular single calendar items.
|
|
33
|
+
# @param [DateTime] start_date the time to start fetching Items from
|
|
34
|
+
# @param [DateTime] end_date the time to stop fetching Items from
|
|
35
|
+
# @param opts [Hash]
|
|
36
|
+
# @option opts :max_entries_returned [Integer] the maximum number of entries to return
|
|
37
|
+
def items_between_calendar_view(start_date, end_date, opts = {})
|
|
38
|
+
view_opts = { start_date: start_date, end_date: end_date }
|
|
39
|
+
view_opts[:max_entries_returned] = opts.delete(:max_entries_returned) if opts[:max_entries_returned]
|
|
40
|
+
items(opts.merge(calendar_view: view_opts))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Creates a new appointment
|
|
44
|
+
# @param attributes [Hash] Parameters of the calendar item. Some example attributes are listed below.
|
|
45
|
+
# @option attributes :subject [String]
|
|
46
|
+
# @option attributes :start [Time]
|
|
47
|
+
# @option attributes :end [Time]
|
|
48
|
+
# @return [CalendarItem]
|
|
49
|
+
# @see Template::CalendarItem
|
|
50
|
+
def create_item(attributes, to_ews_create_opts = {})
|
|
51
|
+
template = Viewpoint::EWS::Template::CalendarItem.new attributes
|
|
52
|
+
template.saved_item_folder_id = { id: id, change_key: change_key }
|
|
53
|
+
rm = ews.create_item(template.to_ews_create(to_ews_create_opts)).response_messages.first
|
|
54
|
+
if rm&.success?
|
|
55
|
+
CalendarItem.new ews, rm.items.first[:calendar_item][:elems].first
|
|
56
|
+
else
|
|
57
|
+
raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" if rm
|
|
58
|
+
|
|
59
|
+
raise EwsCreateItemError, 'Could not create item in folder.'
|
|
60
|
+
|
|
61
|
+
end
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
|
-
|
|
66
65
|
end
|
|
67
66
|
end
|
|
@@ -1,146 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
53
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Viewpoint
|
|
4
|
+
module EWS
|
|
5
|
+
module Types
|
|
6
|
+
# Calendar Item EWS data type.
|
|
7
|
+
class CalendarItem
|
|
8
|
+
include Viewpoint::EWS
|
|
9
|
+
include Viewpoint::EWS::Types
|
|
10
|
+
include Viewpoint::EWS::Types::Item
|
|
11
|
+
include Viewpoint::StringUtils
|
|
12
|
+
|
|
13
|
+
CALENDAR_ITEM_KEY_PATHS = {
|
|
14
|
+
recurring?: %i[is_recurring text],
|
|
15
|
+
meeting?: %i[is_meeting text],
|
|
16
|
+
cancelled?: %i[is_cancelled text],
|
|
17
|
+
duration: %i[duration text],
|
|
18
|
+
time_zone: %i[time_zone text],
|
|
19
|
+
start: %i[start text],
|
|
20
|
+
end: %i[end text],
|
|
21
|
+
location: %i[location text],
|
|
22
|
+
all_day?: %i[is_all_day_event text],
|
|
23
|
+
legacy_free_busy_status: %i[legacy_free_busy_status text],
|
|
24
|
+
my_response_type: %i[my_response_type text],
|
|
25
|
+
organizer: [:organizer, :elems, 0, :mailbox, :elems],
|
|
26
|
+
optional_attendees: %i[optional_attendees elems],
|
|
27
|
+
required_attendees: %i[required_attendees elems],
|
|
28
|
+
recurrence: %i[recurrence elems],
|
|
29
|
+
deleted_occurrences: %i[deleted_occurrences elems],
|
|
30
|
+
modified_occurrences: %i[modified_occurrences elems]
|
|
31
|
+
}.freeze
|
|
32
|
+
|
|
33
|
+
CALENDAR_ITEM_KEY_TYPES = {
|
|
34
|
+
start: ->(str) { DateTime.parse(str) },
|
|
35
|
+
end: ->(str) { DateTime.parse(str) },
|
|
36
|
+
recurring?: ->(str) { str.downcase == 'true' },
|
|
37
|
+
meeting?: ->(str) { str.downcase == 'true' },
|
|
38
|
+
cancelled?: ->(str) { str.downcase == 'true' },
|
|
39
|
+
all_day?: ->(str) { str.downcase == 'true' },
|
|
40
|
+
organizer: :build_mailbox_user,
|
|
41
|
+
optional_attendees: :build_attendees_users,
|
|
42
|
+
required_attendees: :build_attendees_users,
|
|
43
|
+
deleted_occurrences: :build_deleted_occurrences,
|
|
44
|
+
modified_occurrences: :build_modified_occurrences
|
|
45
|
+
}.freeze
|
|
46
|
+
CALENDAR_ITEM_KEY_ALIAS = {}.freeze
|
|
47
|
+
|
|
48
|
+
# Delete this calendar item
|
|
49
|
+
# @param deltype [Symbol] The delete type; must be :hard, :soft, or :recycle.
|
|
50
|
+
# By default EWS will do a hard delete of this calendar item. See the=
|
|
51
|
+
# MSDN docs for more info: http://msdn.microsoft.com/en-us/library/aa562961.aspx
|
|
52
|
+
# @param cancel_type [String] 'SendToNone'/'SendOnlyToAll'/'SendToAllAndSaveCopy'
|
|
53
|
+
# Default is 'SendOnlyToAll'
|
|
54
|
+
# @return [Boolean] Whether or not the calendar item was deleted
|
|
55
|
+
def delete!(deltype = :hard, cancel_type = 'SendOnlyToAll', opts = {})
|
|
56
|
+
opts = opts.merge(send_meeting_cancellations: cancel_type)
|
|
57
|
+
super(deltype, opts)
|
|
58
|
+
end
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
60
|
+
# Updates the specified item attributes
|
|
61
|
+
#
|
|
62
|
+
# Uses `SetItemField` if value is present and `DeleteItemField` if value is nil
|
|
63
|
+
# @param updates [Hash] with (:attribute => value)
|
|
64
|
+
# @param options [Hash]
|
|
65
|
+
# @option options :conflict_resolution [String] one of 'NeverOverwrite', 'AutoResolve' (default)
|
|
66
|
+
# or 'AlwaysOverwrite'
|
|
67
|
+
# @option options :send_meeting_invitations_or_cancellations [String] one of 'SendToNone' (default),
|
|
68
|
+
# 'SendOnlyToAll',
|
|
69
|
+
# 'SendOnlyToChanged', 'SendToAllAndSaveCopy' or 'SendToChangedAndSaveCopy'
|
|
70
|
+
# @return [CalendarItem, false]
|
|
71
|
+
# @example Update Subject and Body
|
|
72
|
+
# item = #...
|
|
73
|
+
# item.update_item!(subject: 'New subject', body: 'New Body')
|
|
74
|
+
# @see http://msdn.microsoft.com/en-us/library/exchange/aa580254.aspx
|
|
75
|
+
# @todo AppendToItemField updates not implemented
|
|
76
|
+
def update_item!(updates, options = {})
|
|
77
|
+
item_updates = []
|
|
78
|
+
updates.each do |attribute, value|
|
|
79
|
+
item_field = FIELD_URIS[attribute][:text] if FIELD_URIS.include? attribute
|
|
80
|
+
field = { field_uRI: { field_uRI: item_field } }
|
|
81
|
+
|
|
82
|
+
if value.nil? && item_field
|
|
83
|
+
# Build DeleteItemField Change
|
|
84
|
+
item_updates << { delete_item_field: field }
|
|
85
|
+
elsif item_field
|
|
86
|
+
# Build SetItemField Change
|
|
87
|
+
item = Viewpoint::EWS::Template::CalendarItem.new(attribute => value)
|
|
88
|
+
|
|
89
|
+
# Remap attributes because ews_builder #dispatch_field_item! uses #build_xml!
|
|
90
|
+
item_attributes = item.to_ews_item.map { |name, value|
|
|
91
|
+
if value.is_a? String
|
|
92
|
+
{ name => { text: value } }
|
|
93
|
+
elsif value.is_a? Hash
|
|
94
|
+
node = { name => {} }
|
|
95
|
+
value.each do |attrib_key, attrib_value|
|
|
96
|
+
attrib_key = camel_case(attrib_key) unless attrib_key == :text
|
|
97
|
+
node[name][attrib_key] = attrib_value
|
|
98
|
+
end
|
|
99
|
+
node
|
|
100
|
+
else
|
|
101
|
+
{ name => value }
|
|
102
|
+
end
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
item_updates << { set_item_field: field.merge(calendar_item: { sub_elements: item_attributes }) }
|
|
95
106
|
end
|
|
96
107
|
end
|
|
97
108
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
rm = ews.update_item(data).response_messages.first
|
|
110
|
-
if rm && rm.success?
|
|
111
|
-
self.get_all_properties!
|
|
112
|
-
self
|
|
113
|
-
else
|
|
114
|
-
if rm
|
|
115
|
-
raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.message_text}"
|
|
109
|
+
return unless item_updates.any?
|
|
110
|
+
|
|
111
|
+
data = {}
|
|
112
|
+
data[:conflict_resolution] = options[:conflict_resolution] || 'AutoResolve'
|
|
113
|
+
data[:send_meeting_invitations_or_cancellations] =
|
|
114
|
+
options[:send_meeting_invitations_or_cancellations] || 'SendToNone'
|
|
115
|
+
data[:item_changes] = [{ item_id: item_id, updates: item_updates }]
|
|
116
|
+
rm = ews.update_item(data).response_messages.first
|
|
117
|
+
if rm&.success?
|
|
118
|
+
get_all_properties!
|
|
119
|
+
self
|
|
116
120
|
else
|
|
117
|
-
raise EwsCreateItemError, "Could not update calendar item."
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
+
raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.message_text}" if rm
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def duration_in_seconds
|
|
125
|
-
iso8601_duration_to_seconds(duration)
|
|
126
|
-
end
|
|
123
|
+
raise EwsCreateItemError, 'Could not update calendar item.'
|
|
127
124
|
|
|
125
|
+
end
|
|
126
|
+
end
|
|
128
127
|
|
|
129
|
-
|
|
128
|
+
def duration_in_seconds
|
|
129
|
+
iso8601_duration_to_seconds(duration)
|
|
130
|
+
end
|
|
130
131
|
|
|
132
|
+
private
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
def key_paths
|
|
135
|
+
super.merge(CALENDAR_ITEM_KEY_PATHS)
|
|
136
|
+
end
|
|
135
137
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
def key_types
|
|
139
|
+
super.merge(CALENDAR_ITEM_KEY_TYPES)
|
|
140
|
+
end
|
|
139
141
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
def key_alias
|
|
143
|
+
super.merge(CALENDAR_ITEM_KEY_ALIAS)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
142
146
|
end
|
|
143
|
-
|
|
144
|
-
|
|
145
147
|
end
|
|
146
148
|
end
|
data/lib/ews/types/contact.rb
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Viewpoint
|
|
4
|
+
module EWS
|
|
5
|
+
module Types
|
|
6
|
+
class Contact
|
|
7
|
+
include Viewpoint::EWS
|
|
8
|
+
include Viewpoint::EWS::Types
|
|
9
|
+
include Viewpoint::EWS::Types::Item
|
|
10
|
+
end
|
|
11
|
+
end
|
|
6
12
|
end
|
|
7
13
|
end
|