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,73 @@
|
|
1
|
+
module Viewpoint::EWS
|
2
|
+
module Template
|
3
|
+
class Message < OpenStruct
|
4
|
+
|
5
|
+
def initialize(opts = {})
|
6
|
+
super opts.clone
|
7
|
+
init_defaults!
|
8
|
+
end
|
9
|
+
|
10
|
+
# Format this object for EWS backend consumption.
|
11
|
+
def to_ews
|
12
|
+
ews_opts, msg = to_ews_basic
|
13
|
+
ews_opts.merge({items: [{message: msg}]})
|
14
|
+
end
|
15
|
+
|
16
|
+
def has_attachments?
|
17
|
+
!(file_attachments.empty? && item_attachments.empty? && inline_attachments.empty?)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
|
24
|
+
def init_defaults!
|
25
|
+
self.subject ||= nil
|
26
|
+
self.body ||= nil
|
27
|
+
self.body_type ||= 'Text'
|
28
|
+
self.importance ||= 'Normal'
|
29
|
+
self.draft ||= false
|
30
|
+
self.to_recipients ||= []
|
31
|
+
self.cc_recipients ||= []
|
32
|
+
self.bcc_recipients ||= []
|
33
|
+
self.file_attachments ||= []
|
34
|
+
self.item_attachments ||= []
|
35
|
+
self.inline_attachments ||= []
|
36
|
+
self.extended_properties ||= []
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_ews_basic
|
40
|
+
ews_opts = {}
|
41
|
+
ews_opts[:message_disposition] = (draft ? 'SaveOnly' : 'SendAndSaveCopy')
|
42
|
+
|
43
|
+
if saved_item_folder_id
|
44
|
+
if saved_item_folder_id.kind_of?(Hash)
|
45
|
+
ews_opts[:saved_item_folder_id] = saved_item_folder_id
|
46
|
+
else
|
47
|
+
ews_opts[:saved_item_folder_id] = {id: saved_item_folder_id}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
msg = {}
|
52
|
+
msg[:subject] = subject if subject
|
53
|
+
msg[:body] = {text: body, body_type: body_type} if body
|
54
|
+
|
55
|
+
msg[:importance] = importance if importance
|
56
|
+
|
57
|
+
to_r = to_recipients.collect{|r| {mailbox: {email_address: r}}}
|
58
|
+
msg[:to_recipients] = to_r unless to_r.empty?
|
59
|
+
|
60
|
+
cc_r = cc_recipients.collect{|r| {mailbox: {email_address: r}}}
|
61
|
+
msg[:cc_recipients] = cc_r unless cc_r.empty?
|
62
|
+
|
63
|
+
bcc_r = bcc_recipients.collect{|r| {mailbox: {email_address: r}}}
|
64
|
+
msg[:bcc_recipients] = bcc_r unless bcc_r.empty?
|
65
|
+
|
66
|
+
msg[:extended_properties] = extended_properties unless extended_properties.empty?
|
67
|
+
|
68
|
+
[ews_opts, msg]
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Viewpoint::EWS
|
2
|
+
module Template
|
3
|
+
class ReplyToItem < 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: [{ews_type => 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
|
+
self.ews_type = :reply_to_item
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Viewpoint::EWS
|
2
|
+
module Template
|
3
|
+
# Template for creating Tasks
|
4
|
+
# @see http://msdn.microsoft.com/en-us/library/exchange/aa564765.aspx
|
5
|
+
class Task < 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
|
10
|
+
is_unmodified internet_message_headers date_time_sent date_time_created response_objects
|
11
|
+
reminder_due_by reminder_is_set reminder_minutes_before_start display_cc display_to
|
12
|
+
has_attachments extended_property culture actual_work assigned_time billing_information
|
13
|
+
change_count companies complete_date contacts delegation_state delegator due_date
|
14
|
+
is_assignment_editable is_complete is_recurring is_team_task mileage owner percent_complete
|
15
|
+
recurrence start_date status status_description total_work effective_rights last_modified_name
|
16
|
+
last_modified_time is_associated web_client_read_form_query_string
|
17
|
+
web_client_edit_form_query_string conversation_id unique_body
|
18
|
+
}.map(&:to_sym).freeze
|
19
|
+
|
20
|
+
# Returns a new Task template
|
21
|
+
def initialize(opts = {})
|
22
|
+
super opts.dup
|
23
|
+
end
|
24
|
+
|
25
|
+
# EWS CreateItem container
|
26
|
+
# @return [Hash]
|
27
|
+
def to_ews_create
|
28
|
+
structure = {}
|
29
|
+
|
30
|
+
if self.saved_item_folder_id
|
31
|
+
if self.saved_item_folder_id.kind_of?(Hash)
|
32
|
+
structure[:saved_item_folder_id] = saved_item_folder_id
|
33
|
+
else
|
34
|
+
structure[:saved_item_folder_id] = {id: saved_item_folder_id}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
structure[:items] = [{task: to_ews_item}]
|
39
|
+
structure
|
40
|
+
end
|
41
|
+
|
42
|
+
# EWS Item hash
|
43
|
+
#
|
44
|
+
# Puts all known parameters in the required ordering and structure
|
45
|
+
# @return [Hash]
|
46
|
+
def to_ews_item
|
47
|
+
item_parameters = {}
|
48
|
+
PARAMETERS.each do |key|
|
49
|
+
if !(value = self.send(key)).nil?
|
50
|
+
|
51
|
+
# Convert non duplicable values to String
|
52
|
+
case value
|
53
|
+
when NilClass, FalseClass, TrueClass, Symbol, Numeric
|
54
|
+
value = value.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
# Convert attributes
|
58
|
+
case key
|
59
|
+
when :start_date, :due_date
|
60
|
+
item_parameters[key] = {text: value.respond_to?(:iso8601) ? value.iso8601 : value}
|
61
|
+
when :body
|
62
|
+
item_parameters[key] = {body_type: self.body_type || 'Text', text: value.to_s}
|
63
|
+
else
|
64
|
+
item_parameters[key] = value
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
item_parameters
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,77 @@
|
|
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::Types
|
20
|
+
# A generic Attachment. This class should not be instantiated directly. You
|
21
|
+
# should use one of the subclasses like FileAttachment or ItemAttachment.
|
22
|
+
class Attachment
|
23
|
+
include Viewpoint::EWS
|
24
|
+
include Viewpoint::EWS::Types
|
25
|
+
include Viewpoint::EWS::Types::Item
|
26
|
+
|
27
|
+
ATTACH_KEY_PATHS = {
|
28
|
+
:id => [:attachment_id, :attribs, :id],
|
29
|
+
:parent_item_id => [:attachment_id, :attribs, :root_item_id],
|
30
|
+
:parent_change_key => [:attachment_id, :attribs, :root_item_change_key],
|
31
|
+
:name => [:name, :text],
|
32
|
+
:content_type => [:content_type, :text],
|
33
|
+
:content_id => [:content_id],
|
34
|
+
:size => [:size, :text],
|
35
|
+
:last_modified_time => [:last_modified_time, :text],
|
36
|
+
:is_inline? => [:is_inline, :text],
|
37
|
+
}
|
38
|
+
|
39
|
+
ATTACH_KEY_TYPES = {
|
40
|
+
is_inline?: ->(str){str.downcase == 'true'},
|
41
|
+
last_modified_type: ->(str){DateTime.parse(str)},
|
42
|
+
size: ->(str){str.to_i},
|
43
|
+
content_id: :fix_content_id,
|
44
|
+
}
|
45
|
+
|
46
|
+
ATTACH_KEY_ALIAS = { }
|
47
|
+
|
48
|
+
# @param [Hash] attachment The attachment ews_item
|
49
|
+
def initialize(item, attachment)
|
50
|
+
@item = item
|
51
|
+
super(item.ews, attachment)
|
52
|
+
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
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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::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
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Viewpoint::EWS::Types
|
2
|
+
class CalendarFolder
|
3
|
+
include Viewpoint::EWS
|
4
|
+
include Viewpoint::EWS::Types
|
5
|
+
include Viewpoint::EWS::Types::GenericFolder
|
6
|
+
|
7
|
+
# Fetch items between a given time period
|
8
|
+
# @param [DateTime] start_date the time to start fetching Items from
|
9
|
+
# @param [DateTime] end_date the time to stop fetching Items from
|
10
|
+
def items_between(start_date, end_date, opts={})
|
11
|
+
items do |obj|
|
12
|
+
obj.restriction = { :and =>
|
13
|
+
[
|
14
|
+
{:is_greater_than_or_equal_to =>
|
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
|
30
|
+
|
31
|
+
# Creates a new appointment
|
32
|
+
# @param attributes [Hash] Parameters of the calendar item. Some example attributes are listed below.
|
33
|
+
# @option attributes :subject [String]
|
34
|
+
# @option attributes :start [Time]
|
35
|
+
# @option attributes :end [Time]
|
36
|
+
# @return [CalendarItem]
|
37
|
+
# @see Template::CalendarItem
|
38
|
+
def create_item(attributes)
|
39
|
+
template = Viewpoint::EWS::Template::CalendarItem.new attributes
|
40
|
+
template.saved_item_folder_id = {id: self.id, change_key: self.change_key}
|
41
|
+
rm = ews.create_item(template.to_ews_create).response_messages.first
|
42
|
+
if rm && rm.success?
|
43
|
+
CalendarItem.new ews, rm.items.first[:calendar_item][:elems].first
|
44
|
+
else
|
45
|
+
raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" unless rm
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Viewpoint::EWS::Types
|
2
|
+
class CalendarItem
|
3
|
+
include Viewpoint::EWS
|
4
|
+
include Viewpoint::EWS::Types
|
5
|
+
include Viewpoint::EWS::Types::Item
|
6
|
+
include Viewpoint::StringUtils
|
7
|
+
|
8
|
+
CALENDAR_ITEM_KEY_PATHS = {
|
9
|
+
recurring?: [:is_recurring, :text],
|
10
|
+
meeting?: [:is_meeting, :text],
|
11
|
+
cancelled?: [:is_cancelled, :text],
|
12
|
+
duration: [:duration, :text],
|
13
|
+
time_zone: [:time_zone, :text],
|
14
|
+
start: [:start, :text],
|
15
|
+
end: [:end, :text],
|
16
|
+
location: [:location, :text],
|
17
|
+
all_day?: [:is_all_day_event, :text],
|
18
|
+
my_response_type: [:my_response_type, :text],
|
19
|
+
organizer: [:organizer, :elems, 0, :mailbox, :elems],
|
20
|
+
required_attendees: [:required_attendees, :elems ],
|
21
|
+
recurrence: [:recurrence, :elems ],
|
22
|
+
deleted_occurrences: [:deleted_occurrences, :elems ],
|
23
|
+
modified_occurrences: [:modified_occurrences, :elems ],
|
24
|
+
has_attachments?: [:has_attachments, :text ],
|
25
|
+
attachments: [:attachments, :elems ]
|
26
|
+
}
|
27
|
+
|
28
|
+
CALENDAR_ITEM_KEY_TYPES = {
|
29
|
+
recurring?: ->(str){str.downcase == 'true'},
|
30
|
+
meeting?: ->(str){str.downcase == 'true'},
|
31
|
+
cancelled?: ->(str){str.downcase == 'true'},
|
32
|
+
all_day?: ->(str){str.downcase == 'true'},
|
33
|
+
organizer: :build_mailbox_user,
|
34
|
+
required_attendees: :build_attendees_users,
|
35
|
+
deleted_occurrences: :build_deleted_occurrences,
|
36
|
+
modified_occurrences: :build_modified_occurrences
|
37
|
+
}
|
38
|
+
CALENDAR_ITEM_KEY_ALIAS = {}
|
39
|
+
|
40
|
+
# Updates the specified item attributes
|
41
|
+
#
|
42
|
+
# Uses `SetItemField` if value is present and `DeleteItemField` if value is nil
|
43
|
+
# @param updates [Hash] with (:attribute => value)
|
44
|
+
# @param options [Hash]
|
45
|
+
# @option options :conflict_resolution [String] one of 'NeverOverwrite', 'AutoResolve' (default) or 'AlwaysOverwrite'
|
46
|
+
# @option options :send_meeting_invitations_or_cancellations [String] one of 'SendToNone' (default), 'SendOnlyToAll',
|
47
|
+
# 'SendOnlyToChanged', 'SendToAllAndSaveCopy' or 'SendToChangedAndSaveCopy'
|
48
|
+
# @return [CalendarItem, false]
|
49
|
+
# @example Update Subject and Body
|
50
|
+
# item = #...
|
51
|
+
# item.update_item!(subject: 'New subject', body: 'New Body')
|
52
|
+
# @see http://msdn.microsoft.com/en-us/library/exchange/aa580254.aspx
|
53
|
+
# @todo AppendToItemField updates not implemented
|
54
|
+
def update_item!(updates, options = {})
|
55
|
+
item_updates = []
|
56
|
+
updates.each do |attribute, value|
|
57
|
+
item_field = FIELD_URIS[attribute][:text] if FIELD_URIS.include? attribute
|
58
|
+
field = {field_uRI: {field_uRI: item_field}}
|
59
|
+
|
60
|
+
if value.nil? && item_field
|
61
|
+
# Build DeleteItemField Change
|
62
|
+
item_updates << {delete_item_field: field}
|
63
|
+
elsif item_field
|
64
|
+
# Build SetItemField Change
|
65
|
+
item = Viewpoint::EWS::Template::CalendarItem.new(attribute => value)
|
66
|
+
|
67
|
+
# Remap attributes because ews_builder #dispatch_field_item! uses #build_xml!
|
68
|
+
item_attributes = item.to_ews_item.map do |name, value|
|
69
|
+
if value.is_a? String
|
70
|
+
{name => {text: value}}
|
71
|
+
elsif value.is_a? Hash
|
72
|
+
node = {name => {}}
|
73
|
+
value.each do |attrib_key, attrib_value|
|
74
|
+
attrib_key = camel_case(attrib_key) unless attrib_key == :text
|
75
|
+
node[name][attrib_key] = attrib_value
|
76
|
+
end
|
77
|
+
node
|
78
|
+
else
|
79
|
+
{name => value}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
item_updates << {set_item_field: field.merge(calendar_item: {sub_elements: item_attributes})}
|
84
|
+
else
|
85
|
+
# Ignore unknown attribute
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if item_updates.any?
|
90
|
+
data = {}
|
91
|
+
data[:conflict_resolution] = options[:conflict_resolution] || 'AutoResolve'
|
92
|
+
data[:send_meeting_invitations_or_cancellations] = options[:send_meeting_invitations_or_cancellations] || 'SendToNone'
|
93
|
+
data[:item_changes] = [{item_id: self.item_id, updates: item_updates}]
|
94
|
+
rm = ews.update_item(data).response_messages.first
|
95
|
+
if rm && rm.success?
|
96
|
+
self.get_all_properties!
|
97
|
+
self
|
98
|
+
else
|
99
|
+
raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.message_text}" unless rm
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def key_paths
|
109
|
+
super.merge(CALENDAR_ITEM_KEY_PATHS)
|
110
|
+
end
|
111
|
+
|
112
|
+
def key_types
|
113
|
+
super.merge(CALENDAR_ITEM_KEY_TYPES)
|
114
|
+
end
|
115
|
+
|
116
|
+
def key_alias
|
117
|
+
super.merge(CALENDAR_ITEM_KEY_ALIAS)
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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::Types
|
20
|
+
|
21
|
+
class CopiedEvent < Event
|
22
|
+
|
23
|
+
COPIED_EVENT_KEY_PATHS = {
|
24
|
+
:old_item_id => [:old_item_id, :attribs],
|
25
|
+
:old_folder_id => [:old_folder_id, :attribs],
|
26
|
+
:old_parent_folder_id => [:old_parent_folder_id, :attribs],
|
27
|
+
}
|
28
|
+
|
29
|
+
COPIED_EVENT_KEY_TYPES = {
|
30
|
+
}
|
31
|
+
|
32
|
+
COPIED_EVENT_KEY_ALIAS = { }
|
33
|
+
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
|
38
|
+
def key_paths
|
39
|
+
@key_paths ||= super.merge COPIED_EVENT_KEY_PATHS
|
40
|
+
end
|
41
|
+
|
42
|
+
def key_types
|
43
|
+
@key_types ||= super.merge COPIED_EVENT_KEY_TYPES
|
44
|
+
end
|
45
|
+
|
46
|
+
def key_alias
|
47
|
+
@key_alias ||= super.merge COPIED_EVENT_KEY_ALIAS
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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::Types
|
20
|
+
|
21
|
+
class CreatedEvent < Event
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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::Types
|
20
|
+
|
21
|
+
class DeletedEvent < Event
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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::Types
|
20
|
+
|
21
|
+
class Event
|
22
|
+
include Viewpoint::EWS
|
23
|
+
include Viewpoint::EWS::Types
|
24
|
+
include Viewpoint::EWS::Types::Item
|
25
|
+
|
26
|
+
EVENT_KEY_PATHS = {
|
27
|
+
:watermark => [:watermark, :text],
|
28
|
+
:timestamp => [:time_stamp, :text],
|
29
|
+
:item_id => [:item_id, :attribs],
|
30
|
+
:folder_id => [:folder_id, :attribs],
|
31
|
+
:parent_folder_id => [:parent_folder_id, :attribs],
|
32
|
+
}
|
33
|
+
|
34
|
+
EVENT_KEY_TYPES = {
|
35
|
+
:timestamp => ->(ts){ DateTime.iso8601(ts) }
|
36
|
+
}
|
37
|
+
|
38
|
+
EVENT_KEY_ALIAS = { }
|
39
|
+
|
40
|
+
def initialize(ews, event)
|
41
|
+
@ews = ews
|
42
|
+
super(ews, event)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
|
49
|
+
def key_paths
|
50
|
+
@key_paths ||= EVENT_KEY_PATHS
|
51
|
+
end
|
52
|
+
|
53
|
+
def key_types
|
54
|
+
@key_types ||= EVENT_KEY_TYPES
|
55
|
+
end
|
56
|
+
|
57
|
+
def key_alias
|
58
|
+
@key_alias ||= EVENT_KEY_ALIAS
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Viewpoint::EWS::Types
|
2
|
+
|
3
|
+
class ExportItemsResponseMessage
|
4
|
+
include Viewpoint::EWS
|
5
|
+
include Viewpoint::EWS::Types
|
6
|
+
include Viewpoint::EWS::Types::Item
|
7
|
+
|
8
|
+
BULK_KEY_PATHS = {
|
9
|
+
:id => [:item_id, :attribs, :id],
|
10
|
+
:change_key => [:item_id, :attribs, :change_key],
|
11
|
+
:data => [:data, :text]
|
12
|
+
}
|
13
|
+
|
14
|
+
BULK_KEY_TYPES = { }
|
15
|
+
|
16
|
+
BULK_KEY_ALIAS = { }
|
17
|
+
|
18
|
+
def initialize(ews, bulk_item)
|
19
|
+
super(ews, bulk_item)
|
20
|
+
@item = bulk_item
|
21
|
+
@ews = ews
|
22
|
+
end
|
23
|
+
|
24
|
+
def id
|
25
|
+
@item[:item_id][:attribs][:id]
|
26
|
+
end
|
27
|
+
|
28
|
+
def change_key
|
29
|
+
@item[:item_id][:attribs][:change_key]
|
30
|
+
end
|
31
|
+
|
32
|
+
def data
|
33
|
+
@item[:data][:text]
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def key_paths
|
40
|
+
@key_paths ||= BULK_KEY_PATHS
|
41
|
+
end
|
42
|
+
|
43
|
+
def key_types
|
44
|
+
@key_types ||= BULK_KEY_TYPES
|
45
|
+
end
|
46
|
+
|
47
|
+
def key_alias
|
48
|
+
@key_alias ||= BULK_KEY_ALIAS
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|