viewpoint 1.1.1 → 2.0.0

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -8
  3. data/lib/ews/calendar_accessors.rb +37 -33
  4. data/lib/ews/connection.rb +151 -124
  5. data/lib/ews/connection_helper.rb +36 -33
  6. data/lib/ews/convert_accessors.rb +58 -54
  7. data/lib/ews/errors.rb +59 -53
  8. data/lib/ews/ews_client.rb +92 -79
  9. data/lib/ews/exceptions/exceptions.rb +61 -61
  10. data/lib/ews/folder_accessors.rb +235 -234
  11. data/lib/ews/impersonation.rb +29 -23
  12. data/lib/ews/item_accessors.rb +215 -213
  13. data/lib/ews/mailbox_accessors.rb +82 -79
  14. data/lib/ews/meeting_accessors.rb +38 -31
  15. data/lib/ews/message_accessors.rb +83 -81
  16. data/lib/ews/push_subscription_accessors.rb +29 -27
  17. data/lib/ews/room_accessors.rb +48 -46
  18. data/lib/ews/roomlist_accessors.rb +47 -45
  19. data/lib/ews/soap/builders/ews_builder.rb +1186 -1188
  20. data/lib/ews/soap/ews_response.rb +68 -73
  21. data/lib/ews/soap/ews_soap_availability_response.rb +57 -57
  22. data/lib/ews/soap/ews_soap_free_busy_response.rb +115 -117
  23. data/lib/ews/soap/ews_soap_response.rb +99 -101
  24. data/lib/ews/soap/ews_soap_room_response.rb +45 -45
  25. data/lib/ews/soap/ews_soap_roomlist_response.rb +45 -46
  26. data/lib/ews/soap/exchange_availability.rb +54 -52
  27. data/lib/ews/soap/exchange_data_services.rb +693 -711
  28. data/lib/ews/soap/exchange_notification.rb +123 -128
  29. data/lib/ews/soap/exchange_synchronization.rb +82 -82
  30. data/lib/ews/soap/exchange_time_zones.rb +41 -44
  31. data/lib/ews/soap/exchange_user_configuration.rb +30 -27
  32. data/lib/ews/soap/exchange_web_service.rb +237 -233
  33. data/lib/ews/soap/parsers/ews_parser.rb +46 -42
  34. data/lib/ews/soap/parsers/ews_sax_document.rb +63 -58
  35. data/lib/ews/soap/response_message.rb +69 -68
  36. data/lib/ews/soap/responses/create_attachment_response_message.rb +45 -45
  37. data/lib/ews/soap/responses/create_item_response_message.rb +26 -25
  38. data/lib/ews/soap/responses/find_item_response_message.rb +76 -78
  39. data/lib/ews/soap/responses/get_events_response_message.rb +52 -51
  40. data/lib/ews/soap/responses/send_notification_response_message.rb +53 -51
  41. data/lib/ews/soap/responses/subscribe_response_message.rb +37 -34
  42. data/lib/ews/soap/responses/sync_folder_hierarchy_response_message.rb +38 -35
  43. data/lib/ews/soap/responses/sync_folder_items_response_message.rb +38 -35
  44. data/lib/ews/soap.rb +27 -26
  45. data/lib/ews/templates/calendar_item.rb +64 -60
  46. data/lib/ews/templates/forward_item.rb +19 -17
  47. data/lib/ews/templates/message.rb +61 -67
  48. data/lib/ews/templates/reply_to_item.rb +20 -18
  49. data/lib/ews/templates/task.rb +55 -55
  50. data/lib/ews/types/attachment.rb +75 -74
  51. data/lib/ews/types/attendee.rb +27 -25
  52. data/lib/ews/types/calendar_folder.rb +60 -44
  53. data/lib/ews/types/calendar_item.rb +134 -116
  54. data/lib/ews/types/contact.rb +11 -5
  55. data/lib/ews/types/contacts_folder.rb +10 -5
  56. data/lib/ews/types/copied_event.rb +47 -48
  57. data/lib/ews/types/created_event.rb +22 -20
  58. data/lib/ews/types/deleted_event.rb +22 -20
  59. data/lib/ews/types/distribution_list.rb +11 -5
  60. data/lib/ews/types/event.rb +60 -59
  61. data/lib/ews/types/export_items_response_message.rb +54 -50
  62. data/lib/ews/types/file_attachment.rb +63 -61
  63. data/lib/ews/types/folder.rb +58 -57
  64. data/lib/ews/types/free_busy_changed_event.rb +22 -20
  65. data/lib/ews/types/generic_folder.rb +348 -372
  66. data/lib/ews/types/item.rb +401 -397
  67. data/lib/ews/types/item_attachment.rb +87 -80
  68. data/lib/ews/types/item_field_uri_map.rb +201 -200
  69. data/lib/ews/types/mailbox_user.rb +146 -154
  70. data/lib/ews/types/meeting_cancellation.rb +11 -5
  71. data/lib/ews/types/meeting_message.rb +11 -5
  72. data/lib/ews/types/meeting_request.rb +11 -5
  73. data/lib/ews/types/meeting_response.rb +11 -5
  74. data/lib/ews/types/message.rb +11 -5
  75. data/lib/ews/types/modified_event.rb +43 -45
  76. data/lib/ews/types/moved_event.rb +47 -48
  77. data/lib/ews/types/new_mail_event.rb +22 -20
  78. data/lib/ews/types/out_of_office.rb +145 -144
  79. data/lib/ews/types/post_item.rb +11 -5
  80. data/lib/ews/types/search_folder.rb +10 -5
  81. data/lib/ews/types/status_event.rb +37 -36
  82. data/lib/ews/types/task.rb +39 -33
  83. data/lib/ews/types/tasks_folder.rb +32 -22
  84. data/lib/ews/types.rb +134 -139
  85. data/lib/viewpoint/logging/config.rb +19 -19
  86. data/lib/viewpoint/logging.rb +23 -17
  87. data/lib/viewpoint/string_utils.rb +31 -32
  88. data/lib/viewpoint.rb +18 -18
  89. metadata +82 -11
  90. data/Changelog.txt +0 -1004
@@ -1,39 +1,46 @@
1
- module Viewpoint::EWS::MeetingAccessors
2
- include Viewpoint::EWS
3
-
4
- def accept_meeting(opts)
5
- ews.create_item({
6
- message_disposition: 'SendOnly',
7
- items: [ { accept_item: opts_to_item(opts) } ]
8
- })
9
- end
1
+ # frozen_string_literal: true
10
2
 
11
- def decline_meeting(opts)
12
- ews.create_item({
13
- message_disposition: 'SendOnly',
14
- items: [ { decline_item: opts_to_item(opts) } ]
15
- })
16
- end
3
+ module Viewpoint
4
+ module EWS
5
+ # Meeting operations mixed into the EWS client.
6
+ module MeetingAccessors
7
+ include Viewpoint::EWS
17
8
 
18
- def tentatively_accept_meeting(opts)
19
- ews.create_item({
20
- message_disposition: 'SendOnly',
21
- items: [ { tentatively_accept_item: opts_to_item(opts) } ]
22
- })
23
- end
9
+ def accept_meeting(opts)
10
+ ews.create_item({
11
+ message_disposition: 'SendOnly',
12
+ items: [{ accept_item: opts_to_item(opts) }]
13
+ })
14
+ end
15
+
16
+ def decline_meeting(opts)
17
+ ews.create_item({
18
+ message_disposition: 'SendOnly',
19
+ items: [{ decline_item: opts_to_item(opts) }]
20
+ })
21
+ end
22
+
23
+ def tentatively_accept_meeting(opts)
24
+ ews.create_item({
25
+ message_disposition: 'SendOnly',
26
+ items: [{ tentatively_accept_item: opts_to_item(opts) }]
27
+ })
28
+ end
24
29
 
25
- private
30
+ private
26
31
 
27
- def opts_to_item(opts)
28
- hash = {
29
- id: opts[:id],
30
- change_key: opts[:change_key],
31
- sensitivity: opts[:sensitivity]
32
- }
32
+ def opts_to_item(opts)
33
+ hash = {
34
+ id: opts[:id],
35
+ change_key: opts[:change_key],
36
+ sensitivity: opts[:sensitivity]
37
+ }
33
38
 
34
- hash[:text] = opts[:text] if opts[:text]
35
- hash[:body_type] = (opts[:body_type] || 'Text') if opts[:text]
39
+ hash[:text] = opts[:text] if opts[:text]
40
+ hash[:body_type] = (opts[:body_type] || 'Text') if opts[:text]
36
41
 
37
- hash
42
+ hash
43
+ end
44
+ end
38
45
  end
39
46
  end
@@ -1,93 +1,95 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
1
+ # frozen_string_literal: true
3
2
 
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
3
+ # This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
4
+ #
5
+ # Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ module Viewpoint
19
+ module EWS
20
+ # Message operations mixed into the EWS client.
21
+ module MessageAccessors
22
+ include Viewpoint::EWS
5
23
 
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
24
+ # Send an E-mail message
25
+ #
26
+ # @param [Hash] opts A Hash with message params
27
+ # @option opts [String] :subject The message subject
28
+ # @option opts [String] :body The message body
29
+ # @option opts [Array] :to_recipients An array of e-mail addresses to send to
30
+ # @option opts [Array] :cc_recipients An array of e-mail addresses to send to
31
+ # @option opts [Array] :bcc_recipients An array of e-mail addresses to send to
32
+ # @option opts [Array] :extended_properties An array of extended properties
33
+ # [{extended_field_uri: {epros}, value: <val>}] or values: [<val>, <val>]
34
+ # @option opts [Boolean] :draft if true it will save to the draft folder
35
+ # without sending the message.
36
+ # @option opts [String,Symbol,Hash] saved_item_folder_id Either a
37
+ # FolderId(String) or a DistinguishedFolderId(Symbol). You can also pass a
38
+ # Hash in the form: {id: <fold_id>, change_key: <change_key>}
39
+ # @option opts [Array<File>] :file_attachments an Array of File or Tempfile objects
40
+ # @option opts [Array<File>] :inline_attachments an Array of Inline File or Tempfile objects
41
+ # @return [Message,Boolean] Returns true if the message is sent, false if
42
+ # nothing is returned from EWS or if draft is true it will return the
43
+ # Message object. Finally, if something goes wrong, it raises an error
44
+ # with a message stating why the e-mail could not be sent.
45
+ # @todo Finish ItemAttachments
46
+ def send_message(opts = {}, &block)
47
+ msg = Template::Message.new opts.clone
48
+ yield msg if block_given?
49
+ if msg.has_attachments?
50
+ draft = msg.draft
51
+ resp = parse_create_item(ews.create_item(msg.to_ews))
52
+ msg.draft = true
53
+ msg.file_attachments.each do |f|
54
+ next unless f.is_a?(File) || f.is_a?(Tempfile)
9
55
 
10
- http://www.apache.org/licenses/LICENSE-2.0
56
+ resp.add_file_attachment(f)
57
+ end
58
+ msg.inline_attachments.each do |f|
59
+ next unless f.is_a?(File) || f.is_a?(Tempfile)
11
60
 
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
- module Viewpoint::EWS::MessageAccessors
19
- include Viewpoint::EWS
20
-
21
- # Send an E-mail message
22
- #
23
- # @param [Hash] opts A Hash with message params
24
- # @option opts [String] :subject The message subject
25
- # @option opts [String] :body The message body
26
- # @option opts [Array] :to_recipients An array of e-mail addresses to send to
27
- # @option opts [Array] :cc_recipients An array of e-mail addresses to send to
28
- # @option opts [Array] :bcc_recipients An array of e-mail addresses to send to
29
- # @option opts [Array] :extended_properties An array of extended properties
30
- # [{extended_field_uri: {epros}, value: <val>}] or values: [<val>, <val>]
31
- # @option opts [Boolean] :draft if true it will save to the draft folder
32
- # without sending the message.
33
- # @option opts [String,Symbol,Hash] saved_item_folder_id Either a
34
- # FolderId(String) or a DistinguishedFolderId(Symbol). You can also pass a
35
- # Hash in the form: {id: <fold_id>, change_key: <change_key>}
36
- # @option opts [Array<File>] :file_attachments an Array of File or Tempfile objects
37
- # @option opts [Array<File>] :inline_attachments an Array of Inline File or Tempfile objects
38
- # @return [Message,Boolean] Returns true if the message is sent, false if
39
- # nothing is returned from EWS or if draft is true it will return the
40
- # Message object. Finally, if something goes wrong, it raises an error
41
- # with a message stating why the e-mail could not be sent.
42
- # @todo Finish ItemAttachments
43
- def send_message(opts = {}, &block)
44
- msg = Template::Message.new opts.clone
45
- yield msg if block_given?
46
- if msg.has_attachments?
47
- draft = msg.draft
48
- msg.draft = true
49
- resp = parse_create_item(ews.create_item(msg.to_ews))
50
- msg.file_attachments.each do |f|
51
- next unless f.kind_of?(File) or f.kind_of?(Tempfile)
52
- resp.add_file_attachment(f)
53
- end
54
- msg.inline_attachments.each do |f|
55
- next unless f.kind_of?(File) or f.kind_of?(Tempfile)
56
- resp.add_inline_attachment(f)
57
- end
58
- if draft
59
- resp.submit_attachments!
60
- resp
61
- else
62
- resp.submit!
61
+ resp.add_inline_attachment(f)
62
+ end
63
+ if draft
64
+ resp.submit_attachments!
65
+ resp
66
+ else
67
+ resp.submit!
68
+ end
69
+ else
70
+ resp = ews.create_item(msg.to_ews)
71
+ resp.response_messages ? parse_create_item(resp) : false
72
+ end
63
73
  end
64
- else
65
- resp = ews.create_item(msg.to_ews)
66
- resp.response_messages ? parse_create_item(resp) : false
67
- end
68
- end
69
74
 
70
- # See #send_message for options
71
- def draft_message(opts = {}, &block)
72
- send_message opts.merge(draft: true), &block
73
- end
75
+ # See #send_message for options
76
+ def draft_message(opts = {}, &block)
77
+ send_message opts.merge(draft: true), &block
78
+ end
74
79
 
80
+ private
75
81
 
76
- private
82
+ def parse_create_item(resp)
83
+ rm = resp.response_messages[0]
84
+ raise EwsError, "Could not send message. #{rm.code}: #{rm.message_text}" unless rm.status == 'Success'
77
85
 
86
+ rm.items.empty? || parse_message(rm.items.first)
87
+ end
78
88
 
79
- def parse_create_item(resp)
80
- rm = resp.response_messages[0]
81
- if(rm.status == 'Success')
82
- rm.items.empty? ? true : parse_message(rm.items.first)
83
- else
84
- raise EwsError, "Could not send message. #{rm.code}: #{rm.message_text}"
89
+ def parse_message(msg)
90
+ mtype = msg.keys.first
91
+ class_by_name(mtype).new(ews, msg[mtype])
92
+ end
85
93
  end
86
94
  end
87
-
88
- def parse_message(msg)
89
- mtype = msg.keys.first
90
- message = class_by_name(mtype).new(ews, msg[mtype])
91
- end
92
-
93
- end # Viewpoint::EWS::MessageAccessors
95
+ end
@@ -1,33 +1,35 @@
1
- =begin
2
- This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
1
+ # frozen_string_literal: true
3
2
 
4
- Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
3
+ # This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
4
+ #
5
+ # Copyright © 2011 Dan Wanek <dan.wanek@gmail.com>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
5
18
 
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
19
+ module Viewpoint
20
+ module EWS
21
+ # Push Subscription operations mixed into the EWS client.
22
+ module PushSubscriptionAccessors
23
+ include Viewpoint::EWS
9
24
 
10
- http://www.apache.org/licenses/LICENSE-2.0
25
+ def parse_send_notification(msg)
26
+ parser = Viewpoint::EWS::SOAP::EwsParser.new(msg)
27
+ resp = parser.parse response_class: Viewpoint::EWS::SOAP::EwsResponse
28
+ rmsg = resp.response_messages[0]
29
+ raise EwsSubscriptionError, "#{rmsg.code}: #{rmsg.message_text}" unless rmsg.success?
11
30
 
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::PushSubscriptionAccessors
20
- include Viewpoint::EWS
21
-
22
- def parse_send_notification(msg)
23
- parser = Viewpoint::EWS::SOAP::EwsParser.new(msg)
24
- resp = parser.parse response_class: Viewpoint::EWS::SOAP::EwsResponse
25
- rmsg = resp.response_messages[0]
26
- if rmsg.success?
27
- rmsg
28
- else
29
- raise EwsSubscriptionError, "#{rmsg.code}: #{rmsg.message_text}"
31
+ rmsg
32
+ end
30
33
  end
31
34
  end
32
-
33
- end # Viewpoint::EWS::PushSubscriptionAccessors
35
+ end
@@ -1,48 +1,50 @@
1
- =begin
2
- This file is part of 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::RoomAccessors
20
- include Viewpoint::EWS
21
-
22
- # Gets the rooms that are available within the specified room distribution list
23
- # @see http://msdn.microsoft.com/en-us/library/dd899415.aspx
24
- # @param [String] roomDistributionList
25
- def get_rooms(roomDistributionList)
26
- resp = ews.get_rooms(roomDistributionList)
27
- get_rooms_parser(resp)
28
- end
29
-
30
- def room_name( room )
31
- room[:room][:elems][:id][:elems][0][:name][:text]
32
- end
33
-
34
- def room_email( room )
35
- room[:room][:elems][:id][:elems][1][:email_address][:text]
36
- end
37
-
38
- private
39
-
40
- def get_rooms_parser(resp)
41
- if resp.success?
42
- resp
43
- else
44
- raise EwsError, "GetRooms produced an error: #{resp.code}: #{resp.message}"
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
4
+ #
5
+ # Copyright © 2013 Camille Baldock <viewpoint@camillebaldock.co.uk>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ module Viewpoint
20
+ module EWS
21
+ # Room operations mixed into the EWS client.
22
+ module RoomAccessors
23
+ include Viewpoint::EWS
24
+
25
+ # Gets the rooms that are available within the specified room distribution list
26
+ # @see http://msdn.microsoft.com/en-us/library/dd899415.aspx
27
+ # @param [String] room_distribution_list
28
+ def get_rooms(room_distribution_list)
29
+ resp = ews.get_rooms(room_distribution_list)
30
+ get_rooms_parser(resp)
31
+ end
32
+
33
+ def room_name(room)
34
+ room[:room][:elems][:id][:elems][0][:name][:text]
35
+ end
36
+
37
+ def room_email(room)
38
+ room[:room][:elems][:id][:elems][1][:email_address][:text]
39
+ end
40
+
41
+ private
42
+
43
+ def get_rooms_parser(resp)
44
+ raise EwsError, "GetRooms produced an error: #{resp.code}: #{resp.message}" unless resp.success?
45
+
46
+ resp
47
+ end
45
48
  end
46
49
  end
47
-
48
- end # Viewpoint::EWS::RoomAccessors
50
+ end
@@ -1,47 +1,49 @@
1
- =begin
2
- This file is part of 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::RoomlistAccessors
20
- include Viewpoint::EWS
21
-
22
- # Gets the room lists that are available within the Exchange organization.
23
- # @see http://msdn.microsoft.com/en-us/library/dd899416.aspx
24
- def get_room_lists
25
- resp = ews.get_room_lists
26
- get_room_lists_parser(resp)
27
- end
28
-
29
- def roomlist_name( roomlist )
30
- roomlist[:address][:elems][:name][:text]
31
- end
32
-
33
- def roomlist_email( roomlist )
34
- roomlist[:address][:elems][:email_address][:text]
35
- end
36
-
37
- private
38
-
39
- def get_room_lists_parser(resp)
40
- if resp.success?
41
- resp
42
- else
43
- raise EwsError, "GetRoomLists produced an error: #{resp.code}: #{resp.message}"
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Viewpoint; the Ruby library for Microsoft Exchange Web Services.
4
+ #
5
+ # Copyright © 2013 Camille Baldock <viewpoint@camillebaldock.co.uk>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ module Viewpoint
20
+ module EWS
21
+ # Roomlist operations mixed into the EWS client.
22
+ module RoomlistAccessors
23
+ include Viewpoint::EWS
24
+
25
+ # Gets the room lists that are available within the Exchange organization.
26
+ # @see http://msdn.microsoft.com/en-us/library/dd899416.aspx
27
+ def get_room_lists # rubocop:disable Naming/AccessorMethodName -- public API name
28
+ resp = ews.get_room_lists
29
+ get_room_lists_parser(resp)
30
+ end
31
+
32
+ def roomlist_name(roomlist)
33
+ roomlist[:address][:elems][:name][:text]
34
+ end
35
+
36
+ def roomlist_email(roomlist)
37
+ roomlist[:address][:elems][:email_address][:text]
38
+ end
39
+
40
+ private
41
+
42
+ def get_room_lists_parser(resp)
43
+ raise EwsError, "GetRoomLists produced an error: #{resp.code}: #{resp.message}" unless resp.success?
44
+
45
+ resp
46
+ end
44
47
  end
45
48
  end
46
-
47
- end # Viewpoint::EWS::RoomlistAccessors
49
+ end