viewpoint2 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +216 -0
  3. data/lib/ews/calendar_accessors.rb +34 -0
  4. data/lib/ews/connection.rb +130 -0
  5. data/lib/ews/connection_helper.rb +35 -0
  6. data/lib/ews/convert_accessors.rb +56 -0
  7. data/lib/ews/errors.rb +56 -0
  8. data/lib/ews/ews_client.rb +103 -0
  9. data/lib/ews/exceptions/exceptions.rb +61 -0
  10. data/lib/ews/folder_accessors.rb +264 -0
  11. data/lib/ews/impersonation.rb +30 -0
  12. data/lib/ews/item_accessors.rb +231 -0
  13. data/lib/ews/mailbox_accessors.rb +99 -0
  14. data/lib/ews/message_accessors.rb +93 -0
  15. data/lib/ews/push_subscription_accessors.rb +33 -0
  16. data/lib/ews/room_accessors.rb +48 -0
  17. data/lib/ews/roomlist_accessors.rb +47 -0
  18. data/lib/ews/soap.rb +64 -0
  19. data/lib/ews/soap/builders/ews_builder.rb +1351 -0
  20. data/lib/ews/soap/ews_response.rb +84 -0
  21. data/lib/ews/soap/ews_soap_availability_response.rb +58 -0
  22. data/lib/ews/soap/ews_soap_free_busy_response.rb +119 -0
  23. data/lib/ews/soap/ews_soap_response.rb +103 -0
  24. data/lib/ews/soap/ews_soap_room_response.rb +53 -0
  25. data/lib/ews/soap/ews_soap_roomlist_response.rb +54 -0
  26. data/lib/ews/soap/exchange_availability.rb +61 -0
  27. data/lib/ews/soap/exchange_data_services.rb +780 -0
  28. data/lib/ews/soap/exchange_notification.rb +146 -0
  29. data/lib/ews/soap/exchange_synchronization.rb +93 -0
  30. data/lib/ews/soap/exchange_time_zones.rb +56 -0
  31. data/lib/ews/soap/exchange_user_configuration.rb +33 -0
  32. data/lib/ews/soap/exchange_web_service.rb +264 -0
  33. data/lib/ews/soap/parsers/ews_parser.rb +43 -0
  34. data/lib/ews/soap/parsers/ews_sax_document.rb +70 -0
  35. data/lib/ews/soap/response_message.rb +80 -0
  36. data/lib/ews/soap/responses/create_attachment_response_message.rb +47 -0
  37. data/lib/ews/soap/responses/create_item_response_message.rb +25 -0
  38. data/lib/ews/soap/responses/find_item_response_message.rb +80 -0
  39. data/lib/ews/soap/responses/get_events_response_message.rb +53 -0
  40. data/lib/ews/soap/responses/send_notification_response_message.rb +59 -0
  41. data/lib/ews/soap/responses/subscribe_response_message.rb +35 -0
  42. data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +36 -0
  43. data/lib/ews/soap/responses/sync_folder_items_response_message.rb +36 -0
  44. data/lib/ews/templates/calendar_item.rb +79 -0
  45. data/lib/ews/templates/forward_item.rb +24 -0
  46. data/lib/ews/templates/message.rb +76 -0
  47. data/lib/ews/templates/reply_to_item.rb +25 -0
  48. data/lib/ews/templates/task.rb +74 -0
  49. data/lib/ews/types.rb +194 -0
  50. data/lib/ews/types/attachment.rb +77 -0
  51. data/lib/ews/types/attendee.rb +41 -0
  52. data/lib/ews/types/calendar_folder.rb +50 -0
  53. data/lib/ews/types/calendar_item.rb +133 -0
  54. data/lib/ews/types/contact.rb +7 -0
  55. data/lib/ews/types/contacts_folder.rb +8 -0
  56. data/lib/ews/types/copied_event.rb +51 -0
  57. data/lib/ews/types/created_event.rb +24 -0
  58. data/lib/ews/types/deleted_event.rb +24 -0
  59. data/lib/ews/types/distribution_list.rb +7 -0
  60. data/lib/ews/types/event.rb +62 -0
  61. data/lib/ews/types/export_items_response_message.rb +52 -0
  62. data/lib/ews/types/file_attachment.rb +65 -0
  63. data/lib/ews/types/folder.rb +60 -0
  64. data/lib/ews/types/free_busy_changed_event.rb +24 -0
  65. data/lib/ews/types/generic_folder.rb +418 -0
  66. data/lib/ews/types/item.rb +450 -0
  67. data/lib/ews/types/item_attachment.rb +84 -0
  68. data/lib/ews/types/item_field_uri_map.rb +208 -0
  69. data/lib/ews/types/mailbox_user.rb +156 -0
  70. data/lib/ews/types/meeting_cancellation.rb +7 -0
  71. data/lib/ews/types/meeting_message.rb +7 -0
  72. data/lib/ews/types/meeting_request.rb +7 -0
  73. data/lib/ews/types/meeting_response.rb +7 -0
  74. data/lib/ews/types/message.rb +7 -0
  75. data/lib/ews/types/modified_event.rb +48 -0
  76. data/lib/ews/types/moved_event.rb +51 -0
  77. data/lib/ews/types/new_mail_event.rb +24 -0
  78. data/lib/ews/types/out_of_office.rb +147 -0
  79. data/lib/ews/types/post_item.rb +7 -0
  80. data/lib/ews/types/search_folder.rb +8 -0
  81. data/lib/ews/types/status_event.rb +39 -0
  82. data/lib/ews/types/task.rb +104 -0
  83. data/lib/ews/types/tasks_folder.rb +27 -0
  84. data/lib/viewpoint/logging.rb +27 -0
  85. data/lib/viewpoint/logging/config.rb +24 -0
  86. data/lib/viewpoint/string_utils.rb +76 -0
  87. data/lib/viewpoint2.rb +111 -0
  88. metadata +191 -0
@@ -0,0 +1,43 @@
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
+ class EwsParser
21
+ include Viewpoint::EWS
22
+
23
+ # @param [String] soap_resp
24
+ def initialize(soap_resp)
25
+ @soap_resp = soap_resp
26
+ @sax_doc = EwsSaxDocument.new
27
+ end
28
+
29
+ def parse(opts = {})
30
+ opts[:response_class] ||= EwsSoapResponse
31
+ sax_parser.parse(@soap_resp)
32
+ opts[:response_class].new @sax_doc.struct
33
+ end
34
+
35
+
36
+ private
37
+
38
+ def sax_parser
39
+ @parser ||= Nokogiri::XML::SAX::Parser.new(@sax_doc)
40
+ end
41
+
42
+ end # EwsParser
43
+ end # Viewpoint
@@ -0,0 +1,70 @@
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
+ # Parse the incoming response document via a SAX parser instead of the
21
+ # traditional DOM parser. In early benchmarks this was performing about
22
+ # 132% faster than the DOM-based parser for large documents.
23
+ class EwsSaxDocument < Nokogiri::XML::SAX::Document
24
+ include Viewpoint::EWS
25
+ include Viewpoint::StringUtils
26
+
27
+ attr_reader :struct
28
+
29
+ def initialize
30
+ @struct = {}
31
+ @elems = []
32
+ end
33
+
34
+ def characters(string)
35
+ # FIXME: Move white space removal to somewhere else.
36
+ # This function can be called multiple times. In this case newlines in Text Bodies get stripped.
37
+ # See: https://github.com/zenchild/Viewpoint/issues/90
38
+ #string.strip!
39
+ return if string.empty?
40
+ if @elems.last[:text]
41
+ @elems.last[:text] += string
42
+ else
43
+ @elems.last[:text] = string
44
+ end
45
+ end
46
+
47
+ def start_element_namespace(name, attributes = [], prefix = nil, uri = nil, ns = [])
48
+ name = ruby_case(name).to_sym
49
+ elem = {}
50
+ unless attributes.empty?
51
+ elem[:attribs] = attributes.collect{|a|
52
+ { ruby_case(a.localname).to_sym => a.value}
53
+ }.inject(&:merge)
54
+ end
55
+ @elems << elem
56
+ end
57
+
58
+ def end_element_namespace name, prefix=nil, uri=nil
59
+ name = ruby_case(name).to_sym
60
+ elem = @elems.pop
61
+ if @elems.empty?
62
+ @struct[name] = elem
63
+ else
64
+ @elems.last[:elems] = [] unless @elems.last[:elems].is_a?(Array)
65
+ @elems.last[:elems] << {name => elem}
66
+ end
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,80 @@
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
+ class ResponseMessage
21
+
22
+ attr_reader :message, :type
23
+
24
+ def initialize(message)
25
+ @type = message.keys.first
26
+ @message = message[@type]
27
+ end
28
+
29
+ def response_class
30
+ message[:attribs][:response_class]
31
+ end
32
+ alias :status :response_class
33
+
34
+ def success?
35
+ response_class == 'Success'
36
+ end
37
+
38
+ def message_text
39
+ safe_hash_access message, [:elems, :message_text, :text]
40
+ end
41
+
42
+ def response_code
43
+ safe_hash_access message, [:elems, :response_code, :text]
44
+ end
45
+ alias :code :response_code
46
+
47
+ def message_xml
48
+ safe_hash_access message, [:elems, :message_xml, :text]
49
+ end
50
+
51
+ def items
52
+ safe_hash_access(message, [:elems, :items, :elems]) || []
53
+ end
54
+
55
+
56
+ private
57
+
58
+
59
+ def safe_hash_access(hsh, keys)
60
+ key = keys.shift
61
+ return nil unless hsh.is_a?(Hash) && hsh.has_key?(key)
62
+
63
+ if keys.empty?
64
+ hsh[key]
65
+ else
66
+ safe_hash_access hsh[key], keys
67
+ end
68
+ end
69
+
70
+ end
71
+ end # Viewpoint::EWS::SOAP
72
+
73
+ require_relative './responses/create_item_response_message'
74
+ require_relative './responses/create_attachment_response_message'
75
+ require_relative './responses/find_item_response_message'
76
+ require_relative './responses/subscribe_response_message'
77
+ require_relative './responses/get_events_response_message'
78
+ require_relative './responses/send_notification_response_message'
79
+ require_relative './responses/sync_folder_items_response_message'
80
+ require_relative './responses/sync_folder_hierarchy_response_message'
@@ -0,0 +1,47 @@
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
+ class CreateAttachmentResponseMessage < ResponseMessage
22
+ include Viewpoint::StringUtils
23
+
24
+ def attachments
25
+ return @attachments if @attachments
26
+
27
+ a = safe_hash_access message, [:elems, :attachments, :elems]
28
+ @attachments = a.nil? ? nil : parse_attachments(a)
29
+ end
30
+
31
+
32
+ private
33
+
34
+
35
+ def parse_attachments(att)
36
+ att.collect do |a|
37
+ type = a.keys.first
38
+ klass = Viewpoint::EWS::Types.const_get(camel_case(type))
39
+ item = OpenStruct.new
40
+ item.ews = nil
41
+ klass.new(item, a[type])
42
+ end
43
+ end
44
+
45
+ end # CreateAttachmentResponseMessage
46
+
47
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,25 @@
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
+ class CreateItemResponseMessage < ResponseMessage
22
+
23
+ end # CreateItemResponseMessage
24
+
25
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,80 @@
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
+ class RootFolder
22
+
23
+ attr_reader :root
24
+
25
+ def initialize(root)
26
+ @root = root
27
+ end
28
+
29
+ def indexed_paging_offset
30
+ attrib :index_paging_offset
31
+ end
32
+
33
+ def numerator_offset
34
+ attrib :numerator_offset
35
+ end
36
+
37
+ def absolute_denominator
38
+ attrib :absolute_denominator
39
+ end
40
+
41
+ def includes_last_item_in_range
42
+ attrib :includes_last_item_in_range
43
+ end
44
+
45
+ def total_items_in_view
46
+ attrib :total_items_in_view
47
+ end
48
+
49
+ def items
50
+ root[:elems][0][:items][:elems] || []
51
+ end
52
+
53
+ def groups
54
+ root[:elems][0][:groups][:elems]
55
+ end
56
+
57
+
58
+ private
59
+
60
+
61
+ def attrib(key)
62
+ return nil unless root.has_key?(:attribs)
63
+ root[:attribs][key]
64
+ end
65
+
66
+ end
67
+
68
+
69
+ class FindItemResponseMessage < ResponseMessage
70
+
71
+ def root_folder
72
+ return @root_folder if @root_folder
73
+
74
+ rf = safe_hash_access message, [:elems, :root_folder]
75
+ @root_folder = rf.nil? ? nil : RootFolder.new(rf)
76
+ end
77
+
78
+ end # FindItemResponseMessage
79
+
80
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,53 @@
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
+ class GetEventsResponseMessage < ResponseMessage
21
+
22
+ def notification
23
+ safe_hash_access message, [:elems, :notification, :elems]
24
+ end
25
+
26
+ def subscription_id
27
+ safe_hash_access notification[0], [:subscription_id, :text]
28
+ end
29
+
30
+ def previous_watermark
31
+ safe_hash_access notification[1], [:previous_watermark, :text]
32
+ end
33
+
34
+ def new_watermark
35
+ ev = notification.last
36
+ if ev
37
+ type = ev.keys.first
38
+ ev[type][:elems][0][:watermark][:text]
39
+ else
40
+ nil
41
+ end
42
+ end
43
+
44
+ def more_events?
45
+ safe_hash_access(notification[2], [:more_events, :text]) == 'true'
46
+ end
47
+
48
+ def events
49
+ notification[3..-1]
50
+ end
51
+
52
+ end # GetEventsResponseMessage
53
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,59 @@
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
+ class SendNotificationResponseMessage < ResponseMessage
21
+ include Viewpoint::StringUtils
22
+
23
+ def notification
24
+ safe_hash_access message, [:elems, :notification, :elems]
25
+ end
26
+
27
+ def subscription_id
28
+ safe_hash_access notification[0], [:subscription_id, :text]
29
+ end
30
+
31
+ def previous_watermark
32
+ safe_hash_access notification[1], [:previous_watermark, :text]
33
+ end
34
+
35
+ def new_watermark
36
+ ev = notification.last
37
+ if ev
38
+ type = ev.keys.first
39
+ ev[type][:elems][0][:watermark][:text]
40
+ else
41
+ nil
42
+ end
43
+ end
44
+
45
+ def more_events?
46
+ safe_hash_access(notification[2], [:more_events, :text]) == 'true'
47
+ end
48
+
49
+ def events
50
+ @events ||=
51
+ notification[3..-1].collect do |ev|
52
+ type = ev.keys.first
53
+ klass = Viewpoint::EWS::Types.const_get(camel_case(type))
54
+ klass.new(nil, ev[type])
55
+ end
56
+ end
57
+
58
+ end # SendNotificationResponseMessage
59
+ end # Viewpoint::EWS::SOAP