viewpoint_reloaded 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/Changelog.txt +1004 -0
  3. data/README.md +201 -0
  4. data/TODO +17 -0
  5. data/lib/ews/calendar_accessors.rb +34 -0
  6. data/lib/ews/connection.rb +130 -0
  7. data/lib/ews/connection_helper.rb +35 -0
  8. data/lib/ews/convert_accessors.rb +56 -0
  9. data/lib/ews/errors.rb +56 -0
  10. data/lib/ews/ews_client.rb +103 -0
  11. data/lib/ews/exceptions/exceptions.rb +61 -0
  12. data/lib/ews/folder_accessors.rb +264 -0
  13. data/lib/ews/impersonation.rb +30 -0
  14. data/lib/ews/item_accessors.rb +231 -0
  15. data/lib/ews/mailbox_accessors.rb +92 -0
  16. data/lib/ews/message_accessors.rb +93 -0
  17. data/lib/ews/push_subscription_accessors.rb +33 -0
  18. data/lib/ews/room_accessors.rb +48 -0
  19. data/lib/ews/roomlist_accessors.rb +47 -0
  20. data/lib/ews/soap.rb +64 -0
  21. data/lib/ews/soap/builders/ews_builder.rb +1266 -0
  22. data/lib/ews/soap/ews_response.rb +84 -0
  23. data/lib/ews/soap/ews_soap_availability_response.rb +58 -0
  24. data/lib/ews/soap/ews_soap_free_busy_response.rb +119 -0
  25. data/lib/ews/soap/ews_soap_response.rb +103 -0
  26. data/lib/ews/soap/ews_soap_room_response.rb +53 -0
  27. data/lib/ews/soap/ews_soap_roomlist_response.rb +54 -0
  28. data/lib/ews/soap/exchange_availability.rb +61 -0
  29. data/lib/ews/soap/exchange_data_services.rb +780 -0
  30. data/lib/ews/soap/exchange_notification.rb +146 -0
  31. data/lib/ews/soap/exchange_synchronization.rb +93 -0
  32. data/lib/ews/soap/exchange_time_zones.rb +56 -0
  33. data/lib/ews/soap/exchange_user_configuration.rb +33 -0
  34. data/lib/ews/soap/exchange_web_service.rb +264 -0
  35. data/lib/ews/soap/parsers/ews_parser.rb +43 -0
  36. data/lib/ews/soap/parsers/ews_sax_document.rb +70 -0
  37. data/lib/ews/soap/response_message.rb +80 -0
  38. data/lib/ews/soap/responses/create_attachment_response_message.rb +47 -0
  39. data/lib/ews/soap/responses/create_item_response_message.rb +25 -0
  40. data/lib/ews/soap/responses/find_item_response_message.rb +80 -0
  41. data/lib/ews/soap/responses/get_events_response_message.rb +53 -0
  42. data/lib/ews/soap/responses/send_notification_response_message.rb +59 -0
  43. data/lib/ews/soap/responses/subscribe_response_message.rb +35 -0
  44. data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +36 -0
  45. data/lib/ews/soap/responses/sync_folder_items_response_message.rb +36 -0
  46. data/lib/ews/templates/calendar_item.rb +79 -0
  47. data/lib/ews/templates/forward_item.rb +24 -0
  48. data/lib/ews/templates/message.rb +73 -0
  49. data/lib/ews/templates/reply_to_item.rb +25 -0
  50. data/lib/ews/templates/task.rb +74 -0
  51. data/lib/ews/types.rb +194 -0
  52. data/lib/ews/types/attachment.rb +77 -0
  53. data/lib/ews/types/attendee.rb +27 -0
  54. data/lib/ews/types/calendar_folder.rb +50 -0
  55. data/lib/ews/types/calendar_item.rb +130 -0
  56. data/lib/ews/types/contact.rb +7 -0
  57. data/lib/ews/types/contacts_folder.rb +8 -0
  58. data/lib/ews/types/copied_event.rb +51 -0
  59. data/lib/ews/types/created_event.rb +24 -0
  60. data/lib/ews/types/deleted_event.rb +24 -0
  61. data/lib/ews/types/distribution_list.rb +7 -0
  62. data/lib/ews/types/event.rb +62 -0
  63. data/lib/ews/types/export_items_response_message.rb +52 -0
  64. data/lib/ews/types/file_attachment.rb +65 -0
  65. data/lib/ews/types/folder.rb +60 -0
  66. data/lib/ews/types/free_busy_changed_event.rb +24 -0
  67. data/lib/ews/types/generic_folder.rb +418 -0
  68. data/lib/ews/types/item.rb +441 -0
  69. data/lib/ews/types/item_attachment.rb +84 -0
  70. data/lib/ews/types/item_field_uri_map.rb +208 -0
  71. data/lib/ews/types/mailbox_user.rb +156 -0
  72. data/lib/ews/types/meeting_cancellation.rb +7 -0
  73. data/lib/ews/types/meeting_message.rb +7 -0
  74. data/lib/ews/types/meeting_request.rb +7 -0
  75. data/lib/ews/types/meeting_response.rb +7 -0
  76. data/lib/ews/types/message.rb +7 -0
  77. data/lib/ews/types/modified_event.rb +48 -0
  78. data/lib/ews/types/moved_event.rb +51 -0
  79. data/lib/ews/types/new_mail_event.rb +24 -0
  80. data/lib/ews/types/out_of_office.rb +147 -0
  81. data/lib/ews/types/search_folder.rb +8 -0
  82. data/lib/ews/types/status_event.rb +39 -0
  83. data/lib/ews/types/task.rb +41 -0
  84. data/lib/ews/types/tasks_folder.rb +27 -0
  85. data/lib/viewpoint.rb +109 -0
  86. data/lib/viewpoint/logging.rb +27 -0
  87. data/lib/viewpoint/logging/config.rb +24 -0
  88. data/lib/viewpoint/string_utils.rb +76 -0
  89. metadata +192 -0
@@ -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 MovedEvent < Event
22
+
23
+ MOVED_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
+ MOVED_EVENT_KEY_TYPES = {
30
+ }
31
+
32
+ MOVED_EVENT_KEY_ALIAS = { }
33
+
34
+
35
+ private
36
+
37
+
38
+ def key_paths
39
+ @key_paths ||= super.merge MOVED_EVENT_KEY_PATHS
40
+ end
41
+
42
+ def key_types
43
+ @key_types ||= super.merge MOVED_EVENT_KEY_TYPES
44
+ end
45
+
46
+ def key_alias
47
+ @key_alias ||= super.merge MOVED_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 NewMailEvent < Event
22
+
23
+ end
24
+ end
@@ -0,0 +1,147 @@
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
+ OOF_KEY_PATHS = {
22
+ :enabled? => [:oof_settings, :oof_state],
23
+ :scheduled? => [:oof_settings, :oof_state],
24
+ :duration => [:oof_settings, :duration],
25
+ }
26
+
27
+ OOF_KEY_TYPES = {
28
+ :enabled? => ->(str){str == :enabled},
29
+ :scheduled? => ->(str){str == :scheduled},
30
+ :duration => ->(hsh){ hsh[:start_time]..hsh[:end_time] },
31
+ }
32
+
33
+ OOF_KEY_ALIAS = {}
34
+
35
+ # This represents OutOfOffice settings
36
+ # @see http://msdn.microsoft.com/en-us/library/aa563465.aspx
37
+ class OutOfOffice
38
+ include Viewpoint::EWS
39
+ include Viewpoint::EWS::Types
40
+
41
+ attr_reader :user
42
+
43
+ # @param [MailboxUser] user
44
+ # @param [Hash] ews_item
45
+ def initialize(user, ews_item)
46
+ @ews = user.ews
47
+ @user = user
48
+ @ews_item = ews_item
49
+ @changed = false
50
+ simplify!
51
+ end
52
+
53
+ def changed?
54
+ @changed
55
+ end
56
+
57
+ def save!
58
+ return true unless changed?
59
+ opts = { mailbox: {address: user.email_address} }.merge(@ews_item[:oof_settings])
60
+ resp = @ews.set_user_oof_settings(opts)
61
+ if resp.success?
62
+ @changed = false
63
+ true
64
+ else
65
+ raise SaveFailed, "Could not save #{self.class}. #{resp.code}: #{resp.message}"
66
+ end
67
+ 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
@@ -0,0 +1,8 @@
1
+ module Viewpoint::EWS::Types
2
+ class SearchFolder
3
+ include Viewpoint::EWS
4
+ include Viewpoint::EWS::Types
5
+ include Viewpoint::EWS::Types::GenericFolder
6
+
7
+ end
8
+ end
@@ -0,0 +1,39 @@
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 StatusEvent
22
+ include Viewpoint::EWS
23
+ include Viewpoint::EWS::Types
24
+ include Viewpoint::EWS::Types::Item
25
+
26
+ STATUS_EVENT_KEY_PATHS = {
27
+ :watermark => [:watermark, :text],
28
+ }
29
+
30
+
31
+ private
32
+
33
+
34
+ def key_paths
35
+ @key_paths ||= STATUS_EVENT_KEY_PATHS
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ module Viewpoint::EWS::Types
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
+ }
17
+
18
+ TASK_KEY_TYPES = {
19
+ recurring?: ->(str){str.downcase == 'true'},
20
+ complete?: ->(str){str.downcase == 'true'},
21
+ reminder?: ->(str){str.downcase == 'true'},
22
+ percent_complete: ->(str){str.to_i},
23
+ }
24
+ TASK_KEY_ALIAS = {}
25
+
26
+ private
27
+
28
+ def key_paths
29
+ super.merge(TASK_KEY_PATHS)
30
+ end
31
+
32
+ def key_types
33
+ super.merge(TASK_KEY_TYPES)
34
+ end
35
+
36
+ def key_alias
37
+ super.merge(TASK_KEY_ALIAS)
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,27 @@
1
+ module Viewpoint::EWS::Types
2
+ class TasksFolder
3
+ include Viewpoint::EWS
4
+ include Viewpoint::EWS::Types
5
+ include Viewpoint::EWS::Types::GenericFolder
6
+
7
+ # Creates a new task
8
+ # @param attributes [Hash] Parameters of the task. Some example attributes are listed below.
9
+ # @option attributes :subject [String]
10
+ # @option attributes :start_date [Time]
11
+ # @option attributes :due_date [Time]
12
+ # @option attributes :reminder_due_by [Time]
13
+ # @option attributes :reminder_is_set [Boolean]
14
+ # @return [Task]
15
+ # @see Template::Task
16
+ def create_item(attributes)
17
+ template = Viewpoint::EWS::Template::Task.new attributes
18
+ template.saved_item_folder_id = {id: self.id, change_key: self.change_key}
19
+ rm = ews.create_item(template.to_ews_create).response_messages.first
20
+ if rm && rm.success?
21
+ Task.new ews, rm.items.first[:task][:elems].first
22
+ else
23
+ raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" unless rm
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,109 @@
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
+ require 'kconv' if(RUBY_VERSION.start_with? '1.9') # bug in rubyntlm with ruby 1.9.x
20
+ require 'date'
21
+ require 'base64'
22
+ require 'nokogiri'
23
+ require 'ostruct'
24
+ require 'logging'
25
+
26
+ # String utilities
27
+ require 'viewpoint/string_utils'
28
+
29
+ # Load the logging setup
30
+ require 'viewpoint/logging'
31
+
32
+ # Load the Exception classes
33
+ require 'ews/exceptions/exceptions'
34
+
35
+ # Load the backend SOAP / EWS infrastructure.
36
+ require 'ews/soap'
37
+ require 'ews/soap/response_message'
38
+ require 'ews/soap/ews_response'
39
+ require 'ews/soap/ews_soap_response'
40
+ require 'ews/soap/ews_soap_availability_response'
41
+ require 'ews/soap/ews_soap_free_busy_response'
42
+ require 'ews/soap/ews_soap_room_response'
43
+ require 'ews/soap/ews_soap_roomlist_response'
44
+ require 'ews/soap/builders/ews_builder'
45
+ require 'ews/soap/parsers/ews_parser'
46
+ require 'ews/soap/parsers/ews_sax_document'
47
+ # Mix-ins for the ExchangeWebService
48
+ require 'ews/soap/exchange_data_services'
49
+ require 'ews/soap/exchange_notification'
50
+ require 'ews/soap/exchange_synchronization'
51
+ require 'ews/soap/exchange_availability'
52
+ require 'ews/soap/exchange_user_configuration'
53
+ require 'ews/soap/exchange_time_zones'
54
+ require 'ews/soap/exchange_web_service'
55
+
56
+ require 'ews/errors'
57
+ require 'ews/connection_helper'
58
+ require 'ews/connection'
59
+
60
+ require 'ews/impersonation'
61
+
62
+ # Base Types
63
+ require 'ews/types'
64
+ require 'ews/types/item_field_uri_map'
65
+ require 'ews/types/generic_folder'
66
+ require 'ews/types/item'
67
+ # Folders
68
+ require 'ews/types/folder'
69
+ require 'ews/types/calendar_folder'
70
+ require 'ews/types/contacts_folder'
71
+ require 'ews/types/tasks_folder'
72
+ require 'ews/types/search_folder'
73
+ # Items
74
+ require 'ews/types/message'
75
+ require 'ews/types/calendar_item'
76
+ require 'ews/types/contact'
77
+ require 'ews/types/distribution_list'
78
+ require 'ews/types/meeting_message'
79
+ require 'ews/types/meeting_request'
80
+ require 'ews/types/meeting_response'
81
+ require 'ews/types/meeting_cancellation'
82
+ require 'ews/types/task'
83
+ require 'ews/types/attachment'
84
+ require 'ews/types/file_attachment'
85
+ require 'ews/types/item_attachment'
86
+ require 'ews/types/mailbox_user'
87
+ require 'ews/types/out_of_office'
88
+ require 'ews/types/export_items_response_message'
89
+
90
+ # Events
91
+ require 'ews/types/event'
92
+ require 'ews/types/copied_event'
93
+ require 'ews/types/created_event'
94
+ require 'ews/types/deleted_event'
95
+ require 'ews/types/free_busy_changed_event'
96
+ require 'ews/types/modified_event'
97
+ require 'ews/types/moved_event'
98
+ require 'ews/types/new_mail_event'
99
+ require 'ews/types/status_event'
100
+
101
+ # Template Objects
102
+ require 'ews/templates/message'
103
+ require 'ews/templates/forward_item'
104
+ require 'ews/templates/reply_to_item'
105
+ require 'ews/templates/calendar_item'
106
+ require 'ews/templates/task'
107
+
108
+ # The proxy between the models and the web service
109
+ require 'ews/ews_client'