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,84 @@
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
+ # A Generic Class for SOAP returns.
22
+ class EwsResponse
23
+ include Viewpoint::StringUtils
24
+
25
+ def initialize(sax_hash)
26
+ @resp = sax_hash
27
+ simplify!
28
+ end
29
+
30
+ def envelope
31
+ @resp[:envelope][:elems]
32
+ end
33
+
34
+ def header
35
+ envelope[0][:header][:elems]
36
+ end
37
+
38
+ def body
39
+ envelope[1][:body][:elems]
40
+ end
41
+
42
+ def response
43
+ body[0]
44
+ end
45
+
46
+ def response_messages
47
+ return @response_messages if @response_messages
48
+
49
+ @response_messages = []
50
+ response_type = response.keys.first
51
+ response[response_type][:elems][0][:response_messages][:elems].each do |rm|
52
+ response_message_type = rm.keys[0]
53
+ rm_klass = class_by_name(response_message_type)
54
+ @response_messages << rm_klass.new(rm)
55
+ end
56
+ @response_messages
57
+ end
58
+
59
+
60
+ private
61
+
62
+
63
+ def simplify!
64
+ response_type = response.keys.first
65
+ response[response_type][:elems][0][:response_messages][:elems].each do |rm|
66
+ key = rm.keys.first
67
+ rm[key][:elems] = rm[key][:elems].inject(&:merge)
68
+ end
69
+ end
70
+
71
+ def class_by_name(cname)
72
+ begin
73
+ if(cname.instance_of? Symbol)
74
+ cname = camel_case(cname)
75
+ end
76
+ Viewpoint::EWS::SOAP.const_get(cname)
77
+ rescue NameError => e
78
+ ResponseMessage
79
+ end
80
+ end
81
+
82
+ end # EwsSoapResponse
83
+
84
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,58 @@
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
+ # This is a speciality response class to handle the idiosynracies of
22
+ # Availability responses.
23
+ # @attr_reader [String] :message The text from the EWS element <m:ResponseCode>
24
+ class EwsSoapAvailabilityResponse < EwsSoapResponse
25
+
26
+ def response_messages
27
+ nil
28
+ end
29
+
30
+ def response
31
+ body[0][response_key]
32
+ end
33
+
34
+ def response_message
35
+ key = response.keys.first
36
+ response[key]
37
+ end
38
+
39
+ def response_code
40
+ response_message[:elems][:response_code][:text]
41
+ end
42
+ alias :code :response_code
43
+
44
+ def response_key
45
+ key = body[0].keys.first
46
+ end
47
+
48
+ private
49
+
50
+ def simplify!
51
+ key = response_key
52
+ body[0][key] = body[0][key][:elems].inject(:merge)
53
+ response_message[:elems] = response_message[:elems].inject(:merge)
54
+ end
55
+
56
+ end # EwsSoapAvailabilityResponse
57
+
58
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,119 @@
1
+ =begin
2
+ This file is a cotribution to Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2013 Mark McCahill <mark.mccahill@duke.edu>
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 EwsSoapFreeBusyResponse < EwsSoapResponse
22
+
23
+ def initialize(sax_hash)
24
+ @resp = sax_hash
25
+ simplify!
26
+ end
27
+
28
+ def envelope
29
+ @resp[:envelope][:elems]
30
+ end
31
+
32
+ def header
33
+ envelope[0][:header][:elems]
34
+ end
35
+
36
+ def body
37
+ envelope[1][:body][:elems]
38
+ end
39
+
40
+ def get_user_availability_response
41
+ body.first[:get_user_availability_response][:elems].first[:free_busy_response_array][:elems].first[:free_busy_response][:elems]
42
+ end
43
+
44
+ def response
45
+ body
46
+ end
47
+
48
+ def calendar_event_array
49
+ result = find_in_hash_list(get_user_availability_response[1][:free_busy_view][:elems], :calendar_event_array)
50
+ result ? result[:elems] : []
51
+ end
52
+
53
+ def working_hours
54
+ get_user_availability_response[1][:free_busy_view][:elems][2][:working_hours][:elems]
55
+ end
56
+
57
+ def response_message
58
+ find_in_hash_list(get_user_availability_response, :response_message)
59
+ end
60
+
61
+ def response_class
62
+ response_message[:attribs][:response_class]
63
+ end
64
+ alias :status :response_class
65
+
66
+ def response_code
67
+ result = find_in_hash_list(response_message[:elems], :response_code)
68
+ result ? result[:text] : nil
69
+ end
70
+ alias :code :response_code
71
+
72
+ def response_message_text
73
+ guard_hash response_message[:elems], [:message_text, :text]
74
+ end
75
+ alias :message :response_message_text
76
+
77
+ def response_key
78
+ response_message[:elems]
79
+ end
80
+
81
+ def success?
82
+ response_class == "Success"
83
+ end
84
+
85
+ private
86
+
87
+ def simplify!
88
+ # key = response_key
89
+ # body[0][key] = body[0][key][:elems].inject(:merge)
90
+ # response_message[:elems] = response_message[:elems].inject(:merge)
91
+ end
92
+
93
+ # If the keys don't exist in the Hash return nil
94
+ # @param[Hash] hsh
95
+ # @param[Array<Symbol,String>] keys keys to follow in the array
96
+ # @return [Object, nil]
97
+ def guard_hash(hsh, keys)
98
+ key = keys.shift
99
+ return nil unless hsh.is_a?(Hash) && hsh.has_key?(key)
100
+
101
+ if keys.empty?
102
+ hsh[key]
103
+ else
104
+ guard_hash hsh[key], keys
105
+ end
106
+ end
107
+
108
+ # Find the first element in a list of hashes or return nil
109
+ # Example:
110
+ # find_in_hash_list([{:foo => :bar}, {:bar => :baz}], :foo)
111
+ # => :bar
112
+ def find_in_hash_list(collection, key)
113
+ result = collection.find { |hsh| hsh.keys.include?(key) }
114
+ result ? result[key] : nil
115
+ end
116
+
117
+ end # EwsSoapFreeBusyResponse
118
+
119
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,103 @@
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
+ # A Generic Class for SOAP returns.
22
+ # @attr_reader [String] :message The text from the EWS element <m:ResponseCode>
23
+ class EwsSoapResponse
24
+
25
+ def initialize(sax_hash)
26
+ @resp = sax_hash
27
+ simplify!
28
+ end
29
+
30
+ def envelope
31
+ @resp[:envelope][:elems]
32
+ end
33
+
34
+ def header
35
+ envelope[0][:header][:elems]
36
+ end
37
+
38
+ def body
39
+ envelope[1][:body][:elems]
40
+ end
41
+
42
+ def response
43
+ body[0]
44
+ end
45
+
46
+ def response_messages
47
+ key = response.keys.first
48
+ response[key][:elems].find{|e| e.keys.include? :response_messages }[:response_messages][:elems]
49
+ end
50
+
51
+ def response_message
52
+ key = response_messages[0].keys.first
53
+ response_messages[0][key]
54
+ end
55
+
56
+ def response_class
57
+ response_message[:attribs][:response_class]
58
+ end
59
+ alias :status :response_class
60
+
61
+ def response_code
62
+ response_message[:elems][:response_code][:text]
63
+ end
64
+ alias :code :response_code
65
+
66
+ def response_message_text
67
+ guard_hash response_message[:elems], [:message_text, :text]
68
+ end
69
+ alias :message :response_message_text
70
+
71
+ def success?
72
+ response_class == "Success"
73
+ end
74
+
75
+
76
+ private
77
+
78
+
79
+ def simplify!
80
+ response_messages.each do |rm|
81
+ key = rm.keys.first
82
+ rm[key][:elems] = rm[key][:elems].inject(&:merge)
83
+ end
84
+ end
85
+
86
+ # If the keys don't exist in the Hash return nil
87
+ # @param[Hash] hsh
88
+ # @param[Array<Symbol,String>] keys keys to follow in the array
89
+ # @return [Object, nil]
90
+ def guard_hash(hsh, keys)
91
+ key = keys.shift
92
+ return nil unless hsh.is_a?(Hash) && hsh.has_key?(key)
93
+
94
+ if keys.empty?
95
+ hsh[key]
96
+ else
97
+ guard_hash hsh[key], keys
98
+ end
99
+ end
100
+
101
+ end # EwsSoapResponse
102
+
103
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,53 @@
1
+ =begin
2
+ This file is a contribution to Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2013 Camille Baldock <viewpoint@camillebaldock.co.uk>
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
+ # A class for roomlists SOAP returns.
22
+ # @attr_reader [String] :message The text from the EWS element <m:ResponseCode>
23
+ class EwsSoapRoomResponse < EwsSoapResponse
24
+
25
+ def response_messages
26
+ key = response.keys.first
27
+ subresponse = response[key][:elems][1]
28
+ response_class = subresponse.keys.first
29
+ subresponse[response_class][:elems]
30
+ end
31
+
32
+ def roomsArray
33
+ response[:get_rooms_response][:elems][1][:rooms][:elems]
34
+ end
35
+
36
+ def success?
37
+ response.first[1][:attribs][:response_class] == "Success"
38
+ end
39
+
40
+ private
41
+
42
+ def simplify!
43
+ if response_messages
44
+ response_messages.each do |rm|
45
+ key = rm.keys.first
46
+ rm[key][:elems] = rm[key][:elems].inject(&:merge)
47
+ end
48
+ end
49
+ end
50
+
51
+ end # EwsSoapRoomResponse
52
+
53
+ end # Viewpoint::EWS::SOAP
@@ -0,0 +1,54 @@
1
+ =begin
2
+ This file is a contribution to Viewpoint; the Ruby library for Microsoft Exchange Web Services.
3
+
4
+ Copyright © 2013 Camille Baldock <viewpoint@camillebaldock.co.uk>
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
+ # A class for roomlists SOAP returns.
22
+ # @attr_reader [String] :message The text from the EWS element <m:ResponseCode>
23
+ class EwsSoapRoomlistResponse < EwsSoapResponse
24
+
25
+ def response_messages
26
+ key = response.keys.first
27
+ subresponse = response[key][:elems][1]
28
+ response_class = subresponse.keys.first
29
+ subresponse[response_class][:elems]
30
+ end
31
+
32
+ def roomListsArray
33
+ response[:get_room_lists_response][:elems][1][:room_lists][:elems]
34
+ end
35
+
36
+ def success?
37
+ response.first[1][:attribs][:response_class] == "Success"
38
+ end
39
+
40
+ private
41
+
42
+
43
+ def simplify!
44
+ if response_messages
45
+ response_messages.each do |rm|
46
+ key = rm.keys.first
47
+ rm[key][:elems] = rm[key][:elems].inject(&:merge)
48
+ end
49
+ end
50
+ end
51
+
52
+ end # EwsSoapRoomlistResponse
53
+
54
+ end # Viewpoint::EWS::SOAP