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