viewpoint 0.1.27 → 1.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +196 -0
- data/lib/ews/calendar_accessors.rb +34 -0
- data/lib/ews/connection.rb +117 -0
- data/lib/ews/connection_helper.rb +35 -0
- data/lib/ews/ews_client.rb +71 -0
- data/lib/ews/exceptions/exceptions.rb +59 -0
- data/lib/ews/folder_accessors.rb +199 -0
- data/lib/ews/item_accessors.rb +157 -0
- data/lib/ews/mailbox_accessors.rb +87 -0
- data/lib/ews/message_accessors.rb +86 -0
- data/lib/ews/push_subscription_accessors.rb +33 -0
- data/lib/ews/soap.rb +63 -0
- data/lib/ews/soap/builders/ews_builder.rb +1011 -0
- data/lib/ews/soap/ews_response.rb +83 -0
- data/lib/ews/soap/ews_soap_availability_response.rb +58 -0
- data/lib/ews/soap/ews_soap_free_busy_response.rb +109 -0
- data/lib/ews/soap/ews_soap_response.rb +103 -0
- data/lib/ews/soap/exchange_availability.rb +61 -0
- data/lib/ews/soap/exchange_data_services.rb +742 -0
- data/lib/ews/soap/exchange_notification.rb +146 -0
- data/lib/ews/soap/exchange_user_configuration.rb +33 -0
- data/lib/ews/soap/exchange_web_service.rb +294 -0
- data/lib/{model/attendee.rb → ews/soap/parsers/ews_parser.rb} +20 -14
- data/lib/ews/soap/parsers/ews_sax_document.rb +66 -0
- data/lib/ews/soap/response_message.rb +78 -0
- data/lib/ews/soap/responses/create_attachment_response_message.rb +46 -0
- data/lib/{model/meeting_message.rb → ews/soap/responses/create_item_response_message.rb} +7 -10
- 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 +58 -0
- data/lib/{model/attachment.rb → ews/soap/responses/subscribe_response_message.rb} +17 -13
- data/lib/ews/templates/forward_item.rb +24 -0
- data/lib/ews/templates/message.rb +66 -0
- data/lib/ews/templates/reply_to_item.rb +25 -0
- data/lib/ews/types.rb +146 -0
- data/lib/ews/types/attachment.rb +77 -0
- data/lib/{model/meeting_cancellation.rb → ews/types/attendee.rb} +9 -8
- data/lib/ews/types/calendar_folder.rb +8 -0
- data/lib/ews/types/calendar_item.rb +37 -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/{soap/handsoap/builder.rb → ews/types/created_event.rb} +5 -2
- data/lib/{model/meeting_response.rb → ews/types/deleted_event.rb} +6 -6
- data/lib/ews/types/distribution_list.rb +7 -0
- data/lib/ews/types/event.rb +62 -0
- data/lib/ews/types/file_attachment.rb +65 -0
- data/lib/ews/types/folder.rb +60 -0
- data/lib/{model/distribution_list.rb → ews/types/free_busy_changed_event.rb} +6 -6
- data/lib/ews/types/generic_folder.rb +352 -0
- data/lib/ews/types/item.rb +381 -0
- data/lib/ews/types/item_attachment.rb +46 -0
- data/lib/{model → ews/types}/item_field_uri_map.rb +2 -2
- 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/{model/item_attachment.rb → ews/types/moved_event.rb} +33 -15
- 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 +7 -0
- data/lib/ews/types/tasks_folder.rb +8 -0
- data/lib/viewpoint.rb +82 -106
- metadata +99 -67
- data/README +0 -114
- data/lib/exceptions/exceptions.rb +0 -46
- data/lib/model/calendar_folder.rb +0 -67
- data/lib/model/calendar_item.rb +0 -267
- data/lib/model/contact.rb +0 -238
- data/lib/model/contacts_folder.rb +0 -46
- data/lib/model/event.rb +0 -116
- data/lib/model/file_attachment.rb +0 -53
- data/lib/model/folder.rb +0 -47
- data/lib/model/generic_folder.rb +0 -471
- data/lib/model/item.rb +0 -313
- data/lib/model/mailbox_user.rb +0 -146
- data/lib/model/meeting_request.rb +0 -39
- data/lib/model/message.rb +0 -142
- data/lib/model/model.rb +0 -269
- data/lib/model/search_folder.rb +0 -48
- data/lib/model/task.rb +0 -121
- data/lib/model/tasks_folder.rb +0 -44
- data/lib/soap/handsoap/builders/ews_build_helpers.rb +0 -383
- data/lib/soap/handsoap/builders/ews_builder.rb +0 -146
- data/lib/soap/handsoap/ews_service.rb +0 -813
- data/lib/soap/handsoap/parser.rb +0 -104
- data/lib/soap/handsoap/parsers/ews_parser.rb +0 -246
- data/lib/soap/soap_provider.rb +0 -64
@@ -16,16 +16,20 @@
|
|
16
16
|
limitations under the License.
|
17
17
|
=end
|
18
18
|
|
19
|
-
module Viewpoint
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
19
|
+
module Viewpoint::EWS::SOAP
|
20
|
+
class SubscribeResponseMessage < ResponseMessage
|
21
|
+
|
22
|
+
def subscription
|
23
|
+
safe_hash_access message, [:elems]
|
24
|
+
end
|
25
|
+
|
26
|
+
def subscription_id
|
27
|
+
safe_hash_access subscription, [:subscription_id, :text]
|
28
|
+
end
|
29
|
+
|
30
|
+
def watermark
|
31
|
+
safe_hash_access subscription, [:watermark, :text]
|
32
|
+
end
|
33
|
+
|
34
|
+
end # SubscribeResponseMessage
|
35
|
+
end # Viewpoint::EWS::SOAP
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Viewpoint::EWS
|
2
|
+
module Template
|
3
|
+
class ForwardItem < Message
|
4
|
+
|
5
|
+
# Format this object for EWS backend consumption.
|
6
|
+
def to_ews
|
7
|
+
ews_opts, msg = to_ews_basic
|
8
|
+
msg[:reference_item_id] = reference_item_id
|
9
|
+
msg[:new_body_content] = {text: new_body_content, body_type: new_body_type}
|
10
|
+
ews_opts.merge({items: [{forward_item: msg}]})
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
|
16
|
+
def init_defaults!
|
17
|
+
super
|
18
|
+
self.new_body_content ||= ''
|
19
|
+
self.new_body_type ||= 'Text'
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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?)
|
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.draft ||= false
|
29
|
+
self.to_recipients ||= []
|
30
|
+
self.cc_recipients ||= []
|
31
|
+
self.bcc_recipients ||= []
|
32
|
+
self.file_attachments ||= []
|
33
|
+
self.item_attachments ||= []
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_ews_basic
|
37
|
+
ews_opts = {}
|
38
|
+
ews_opts[:message_disposition] = (draft ? 'SaveOnly' : 'SendAndSaveCopy')
|
39
|
+
|
40
|
+
if saved_item_folder_id
|
41
|
+
if saved_item_folder_id.kind_of?(Hash)
|
42
|
+
ews_opts[:saved_item_folder_id] = saved_item_folder_id
|
43
|
+
else
|
44
|
+
ews_opts[:saved_item_folder_id] = {id: saved_item_folder_id}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
msg = {}
|
49
|
+
msg[:subject] = subject if subject
|
50
|
+
msg[:body] = {text: body, body_type: body_type} if body
|
51
|
+
|
52
|
+
to_r = to_recipients.collect{|r| {mailbox: {email_address: r}}}
|
53
|
+
msg[:to_recipients] = to_r unless to_r.empty?
|
54
|
+
|
55
|
+
cc_r = cc_recipients.collect{|r| {mailbox: {email_address: r}}}
|
56
|
+
msg[:cc_recipients] = cc_r unless cc_r.empty?
|
57
|
+
|
58
|
+
bcc_r = bcc_recipients.collect{|r| {mailbox: {email_address: r}}}
|
59
|
+
msg[:bcc_recipients] = bcc_r unless bcc_r.empty?
|
60
|
+
|
61
|
+
[ews_opts, msg]
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
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
|
data/lib/ews/types.rb
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
module Viewpoint::EWS
|
2
|
+
module Types
|
3
|
+
|
4
|
+
KEY_PATHS = {
|
5
|
+
extended_properties: [:extended_property],
|
6
|
+
}
|
7
|
+
KEY_TYPES = {
|
8
|
+
extended_properties: :build_extended_properties,
|
9
|
+
}
|
10
|
+
KEY_ALIAS = {}
|
11
|
+
|
12
|
+
attr_reader :ews_item
|
13
|
+
|
14
|
+
# @param [SOAP::ExchangeWebService] ews the EWS reference
|
15
|
+
# @param [Hash] ews_item the EWS parsed response document
|
16
|
+
def initialize(ews, ews_item)
|
17
|
+
@ews = ews
|
18
|
+
@ews_item = ews_item
|
19
|
+
@shallow = true
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(method_sym, *arguments, &block)
|
23
|
+
if method_keys.include?(method_sym)
|
24
|
+
type_convert( method_sym, resolve_method(method_sym) )
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
"#{self.class.name}: EWS METHODS: #{self.ews_methods.sort.join(', ')}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def shallow?
|
35
|
+
@shallow
|
36
|
+
end
|
37
|
+
|
38
|
+
def mark_deep!
|
39
|
+
@shallow = false
|
40
|
+
end
|
41
|
+
|
42
|
+
def auto_deepen?
|
43
|
+
ews.auto_deepen
|
44
|
+
end
|
45
|
+
|
46
|
+
def deepen!
|
47
|
+
if shallow?
|
48
|
+
self.get_all_properties!
|
49
|
+
@shallow = false
|
50
|
+
true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
alias_method :enlighten!, :deepen!
|
54
|
+
|
55
|
+
# @see http://www.ruby-doc.org/core/classes/Object.html#M000333
|
56
|
+
def respond_to?(method_sym, include_private = false)
|
57
|
+
if method_keys.include?(method_sym)
|
58
|
+
true
|
59
|
+
else
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def methods(include_super = true)
|
65
|
+
super + ews_methods
|
66
|
+
end
|
67
|
+
|
68
|
+
def ews_methods
|
69
|
+
key_paths.keys + key_alias.keys
|
70
|
+
end
|
71
|
+
|
72
|
+
protected # things like OutOfOffice need protected level access
|
73
|
+
|
74
|
+
def ews
|
75
|
+
@ews
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def key_paths
|
81
|
+
KEY_PATHS
|
82
|
+
end
|
83
|
+
|
84
|
+
def key_types
|
85
|
+
KEY_TYPES
|
86
|
+
end
|
87
|
+
|
88
|
+
def key_alias
|
89
|
+
KEY_ALIAS
|
90
|
+
end
|
91
|
+
|
92
|
+
def class_by_name(cname)
|
93
|
+
if(cname.instance_of? Symbol)
|
94
|
+
cname = cname.to_s.camel_case
|
95
|
+
end
|
96
|
+
Viewpoint::EWS::Types.const_get(cname)
|
97
|
+
end
|
98
|
+
|
99
|
+
def type_convert(key,str)
|
100
|
+
return nil if str.nil?
|
101
|
+
key = key_alias[key] || key
|
102
|
+
if key_types[key]
|
103
|
+
key_types[key].is_a?(Symbol) ? method(key_types[key]).call(str) : key_types[key].call(str)
|
104
|
+
else
|
105
|
+
str
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def resolve_method(method_sym)
|
110
|
+
begin
|
111
|
+
resolve_key_path(@ews_item, method_path(method_sym))
|
112
|
+
rescue
|
113
|
+
if shallow?
|
114
|
+
if auto_deepen?
|
115
|
+
enlighten!
|
116
|
+
retry
|
117
|
+
else
|
118
|
+
raise EwsMinimalObjectError, "Could not resolve :#{method_sym}. #auto_deepen set to false"
|
119
|
+
end
|
120
|
+
else
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def resolve_key_path(hsh, path)
|
127
|
+
k = path.first
|
128
|
+
return hsh[k] if path.length == 1
|
129
|
+
resolve_key_path(hsh[k],path[1..-1])
|
130
|
+
end
|
131
|
+
|
132
|
+
def method_keys
|
133
|
+
key_paths.keys + key_alias.keys
|
134
|
+
end
|
135
|
+
|
136
|
+
# Resolve the method path with or without an alias
|
137
|
+
def method_path(sym)
|
138
|
+
key_paths[key_alias[sym] || sym]
|
139
|
+
end
|
140
|
+
|
141
|
+
def build_extended_properties(eprops)
|
142
|
+
eprops.collect.collect {|e| e[:elems]}
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
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
|
@@ -16,11 +16,12 @@
|
|
16
16
|
limitations under the License.
|
17
17
|
=end
|
18
18
|
|
19
|
-
module Viewpoint
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end #
|
26
|
-
|
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,37 @@
|
|
1
|
+
module Viewpoint::EWS::Types
|
2
|
+
class CalendarItem
|
3
|
+
include Viewpoint::EWS
|
4
|
+
include Viewpoint::EWS::Types
|
5
|
+
include Viewpoint::EWS::Types::Item
|
6
|
+
|
7
|
+
CALENDAR_ITEM_KEY_PATHS = {
|
8
|
+
recurring?: [:is_recurring, :text],
|
9
|
+
meeting?: [:is_meeting, :text],
|
10
|
+
cancelled?: [:is_cancelled, :text],
|
11
|
+
}
|
12
|
+
|
13
|
+
CALENDAR_ITEM_KEY_TYPES = {
|
14
|
+
recurring?: ->(str){str.downcase == 'true'},
|
15
|
+
meeting?: ->(str){str.downcase == 'true'},
|
16
|
+
cancelled?: ->(str){str.downcase == 'true'},
|
17
|
+
}
|
18
|
+
CALENDAR_ITEM_KEY_ALIAS = {}
|
19
|
+
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def key_paths
|
24
|
+
super.merge(CALENDAR_ITEM_KEY_PATHS)
|
25
|
+
end
|
26
|
+
|
27
|
+
def key_types
|
28
|
+
super.merge(CALENDAR_ITEM_KEY_TYPES)
|
29
|
+
end
|
30
|
+
|
31
|
+
def key_alias
|
32
|
+
super.merge(CALENDAR_ITEM_KEY_ALIAS)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|