viewpoint 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/lib/ews/calendar_accessors.rb +37 -33
- data/lib/ews/connection.rb +152 -125
- data/lib/ews/connection_helper.rb +36 -33
- data/lib/ews/convert_accessors.rb +58 -54
- data/lib/ews/errors.rb +59 -53
- data/lib/ews/ews_client.rb +92 -79
- data/lib/ews/exceptions/exceptions.rb +61 -61
- data/lib/ews/folder_accessors.rb +235 -234
- data/lib/ews/impersonation.rb +29 -23
- data/lib/ews/item_accessors.rb +215 -213
- data/lib/ews/mailbox_accessors.rb +82 -79
- data/lib/ews/meeting_accessors.rb +38 -31
- data/lib/ews/message_accessors.rb +83 -81
- data/lib/ews/push_subscription_accessors.rb +29 -27
- data/lib/ews/room_accessors.rb +48 -46
- data/lib/ews/roomlist_accessors.rb +47 -45
- data/lib/ews/soap/builders/ews_builder.rb +1191 -1176
- data/lib/ews/soap/ews_response.rb +68 -73
- data/lib/ews/soap/ews_soap_availability_response.rb +57 -57
- data/lib/ews/soap/ews_soap_free_busy_response.rb +115 -117
- data/lib/ews/soap/ews_soap_response.rb +99 -101
- data/lib/ews/soap/ews_soap_room_response.rb +45 -45
- data/lib/ews/soap/ews_soap_roomlist_response.rb +45 -46
- data/lib/ews/soap/exchange_availability.rb +54 -52
- data/lib/ews/soap/exchange_data_services.rb +693 -711
- data/lib/ews/soap/exchange_notification.rb +123 -128
- data/lib/ews/soap/exchange_synchronization.rb +82 -82
- data/lib/ews/soap/exchange_time_zones.rb +41 -44
- data/lib/ews/soap/exchange_user_configuration.rb +30 -27
- data/lib/ews/soap/exchange_web_service.rb +237 -233
- data/lib/ews/soap/parsers/ews_parser.rb +46 -42
- data/lib/ews/soap/parsers/ews_sax_document.rb +63 -58
- data/lib/ews/soap/response_message.rb +69 -68
- data/lib/ews/soap/responses/create_attachment_response_message.rb +45 -45
- data/lib/ews/soap/responses/create_item_response_message.rb +26 -25
- data/lib/ews/soap/responses/find_item_response_message.rb +76 -78
- data/lib/ews/soap/responses/get_events_response_message.rb +52 -51
- data/lib/ews/soap/responses/send_notification_response_message.rb +53 -51
- data/lib/ews/soap/responses/subscribe_response_message.rb +37 -34
- data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +38 -35
- data/lib/ews/soap/responses/sync_folder_items_response_message.rb +38 -35
- data/lib/ews/soap.rb +27 -26
- data/lib/ews/templates/calendar_item.rb +64 -60
- data/lib/ews/templates/forward_item.rb +19 -17
- data/lib/ews/templates/message.rb +61 -58
- data/lib/ews/templates/reply_to_item.rb +20 -18
- data/lib/ews/templates/task.rb +55 -55
- data/lib/ews/types/attachment.rb +75 -74
- data/lib/ews/types/attendee.rb +27 -25
- data/lib/ews/types/calendar_folder.rb +58 -59
- data/lib/ews/types/calendar_item.rb +133 -131
- data/lib/ews/types/contact.rb +11 -5
- data/lib/ews/types/contacts_folder.rb +10 -5
- data/lib/ews/types/copied_event.rb +47 -48
- data/lib/ews/types/created_event.rb +22 -20
- data/lib/ews/types/deleted_event.rb +22 -20
- data/lib/ews/types/distribution_list.rb +11 -5
- data/lib/ews/types/event.rb +60 -59
- data/lib/ews/types/export_items_response_message.rb +54 -50
- data/lib/ews/types/file_attachment.rb +63 -61
- data/lib/ews/types/folder.rb +58 -57
- data/lib/ews/types/free_busy_changed_event.rb +22 -20
- data/lib/ews/types/generic_folder.rb +348 -372
- data/lib/ews/types/item.rb +401 -397
- data/lib/ews/types/item_attachment.rb +87 -80
- data/lib/ews/types/item_field_uri_map.rb +201 -200
- data/lib/ews/types/mailbox_user.rb +146 -154
- data/lib/ews/types/meeting_cancellation.rb +11 -5
- data/lib/ews/types/meeting_message.rb +11 -5
- data/lib/ews/types/meeting_request.rb +11 -5
- data/lib/ews/types/meeting_response.rb +11 -5
- data/lib/ews/types/message.rb +11 -5
- data/lib/ews/types/modified_event.rb +43 -45
- data/lib/ews/types/moved_event.rb +47 -48
- data/lib/ews/types/new_mail_event.rb +22 -20
- data/lib/ews/types/out_of_office.rb +145 -144
- data/lib/ews/types/post_item.rb +11 -5
- data/lib/ews/types/search_folder.rb +10 -5
- data/lib/ews/types/status_event.rb +37 -36
- data/lib/ews/types/task.rb +39 -33
- data/lib/ews/types/tasks_folder.rb +31 -25
- data/lib/ews/types.rb +134 -139
- data/lib/viewpoint/logging/config.rb +19 -19
- data/lib/viewpoint/logging.rb +23 -17
- data/lib/viewpoint/string_utils.rb +31 -32
- data/lib/viewpoint.rb +18 -18
- metadata +50 -25
- data/Changelog.txt +0 -1004
|
@@ -1,147 +1,148 @@
|
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
+
OOF_KEY_PATHS = {
|
|
23
|
+
enabled?: %i[oof_settings oof_state],
|
|
24
|
+
scheduled?: %i[oof_settings oof_state],
|
|
25
|
+
duration: %i[oof_settings duration]
|
|
26
|
+
}.freeze
|
|
27
|
+
|
|
28
|
+
OOF_KEY_TYPES = {
|
|
29
|
+
enabled?: ->(str) { str == :enabled },
|
|
30
|
+
scheduled?: ->(str) { str == :scheduled },
|
|
31
|
+
duration: ->(hsh) { hsh[:start_time]..hsh[:end_time] }
|
|
32
|
+
}.freeze
|
|
33
|
+
|
|
34
|
+
OOF_KEY_ALIAS = {}.freeze
|
|
35
|
+
|
|
36
|
+
# This represents OutOfOffice settings
|
|
37
|
+
# @see http://msdn.microsoft.com/en-us/library/aa563465.aspx
|
|
38
|
+
class OutOfOffice
|
|
39
|
+
include Viewpoint::EWS
|
|
40
|
+
include Viewpoint::EWS::Types
|
|
41
|
+
|
|
42
|
+
attr_reader :user
|
|
43
|
+
|
|
44
|
+
# @param [MailboxUser] user
|
|
45
|
+
# @param [Hash] ews_item
|
|
46
|
+
def initialize(user, ews_item)
|
|
47
|
+
@ews = user.ews
|
|
48
|
+
@user = user
|
|
49
|
+
@ews_item = ews_item
|
|
50
|
+
@changed = false
|
|
51
|
+
simplify!
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def changed?
|
|
55
|
+
@changed
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def save!
|
|
59
|
+
return true unless changed?
|
|
60
|
+
|
|
61
|
+
opts = { mailbox: { address: user.email_address } }.merge(@ews_item[:oof_settings])
|
|
62
|
+
resp = @ews.set_user_oof_settings(opts)
|
|
63
|
+
raise SaveFailed, "Could not save #{self.class}. #{resp.code}: #{resp.message}" unless resp.success?
|
|
64
|
+
|
|
65
|
+
@changed = false
|
|
66
|
+
true
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def enable
|
|
70
|
+
return true if enabled?
|
|
71
|
+
|
|
72
|
+
@changed = true
|
|
73
|
+
@ews_item[:oof_settings][:oof_state] = :enabled
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def disable
|
|
77
|
+
return true unless enabled? || scheduled?
|
|
78
|
+
|
|
79
|
+
@changed = true
|
|
80
|
+
@ews_item[:oof_settings][:oof_state] = :disabled
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Schedule an out of office.
|
|
84
|
+
# @param [DateTime] start_time
|
|
85
|
+
# @param [DateTime] end_time
|
|
86
|
+
def schedule(start_time, end_time)
|
|
87
|
+
@changed = true
|
|
88
|
+
@ews_item[:oof_settings][:oof_state] = :scheduled
|
|
89
|
+
set_duration start_time, end_time
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Specify a duration for this Out Of Office setting
|
|
93
|
+
# @param [DateTime] start_time
|
|
94
|
+
# @param [DateTime] end_time
|
|
95
|
+
def set_duration(start_time, end_time)
|
|
96
|
+
@changed = true
|
|
97
|
+
@ews_item[:oof_settings][:duration][:start_time] = start_time
|
|
98
|
+
@ews_item[:oof_settings][:duration][:end_time] = end_time
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# A message to send to internal users
|
|
102
|
+
# @param [String] message
|
|
103
|
+
def internal_reply=(message)
|
|
104
|
+
@changed = true
|
|
105
|
+
@ews_item[:oof_settings][:internal_reply] = message
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# A message to send to external users
|
|
109
|
+
# @param [String] message
|
|
110
|
+
def external_reply=(message)
|
|
111
|
+
@changed = true
|
|
112
|
+
@ews_item[:oof_settings][:external_reply] = message
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
def key_paths
|
|
118
|
+
@key_paths ||= super.merge(OOF_KEY_PATHS)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def key_types
|
|
122
|
+
@key_types ||= super.merge(OOF_KEY_TYPES)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def key_alias
|
|
126
|
+
@key_alias ||= super.merge(OOF_KEY_ALIAS)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def simplify!
|
|
130
|
+
oof_settings = @ews_item[:oof_settings][:elems].inject(:merge)
|
|
131
|
+
oof_settings[:oof_state] = oof_settings[:oof_state][:text].downcase.to_sym
|
|
132
|
+
oof_settings[:external_audience] = oof_settings[:external_audience][:text]
|
|
133
|
+
if oof_settings[:duration]
|
|
134
|
+
dur = oof_settings[:duration][:elems].inject(:merge)
|
|
135
|
+
oof_settings[:duration] = {
|
|
136
|
+
start_time: DateTime.iso8601(dur[:start_time][:text]),
|
|
137
|
+
end_time: DateTime.iso8601(dur[:end_time][:text])
|
|
138
|
+
}
|
|
139
|
+
end
|
|
140
|
+
oof_settings[:internal_reply] = oof_settings[:internal_reply][:elems][0][:message][:text] || ''
|
|
141
|
+
oof_settings[:external_reply] = oof_settings[:external_reply][:elems][0][:message][:text] || ''
|
|
142
|
+
@ews_item[:oof_settings] = oof_settings
|
|
143
|
+
@ews_item[:allow_external_oof] = @ews_item[:allow_external_oof][:text]
|
|
144
|
+
end
|
|
66
145
|
end
|
|
67
146
|
end
|
|
68
|
-
|
|
69
|
-
def enable
|
|
70
|
-
return true if enabled?
|
|
71
|
-
@changed = true
|
|
72
|
-
@ews_item[:oof_settings][:oof_state] = :enabled
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def disable
|
|
76
|
-
return true unless enabled? || scheduled?
|
|
77
|
-
@changed = true
|
|
78
|
-
@ews_item[:oof_settings][:oof_state] = :disabled
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Schedule an out of office.
|
|
82
|
-
# @param [DateTime] start_time
|
|
83
|
-
# @param [DateTime] end_time
|
|
84
|
-
def schedule(start_time, end_time)
|
|
85
|
-
@changed = true
|
|
86
|
-
@ews_item[:oof_settings][:oof_state] = :scheduled
|
|
87
|
-
set_duration start_time, end_time
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Specify a duration for this Out Of Office setting
|
|
91
|
-
# @param [DateTime] start_time
|
|
92
|
-
# @param [DateTime] end_time
|
|
93
|
-
def set_duration(start_time, end_time)
|
|
94
|
-
@changed = true
|
|
95
|
-
@ews_item[:oof_settings][:duration][:start_time] = start_time
|
|
96
|
-
@ews_item[:oof_settings][:duration][:end_time] = end_time
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# A message to send to internal users
|
|
100
|
-
# @param [String] message
|
|
101
|
-
def internal_reply=(message)
|
|
102
|
-
@changed = true
|
|
103
|
-
@ews_item[:oof_settings][:internal_reply] = message
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
# A message to send to external users
|
|
107
|
-
# @param [String] message
|
|
108
|
-
def external_reply=(message)
|
|
109
|
-
@changed = true
|
|
110
|
-
@ews_item[:oof_settings][:external_reply] = message
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
private
|
|
115
|
-
|
|
116
|
-
def key_paths
|
|
117
|
-
@key_paths ||= super.merge(OOF_KEY_PATHS)
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def key_types
|
|
121
|
-
@key_types ||= super.merge(OOF_KEY_TYPES)
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def key_alias
|
|
125
|
-
@key_alias ||= super.merge(OOF_KEY_ALIAS)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def simplify!
|
|
129
|
-
oof_settings = @ews_item[:oof_settings][:elems].inject(:merge)
|
|
130
|
-
oof_settings[:oof_state] = oof_settings[:oof_state][:text].downcase.to_sym
|
|
131
|
-
oof_settings[:external_audience] = oof_settings[:external_audience][:text]
|
|
132
|
-
if oof_settings[:duration]
|
|
133
|
-
dur = oof_settings[:duration][:elems].inject(:merge)
|
|
134
|
-
oof_settings[:duration] = {
|
|
135
|
-
start_time: DateTime.iso8601(dur[:start_time][:text]),
|
|
136
|
-
end_time: DateTime.iso8601(dur[:end_time][:text])
|
|
137
|
-
}
|
|
138
|
-
end
|
|
139
|
-
oof_settings[:internal_reply] = oof_settings[:internal_reply][:elems][0][:message][:text] || ""
|
|
140
|
-
oof_settings[:external_reply] = oof_settings[:external_reply][:elems][0][:message][:text] || ""
|
|
141
|
-
@ews_item[:oof_settings] = oof_settings
|
|
142
|
-
@ews_item[:allow_external_oof] = @ews_item[:allow_external_oof][:text]
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
end #OutOfOffice
|
|
146
|
-
|
|
147
|
+
end
|
|
147
148
|
end
|
data/lib/ews/types/post_item.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 PostItem
|
|
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
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
class SearchFolder
|
|
3
|
-
include Viewpoint::EWS
|
|
4
|
-
include Viewpoint::EWS::Types
|
|
5
|
-
include Viewpoint::EWS::Types::GenericFolder
|
|
1
|
+
# frozen_string_literal: true
|
|
6
2
|
|
|
3
|
+
module Viewpoint
|
|
4
|
+
module EWS
|
|
5
|
+
module Types
|
|
6
|
+
class SearchFolder
|
|
7
|
+
include Viewpoint::EWS
|
|
8
|
+
include Viewpoint::EWS::Types
|
|
9
|
+
include Viewpoint::EWS::Types::GenericFolder
|
|
10
|
+
end
|
|
11
|
+
end
|
|
7
12
|
end
|
|
8
13
|
end
|
|
@@ -1,39 +1,40 @@
|
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
# Status Event EWS data type.
|
|
23
|
+
class StatusEvent
|
|
24
|
+
include Viewpoint::EWS
|
|
25
|
+
include Viewpoint::EWS::Types
|
|
26
|
+
include Viewpoint::EWS::Types::Item
|
|
27
|
+
|
|
28
|
+
STATUS_EVENT_KEY_PATHS = {
|
|
29
|
+
watermark: %i[watermark text]
|
|
30
|
+
}.freeze
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def key_paths
|
|
35
|
+
@key_paths ||= STATUS_EVENT_KEY_PATHS
|
|
36
|
+
end
|
|
37
|
+
end
|
|
36
38
|
end
|
|
37
|
-
|
|
38
39
|
end
|
|
39
40
|
end
|
data/lib/ews/types/task.rb
CHANGED
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
class Task
|
|
3
|
-
include Viewpoint::EWS
|
|
4
|
-
include Viewpoint::EWS::Types
|
|
5
|
-
include Viewpoint::EWS::Types::Item
|
|
6
|
-
|
|
7
|
-
TASK_KEY_PATHS = {
|
|
8
|
-
complete?: [:is_complete, :text],
|
|
9
|
-
recurring?: [:is_recurring, :text],
|
|
10
|
-
start_date: [:start_date, :text],
|
|
11
|
-
due_date: [:end_date, :text],
|
|
12
|
-
reminder_due_by: [:reminder_due_by, :text],
|
|
13
|
-
reminder?: [:reminder_is_set, :text],
|
|
14
|
-
percent_complete: [:percent_complete, :text],
|
|
15
|
-
status: [:status, :text],
|
|
16
|
-
}
|
|
1
|
+
# frozen_string_literal: true
|
|
17
2
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
module Viewpoint
|
|
4
|
+
module EWS
|
|
5
|
+
module Types
|
|
6
|
+
# Task EWS data type.
|
|
7
|
+
class Task
|
|
8
|
+
include Viewpoint::EWS
|
|
9
|
+
include Viewpoint::EWS::Types
|
|
10
|
+
include Viewpoint::EWS::Types::Item
|
|
25
11
|
|
|
26
|
-
|
|
12
|
+
TASK_KEY_PATHS = {
|
|
13
|
+
complete?: %i[is_complete text],
|
|
14
|
+
recurring?: %i[is_recurring text],
|
|
15
|
+
start_date: %i[start_date text],
|
|
16
|
+
due_date: %i[end_date text],
|
|
17
|
+
reminder_due_by: %i[reminder_due_by text],
|
|
18
|
+
reminder?: %i[reminder_is_set text],
|
|
19
|
+
percent_complete: %i[percent_complete text],
|
|
20
|
+
status: %i[status text]
|
|
21
|
+
}.freeze
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
TASK_KEY_TYPES = {
|
|
24
|
+
recurring?: ->(str) { str.downcase == 'true' },
|
|
25
|
+
complete?: ->(str) { str.downcase == 'true' },
|
|
26
|
+
reminder?: ->(str) { str.downcase == 'true' },
|
|
27
|
+
percent_complete: lambda(&:to_i)
|
|
28
|
+
}.freeze
|
|
29
|
+
TASK_KEY_ALIAS = {}.freeze
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
super.merge(TASK_KEY_TYPES)
|
|
34
|
-
end
|
|
31
|
+
private
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
def key_paths
|
|
34
|
+
super.merge(TASK_KEY_PATHS)
|
|
35
|
+
end
|
|
39
36
|
|
|
37
|
+
def key_types
|
|
38
|
+
super.merge(TASK_KEY_TYPES)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def key_alias
|
|
42
|
+
super.merge(TASK_KEY_ALIAS)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
40
46
|
end
|
|
41
47
|
end
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
class TasksFolder
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
module Viewpoint
|
|
4
|
+
module EWS
|
|
5
|
+
module Types
|
|
6
|
+
# Tasks Folder EWS data type.
|
|
7
|
+
class TasksFolder
|
|
8
|
+
include Viewpoint::EWS
|
|
9
|
+
include Viewpoint::EWS::Types
|
|
10
|
+
include Viewpoint::EWS::Types::GenericFolder
|
|
11
|
+
|
|
12
|
+
# Creates a new task
|
|
13
|
+
# @param attributes [Hash] Parameters of the task. Some example attributes are listed below.
|
|
14
|
+
# @option attributes :subject [String]
|
|
15
|
+
# @option attributes :start_date [Time]
|
|
16
|
+
# @option attributes :due_date [Time]
|
|
17
|
+
# @option attributes :reminder_due_by [Time]
|
|
18
|
+
# @option attributes :reminder_is_set [Boolean]
|
|
19
|
+
# @return [Task]
|
|
20
|
+
# @see Template::Task
|
|
21
|
+
def create_item(attributes)
|
|
22
|
+
template = Viewpoint::EWS::Template::Task.new attributes
|
|
23
|
+
template.saved_item_folder_id = { id: id, change_key: change_key }
|
|
24
|
+
rm = ews.create_item(template.to_ews_create).response_messages.first
|
|
25
|
+
if rm&.success?
|
|
26
|
+
Task.new ews, rm.items.first[:task][:elems].first
|
|
27
|
+
else
|
|
28
|
+
raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" if rm
|
|
29
|
+
|
|
30
|
+
raise EwsCreateItemError, 'Could not create item in folder.'
|
|
31
|
+
|
|
32
|
+
end
|
|
27
33
|
end
|
|
28
34
|
end
|
|
29
35
|
end
|