zm-ruby-client 3.0.1 → 3.1.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 (229) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +96 -0
  3. data/README.md +128 -27
  4. data/VERSION +1 -1
  5. data/lib/zm/client/account/account.rb +12 -19
  6. data/lib/zm/client/account/account_aliases_collection.rb +6 -4
  7. data/lib/zm/client/account/account_dls_membership_collection.rb +4 -3
  8. data/lib/zm/client/account/account_dls_owner_collection.rb +3 -2
  9. data/lib/zm/client/account/account_jsns_builder.rb +10 -10
  10. data/lib/zm/client/account/accounts_collection.rb +27 -16
  11. data/lib/zm/client/ace/ace.rb +3 -6
  12. data/lib/zm/client/ace/ace_jsns_builder.rb +6 -6
  13. data/lib/zm/client/appointment/appointment.rb +32 -14
  14. data/lib/zm/client/appointment/appointment_jsns_builder.rb +5 -5
  15. data/lib/zm/client/appointment/appointment_jsns_initializer.rb +6 -1
  16. data/lib/zm/client/appointment/appointments_collection.rb +12 -9
  17. data/lib/zm/client/backup/backup.rb +5 -2
  18. data/lib/zm/client/backup/backups_collection.rb +3 -2
  19. data/lib/zm/client/base/account_objects_collection.rb +1 -0
  20. data/lib/zm/client/base/account_search_objects_collection.rb +6 -6
  21. data/lib/zm/client/base/admin_objects_collection.rb +60 -7
  22. data/lib/zm/client/base/base_account_jsns_builder.rb +89 -87
  23. data/lib/zm/client/base/base_jsns_builder.rb +3 -3
  24. data/lib/zm/client/base/base_jsns_initializer.rb +20 -15
  25. data/lib/zm/client/base/mailbox_infos_collection.rb +92 -90
  26. data/lib/zm/client/base/mailbox_object.rb +49 -160
  27. data/lib/zm/client/base/mailbox_prefs_collection.rb +54 -52
  28. data/lib/zm/client/base/object.rb +19 -2
  29. data/lib/zm/client/base/objects_collection.rb +10 -10
  30. data/lib/zm/client/base/zimbra_attribute.rb +28 -42
  31. data/lib/zm/client/base/zimbra_attributes_collection.rb +38 -24
  32. data/lib/zm/client/{cluster/batch_request.rb → batch_request.rb} +1 -1
  33. data/lib/zm/client/cluster/cluster.rb +24 -61
  34. data/lib/zm/client/cluster/cluster_config.rb +35 -15
  35. data/lib/zm/client/contact/contact.rb +15 -13
  36. data/lib/zm/client/contact/contact_jsns_builder.rb +9 -6
  37. data/lib/zm/client/contact/contact_jsns_initializer.rb +2 -2
  38. data/lib/zm/client/contact/contact_member.rb +3 -3
  39. data/lib/zm/client/contact/contact_members_collection.rb +3 -3
  40. data/lib/zm/client/contact/contacts_builder.rb +1 -1
  41. data/lib/zm/client/contact/contacts_collection.rb +2 -2
  42. data/lib/zm/client/contact/group_contact_jsns_builder.rb +18 -14
  43. data/lib/zm/client/contact/mod_group_contact.rb +12 -8
  44. data/lib/zm/client/cos/cos.rb +15 -31
  45. data/lib/zm/client/cos/cos_jsns_builder.rb +21 -21
  46. data/lib/zm/client/cos/coses_collection.rb +11 -6
  47. data/lib/zm/client/datasource/datasource.rb +3 -9
  48. data/lib/zm/client/datasource/datasource_jsns_builder.rb +4 -4
  49. data/lib/zm/client/datasource/datasources_builder.rb +1 -1
  50. data/lib/zm/client/datasource/datasources_collection.rb +2 -2
  51. data/lib/zm/client/deprecated_constants.rb +36 -0
  52. data/lib/zm/client/distributionlist/distributionlist.rb +15 -47
  53. data/lib/zm/client/distributionlist/distributionlist_aces_collection.rb +4 -4
  54. data/lib/zm/client/distributionlist/distributionlist_aliases_collection.rb +7 -5
  55. data/lib/zm/client/distributionlist/distributionlist_jsns_builder.rb +29 -41
  56. data/lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb +14 -3
  57. data/lib/zm/client/distributionlist/distributionlist_members_collection.rb +14 -10
  58. data/lib/zm/client/distributionlist/distributionlist_owners_collection.rb +13 -13
  59. data/lib/zm/client/distributionlist/distributionlists_collection.rb +15 -7
  60. data/lib/zm/client/distributionlist/dls_membership_collection.rb +8 -6
  61. data/lib/zm/client/document/document.rb +5 -11
  62. data/lib/zm/client/document/document_jsns_builder.rb +2 -2
  63. data/lib/zm/client/document/documents_collection.rb +4 -4
  64. data/lib/zm/client/domain/domain.rb +8 -25
  65. data/lib/zm/client/domain/domain_jsns_builder.rb +13 -13
  66. data/lib/zm/client/domain/domains_collection.rb +13 -6
  67. data/lib/zm/client/filter_rules/filter_rules_collection.rb +1 -1
  68. data/lib/zm/client/filter_rules/outgoing_filter_rules_collection.rb +1 -1
  69. data/lib/zm/client/folder/folder.rb +34 -21
  70. data/lib/zm/client/folder/folder_default.rb +39 -0
  71. data/lib/zm/client/folder/folder_grant_jsns_builder.rb +3 -3
  72. data/lib/zm/client/folder/folder_grants_collection.rb +1 -1
  73. data/lib/zm/client/folder/folder_jsns_builder.rb +12 -12
  74. data/lib/zm/client/folder/folder_jsns_initializer.rb +1 -1
  75. data/lib/zm/client/folder/folder_retention_policies_collection.rb +6 -2
  76. data/lib/zm/client/folder/folder_view.rb +15 -0
  77. data/lib/zm/client/folder/folders_jsns_builder.rb +1 -1
  78. data/lib/zm/client/folder/mod_document_folder.rb +16 -12
  79. data/lib/zm/client/identity/identities_collection.rb +1 -1
  80. data/lib/zm/client/identity/identity.rb +3 -9
  81. data/lib/zm/client/identity/identity_jsns_builder.rb +8 -8
  82. data/lib/zm/client/{base/ldap_filter.rb → ldap_filter.rb} +1 -1
  83. data/lib/zm/client/license/licenses_collection.rb +1 -1
  84. data/lib/zm/client/mailbox/mailbox_item_concern.rb +0 -2
  85. data/lib/zm/client/message/message.rb +14 -19
  86. data/lib/zm/client/message/message_attachments_collection.rb +39 -0
  87. data/lib/zm/client/message/message_flags_collection.rb +130 -0
  88. data/lib/zm/client/message/message_jsns_builder.rb +4 -8
  89. data/lib/zm/client/message/message_jsns_initializer.rb +4 -4
  90. data/lib/zm/client/message/message_recipients.rb +19 -43
  91. data/lib/zm/client/message/messages_collection.rb +20 -4
  92. data/lib/zm/client/mountpoint/{mountpoint.rb → mount_point.rb} +4 -10
  93. data/lib/zm/client/mountpoint/{mountpoint_jsns_builder.rb → mount_point_jsns_builder.rb} +3 -3
  94. data/lib/zm/client/mountpoint/{mountpoint_jsns_initializer.rb → mount_point_jsns_initializer.rb} +1 -1
  95. data/lib/zm/client/mountpoint/{mountpoints_builder.rb → mount_points_builder.rb} +1 -1
  96. data/lib/zm/client/mta_queue/mta_queue.rb +4 -16
  97. data/lib/zm/client/mta_queue/mta_queue_action.rb +12 -0
  98. data/lib/zm/client/mta_queue/mta_queue_jsns_builder.rb +7 -7
  99. data/lib/zm/client/mta_queue/mta_queue_name.rb +14 -0
  100. data/lib/zm/client/mta_queue/mta_queues_collection.rb +4 -3
  101. data/lib/zm/client/mta_queue_item/mta_queue_items_collection.rb +1 -0
  102. data/lib/zm/client/recipient.rb +21 -0
  103. data/lib/zm/client/{common/recipients.rb → recipients.rb} +0 -16
  104. data/lib/zm/client/resource/resource.rb +3 -7
  105. data/lib/zm/client/resource/resource_jsns_builder.rb +13 -13
  106. data/lib/zm/client/resource/resources_collection.rb +20 -7
  107. data/lib/zm/client/search_folder/search_folder.rb +4 -11
  108. data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +6 -6
  109. data/lib/zm/client/search_folder/search_folders_collection.rb +1 -1
  110. data/lib/zm/client/server/server.rb +16 -22
  111. data/lib/zm/client/server/server_services.rb +26 -0
  112. data/lib/zm/client/server/servers_collection.rb +6 -6
  113. data/lib/zm/client/share/share.rb +2 -5
  114. data/lib/zm/client/share/shares_builder.rb +1 -1
  115. data/lib/zm/client/share/shares_collection.rb +5 -4
  116. data/lib/zm/client/signature/signature.rb +7 -13
  117. data/lib/zm/client/signature/signature_jsns_builder.rb +13 -13
  118. data/lib/zm/client/signature/signature_jsns_initializer.rb +2 -2
  119. data/lib/zm/client/signature/signatures_collection.rb +1 -1
  120. data/lib/zm/client/tag/account_object_tags_collection.rb +45 -47
  121. data/lib/zm/client/tag/tag.rb +3 -9
  122. data/lib/zm/client/tag/tag_jsns_builder.rb +3 -3
  123. data/lib/zm/client/tag/tags_builder.rb +1 -1
  124. data/lib/zm/client/tag/tags_collection.rb +2 -2
  125. data/lib/zm/client/task/task.rb +2 -2
  126. data/lib/zm/client/task/tasks_collection.rb +2 -2
  127. data/lib/zm/client/token.rb +4 -1
  128. data/lib/zm/client/upload.rb +179 -1
  129. data/lib/zm/client/{common/utils.rb → utils.rb} +6 -3
  130. data/lib/zm/client/zm_logger.rb +1 -1
  131. data/lib/zm/client.rb +227 -10
  132. data/lib/zm/connector/network_error_handler.rb +18 -0
  133. data/lib/zm/{client/connector → connector}/rest_connector.rb +46 -40
  134. data/lib/zm/{client/connector/soap_account.rb → connector/soap_account_connector.rb} +15 -17
  135. data/lib/zm/{client/connector/soap_admin.rb → connector/soap_admin_connector.rb} +3 -5
  136. data/lib/zm/connector/soap_base_connector.rb +115 -0
  137. data/lib/zm/connector.rb +13 -0
  138. data/lib/zm/error/auth_error.rb +8 -0
  139. data/lib/zm/error/connection_error.rb +8 -0
  140. data/lib/zm/error/rest_error.rb +8 -0
  141. data/lib/zm/{client/connector → error}/soap_error.rb +1 -10
  142. data/lib/zm/error/zm_error.rb +8 -0
  143. data/lib/zm/error.rb +11 -0
  144. data/lib/zm/relationship/has_many.rb +22 -0
  145. data/lib/zm/relationship/jsns_builder.rb +21 -0
  146. data/lib/zm/relationship/relationship.rb +113 -0
  147. data/lib/zm/relationship/schema.rb +32 -0
  148. data/lib/zm/relationship.rb +5 -0
  149. data/lib/zm/{client/soap_request → soap_request}/request_methods_admin.rb +11 -5
  150. data/lib/zm/{client/soap_request → soap_request}/request_methods_mailbox.rb +1 -1
  151. data/lib/zm/{client/soap_request/account_soap_constants.rb → soap_request/soap_account_constants.rb} +1 -1
  152. data/lib/zm/{client/soap_request/admin_soap_constants.rb → soap_request/soap_admin_constants.rb} +1 -1
  153. data/lib/zm/{client/soap_request → soap_request}/soap_constants.rb +1 -1
  154. data/lib/zm/{client/soap_request → soap_request}/soap_context.rb +13 -5
  155. data/lib/zm/{client/soap_request → soap_request}/soap_element.rb +1 -1
  156. data/lib/zm/{client/soap_request/mail_soap_constants.rb → soap_request/soap_mail_constants.rb} +1 -1
  157. data/lib/zm/soap_request.rb +14 -0
  158. data/lib/zm/support/cache/entry.rb +3 -3
  159. data/lib/zm/support/cache/file_store.rb +4 -6
  160. data/lib/zm/support/cache/null_store.rb +2 -4
  161. data/lib/zm/support/cache/store.rb +17 -9
  162. data/lib/zm/support/cache.rb +13 -8
  163. data/lib/zm/support.rb +7 -0
  164. data/lib/zm/{modules → utils}/belongs_to_folder.rb +1 -1
  165. data/lib/zm/{modules → utils}/belongs_to_tag.rb +2 -2
  166. data/lib/zm/utils/content_part.rb +9 -0
  167. data/lib/zm/utils/content_type.rb +11 -0
  168. data/lib/zm/{modules → utils}/has_soap_admin_connector.rb +1 -1
  169. data/lib/zm/utils/inspector.rb +26 -0
  170. data/lib/zm/utils/log_filter.rb +30 -0
  171. data/lib/zm/utils/missing_method_static_collection.rb +17 -0
  172. data/lib/zm/utils/regex.rb +11 -0
  173. data/lib/zm/utils/search_utils.rb +13 -0
  174. data/lib/zm/utils.rb +16 -0
  175. data/lib/zm-ruby-client.rb +12 -0
  176. data/sig/zm/client/admin_objects.rbs +261 -0
  177. data/sig/zm/client/base.rbs +191 -0
  178. data/sig/zm/client/cluster.rbs +152 -0
  179. data/sig/zm/client/mailbox.rbs +766 -0
  180. data/sig/zm/error.rbs +23 -0
  181. metadata +99 -91
  182. data/.gitignore +0 -59
  183. data/.rubocop.yml +0 -6
  184. data/.ruby-version +0 -1
  185. data/Gemfile +0 -11
  186. data/SECURITY.md +0 -21
  187. data/bin/console +0 -11
  188. data/lib/zm/client/account.rb +0 -9
  189. data/lib/zm/client/ace.rb +0 -7
  190. data/lib/zm/client/appointment.rb +0 -7
  191. data/lib/zm/client/backup.rb +0 -6
  192. data/lib/zm/client/base.rb +0 -21
  193. data/lib/zm/client/cluster.rb +0 -4
  194. data/lib/zm/client/common/message.rb +0 -10
  195. data/lib/zm/client/common.rb +0 -5
  196. data/lib/zm/client/connector/soap_base.rb +0 -104
  197. data/lib/zm/client/constant.rb +0 -229
  198. data/lib/zm/client/contact.rb +0 -11
  199. data/lib/zm/client/cos.rb +0 -10
  200. data/lib/zm/client/datasource.rb +0 -7
  201. data/lib/zm/client/distributionlist.rb +0 -8
  202. data/lib/zm/client/document.rb +0 -7
  203. data/lib/zm/client/domain.rb +0 -10
  204. data/lib/zm/client/filter_rule.rb +0 -7
  205. data/lib/zm/client/folder.rb +0 -14
  206. data/lib/zm/client/identity.rb +0 -7
  207. data/lib/zm/client/license.rb +0 -5
  208. data/lib/zm/client/message/attachments_collection.rb +0 -55
  209. data/lib/zm/client/message/message_flags.rb +0 -115
  210. data/lib/zm/client/message.rb +0 -10
  211. data/lib/zm/client/mountpoint.rb +0 -7
  212. data/lib/zm/client/mta_queue.rb +0 -7
  213. data/lib/zm/client/mta_queue_item.rb +0 -6
  214. data/lib/zm/client/resource.rb +0 -7
  215. data/lib/zm/client/search_folder.rb +0 -7
  216. data/lib/zm/client/server.rb +0 -7
  217. data/lib/zm/client/share.rb +0 -7
  218. data/lib/zm/client/signature.rb +0 -7
  219. data/lib/zm/client/soap_request.rb +0 -11
  220. data/lib/zm/client/tag.rb +0 -8
  221. data/lib/zm/client/task.rb +0 -6
  222. data/lib/zm/client/upload/upload.rb +0 -160
  223. data/lib/zm/modules/base.rb +0 -9
  224. data/lib/zm/modules/common/zimbra-attrs.json +0 -58
  225. data/lib/zm/modules/inspector.rb +0 -24
  226. data/lib/zm/modules/missing_method_static_collection.rb +0 -13
  227. data/lib/zm/modules/zm_model.rb +0 -43
  228. data/zm-ruby-client.gemspec +0 -27
  229. /data/lib/zm/client/mountpoint/{mountpoints_collection.rb → mount_points_collection.rb} +0 -0
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ class MessageAttachmentsCollection
6
+ include Zm::Utils::MissingMethodStaticCollection
7
+
8
+ attr_reader :all
9
+
10
+ def initialize
11
+ @all = []
12
+ end
13
+
14
+ def add(attachment)
15
+ return unless attachment.is_a?(Attachment)
16
+
17
+ @all.push(attachment)
18
+ end
19
+ end
20
+
21
+ # class attachment for email
22
+ class Attachment
23
+ attr_accessor :aid, :part, :mid, :ct, :s, :filename, :ci, :cd
24
+
25
+ def initialize(parent)
26
+ @parent = parent
27
+ yield(self) if block_given?
28
+ end
29
+
30
+ def download(dest_file_path)
31
+ account.build_uploader.download_attachment(dest_file_path, @parent.id, part)
32
+ end
33
+
34
+ def account
35
+ @parent.parent
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ # class message for account
6
+ class MessageFlagsCollection
7
+ def initialize(parent)
8
+ @parent = parent
9
+ end
10
+
11
+ def all
12
+ @all ||= @parent.f.to_s.chars
13
+ end
14
+
15
+ # properties
16
+
17
+ def unread?
18
+ all.include?('u')
19
+ end
20
+
21
+ def flagged?
22
+ all.include?('f')
23
+ end
24
+
25
+ def attachment?
26
+ all.include?('a')
27
+ end
28
+
29
+ def replied
30
+ all.include?('r')
31
+ end
32
+
33
+ def sent_by_me?
34
+ all.include?('s')
35
+ end
36
+
37
+ def forwarded?
38
+ all.include?('w')
39
+ end
40
+
41
+ def calendar_invite?
42
+ all.include?('v')
43
+ end
44
+
45
+ def draft?
46
+ all.include?('d')
47
+ end
48
+
49
+ def imap_deleted?
50
+ all.include?('x')
51
+ end
52
+
53
+ def notification?
54
+ all.include?('n')
55
+ end
56
+
57
+ def urgent?
58
+ all.include?('!')
59
+ end
60
+
61
+ def low_priority?
62
+ all.include?('?')
63
+ end
64
+
65
+ def priority?
66
+ all.include?('+')
67
+ end
68
+
69
+ # actions
70
+
71
+ def unread!
72
+ apply(build_unread, 'u', true)
73
+ end
74
+
75
+ def build_unread
76
+ build({ op: '!read', id: @parent.id })
77
+ end
78
+
79
+ def read!
80
+ apply(build_read, 'u', false)
81
+ end
82
+
83
+ def build_read
84
+ build({ op: 'read', id: @parent.id })
85
+ end
86
+
87
+ def unflag!
88
+ apply(build_unflag, 'f', false)
89
+ end
90
+
91
+ def build_unflag
92
+ build({ op: '!flag', id: @parent.id })
93
+ end
94
+
95
+ def flag!
96
+ apply(build_flag, 'f', true)
97
+ end
98
+
99
+ def build_flag
100
+ build({ op: 'flag', id: @parent.id })
101
+ end
102
+
103
+ private
104
+
105
+ def soap_connector
106
+ @parent.parent.soap_connector
107
+ end
108
+
109
+ def apply(soap_request, flag, enabled)
110
+ response = soap_connector.invoke(soap_request)
111
+
112
+ if enabled
113
+ all << flag unless all.include?(flag)
114
+ else
115
+ all.delete(flag)
116
+ end
117
+ @parent.f = all.join
118
+
119
+ response
120
+ end
121
+
122
+ def build(attrs)
123
+ soap_request = SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::ITEM_ACTION_REQUEST)
124
+ node_action = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::ACTION).add_attributes(attrs)
125
+ soap_request.add_node(node_action)
126
+ soap_request
127
+ end
128
+ end
129
+ end
130
+ end
@@ -3,11 +3,7 @@
3
3
  module Zm
4
4
  module Client
5
5
  # class for account message jsns builder
6
- class MessageJsnsBuilder < BaseAccountJsnsBuilder
7
- def initialize(item)
8
- @item = item
9
- end
10
-
6
+ class MessageJsnsBuilder < Base::BaseAccountJsnsBuilder
11
7
  def to_jsns
12
8
  jsns = {
13
9
  id: @item.id,
@@ -57,12 +53,12 @@ module Zm
57
53
  def body_jsns
58
54
  return nil if @item.body.text.nil? && @item.body.html.nil?
59
55
 
60
- text_jsns = @item.body.text.nil? ? nil : { ct: ContentType::TEXT, content: { _content: @item.body.text } }
61
- html_jsns = @item.body.html.nil? ? nil : { ct: ContentType::HTML, content: { _content: @item.body.html } }
56
+ text_jsns = @item.body.text.nil? ? nil : { ct: Zm::Utils::ContentType::TEXT, content: { _content: @item.body.text } }
57
+ html_jsns = @item.body.html.nil? ? nil : { ct: Zm::Utils::ContentType::HTML, content: { _content: @item.body.html } }
62
58
 
63
59
  [
64
60
  {
65
- ct: ContentPart::ALTERNATIVE,
61
+ ct: Zm::Utils::ContentPart::ALTERNATIVE,
66
62
  mp: [text_jsns, html_jsns].compact
67
63
  }
68
64
  ]
@@ -40,7 +40,7 @@ module Zm
40
40
  mps = [mps] unless mps.is_a?(Array)
41
41
 
42
42
  mps.each do |mp|
43
- if ContentType::ALL.include?(mp[:ct])
43
+ if Zm::Utils::ContentType::ALL.include?(mp[:ct])
44
44
  update_body(item, mp)
45
45
  elsif mp[:cd] == 'attachment'
46
46
  update_attachment(item, mp)
@@ -51,12 +51,12 @@ module Zm
51
51
  end
52
52
 
53
53
  def update_body(item, json)
54
- item.body.text = json[:content] if json[:ct] == ContentType::TEXT
55
- item.body.html = json[:content] if json[:ct] == ContentType::HTML
54
+ item.body.text = json[:content] if json[:ct] == Zm::Utils::ContentType::TEXT
55
+ item.body.html = json[:content] if json[:ct] == Zm::Utils::ContentType::HTML
56
56
  end
57
57
 
58
58
  def update_attachment(item, json)
59
- pj = Zm::Client::Message::Attachment.new(self)
59
+ pj = Attachment.new(item)
60
60
  pj.mid = json.delete(:mid)
61
61
  pj.aid = json.delete(:aid)
62
62
  pj.ct = json.delete(:ct)
@@ -2,57 +2,33 @@
2
2
 
3
3
  module Zm
4
4
  module Client
5
- class Message
6
- # Collection recipients
7
- class Recipients
8
- attr_reader :all
5
+ class MessageRecipients
6
+ attr_reader :all
9
7
 
10
- def initialize
11
- @all = []
12
- end
13
-
14
- def add(recipient)
15
- return unless recipient.is_a?(Zm::Client::Recipient)
8
+ def initialize
9
+ @all = []
10
+ end
16
11
 
17
- @all.push(recipient)
18
- end
12
+ def add(recipient)
13
+ return unless recipient.is_a?(Zm::Client::Recipient)
19
14
 
20
- def to
21
- @all.select { |r| r.field == Zm::Client::Recipient::TO }
22
- end
15
+ @all.push(recipient)
16
+ end
23
17
 
24
- def cc
25
- @all.select { |r| r.field == Zm::Client::Recipient::CC }
26
- end
18
+ def to
19
+ @all.select { |r| r.field == Zm::Client::Recipient::TO }
20
+ end
27
21
 
28
- def bcc
29
- @all.select { |r| r.field == Zm::Client::Recipient::BCC }
30
- end
22
+ def cc
23
+ @all.select { |r| r.field == Zm::Client::Recipient::CC }
24
+ end
31
25
 
32
- def from
33
- @all.select { |r| r.field == Zm::Client::Recipient::FROM }
34
- end
26
+ def bcc
27
+ @all.select { |r| r.field == Zm::Client::Recipient::BCC }
35
28
  end
36
29
 
37
- # Class one recipient for email
38
- class Recipient
39
- FROM = :f
40
- TO = :t
41
- CC = :c
42
- BCC = :b
43
-
44
- attr_accessor :field, :email
45
- attr_writer :display_name
46
-
47
- def initialize(field, email, display_name = nil)
48
- @email = email
49
- @field = field.to_sym
50
- @display_name = display_name
51
- end
52
-
53
- def display_name
54
- @display_name || "#{@email} (#{@display_name})"
55
- end
30
+ def from
31
+ @all.select { |r| r.field == Zm::Client::Recipient::FROM }
56
32
  end
57
33
  end
58
34
  end
@@ -8,23 +8,39 @@ module Zm
8
8
  super
9
9
  @child_class = Message
10
10
  @builder_class = MessagesBuilder
11
- @type = SoapConstants::MESSAGE
12
- @sort_by = SoapConstants::DATE_DESC
11
+ @type = SoapRequest::SoapConstants::MESSAGE
12
+ @sort_by = SoapRequest::SoapConstants::DATE_DESC
13
13
  end
14
14
 
15
- def find_each(offset: 0, limit: 500, &block)
15
+ def find_each(offset: 0, limit: 500, secure: true, &)
16
16
  @more = true
17
17
  @offset = offset
18
18
  @limit = limit
19
19
 
20
20
  while @more
21
- build_response.each { |item| block.call(item) }
21
+ items = secure ? secure_build_response : build_response
22
+ break if items.nil?
23
+
24
+ secure ? secure_each(items, &) : items.each(&)
22
25
  @offset += @limit
23
26
  end
24
27
  end
25
28
 
26
29
  private
27
30
 
31
+ def secure_build_response
32
+ build_response
33
+ rescue StandardError => e
34
+ logger.error "Messages search stopped at offset #{@offset}: #{e.message}"
35
+ nil
36
+ end
37
+
38
+ def secure_each(items, &)
39
+ items.each(&)
40
+ rescue StandardError => e
41
+ logger.error e.message
42
+ end
43
+
28
44
  def build_options
29
45
  options = super
30
46
  options[:recip] = @recip
@@ -4,9 +4,11 @@ module Zm
4
4
  module Client
5
5
  # class for account mountpoint
6
6
  class MountPoint < Base::Object
7
- include BelongsToFolder
8
- include RequestMethodsMailbox
7
+ include Zm::Utils::BelongsToFolder
8
+ include SoapRequest::RequestMethodsMailbox
9
9
  include MailboxItemConcern
10
+ extend Relationship
11
+ has_jsns_builder
10
12
 
11
13
  attr_accessor :owner, :rev, :reminder, :ms, :deletable, :rid, :uuid, :url, :f, :broken, :luuid, :ruuid,
12
14
  :activesyncdisabled, :absFolderPath, :view, :zid, :webOfflineSyncDays, :name, :color, :rgb
@@ -48,14 +50,6 @@ module Zm
48
50
  def reload!
49
51
  raise NotImplementedError
50
52
  end
51
-
52
- private
53
-
54
- def jsns_builder
55
- return @jsns_builder if defined? @jsns_builder
56
-
57
- @jsns_builder = MountpointJsnsBuilder.new(self)
58
- end
59
53
  end
60
54
  end
61
55
  end
@@ -3,7 +3,7 @@
3
3
  module Zm
4
4
  module Client
5
5
  # class for account folder
6
- class MountpointJsnsBuilder < BaseAccountJsnsBuilder
6
+ class MountPointJsnsBuilder < Base::BaseAccountJsnsBuilder
7
7
  def to_find
8
8
  { link: { l: @item.id } }
9
9
  end
@@ -22,9 +22,9 @@ module Zm
22
22
  }
23
23
  link.compact!
24
24
 
25
- attrs = { link: link }
25
+ attrs = { link: }
26
26
 
27
- SoapElement.mail(SoapMailConstants::CREATE_MOUNTPOINT_REQUEST)
27
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::CREATE_MOUNTPOINT_REQUEST)
28
28
  .add_attributes(attrs)
29
29
  end
30
30
 
@@ -3,7 +3,7 @@
3
3
  module Zm
4
4
  module Client
5
5
  # class for initialize account mountpoint
6
- class MountpointJsnsInitializer
6
+ class MountPointJsnsInitializer
7
7
  class << self
8
8
  def create(parent, json)
9
9
  MountPoint.new(parent).tap do |item|
@@ -23,7 +23,7 @@ module Zm
23
23
  json_folders.each do |json_folder|
24
24
  if json_folder[@key_link].is_a?(Array)
25
25
  @list += json_folder[@key_link].map do |json_link|
26
- MountpointJsnsInitializer.create(@parent, json_link)
26
+ MountPointJsnsInitializer.create(@parent, json_link)
27
27
  end
28
28
  end
29
29
 
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'zm/client/mta_queue_item'
4
-
5
3
  module Zm
6
4
  module Client
7
5
  class MtaQueue < Base::Object
8
- include HasSoapAdminConnector
6
+ extend Relationship
7
+ has_jsns_builder
8
+ include Zm::Utils::HasSoapAdminConnector
9
9
 
10
10
  attr_accessor :name, :n
11
11
 
@@ -15,11 +15,7 @@ module Zm
15
15
  @parent
16
16
  end
17
17
 
18
- def items
19
- return @items if defined? @items
20
-
21
- @items = MtaQueueItemsCollection.new self
22
- end
18
+ has_many :items, klass: :'Zm::Client::MtaQueueItemsCollection'
23
19
 
24
20
  def hold!(ids)
25
21
  sac.invoke(jsns_builder.to_jsns(Zm::Client::MtaQueueAction::HOLD, ids))
@@ -36,14 +32,6 @@ module Zm
36
32
  def requeue!(ids)
37
33
  sac.invoke(jsns_builder.to_jsns(Zm::Client::MtaQueueAction::REQUEUE, ids))
38
34
  end
39
-
40
- private
41
-
42
- def jsns_builder
43
- return @jsns_builder if defined? @jsns_builder
44
-
45
- @jsns_builder = MtaQueueJsnsBuilder.new(self)
46
- end
47
35
  end
48
36
  end
49
37
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module MtaQueueAction
6
+ HOLD = 'hold'
7
+ RELEASE = 'release'
8
+ DELETE = 'delete'
9
+ REQUEUE = 'requeue'
10
+ end
11
+ end
12
+ end
@@ -9,12 +9,12 @@ module Zm
9
9
  end
10
10
 
11
11
  def to_jsns(op, ids)
12
- soap_request = SoapElement.admin(SoapAdminConstants::MAIL_QUEUE_ACTION_REQUEST)
13
- node_server = SoapElement.create('server').add_attribute(SoapConstants::NAME, @item.server.name)
12
+ soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::MAIL_QUEUE_ACTION_REQUEST)
13
+ node_server = SoapRequest::SoapElement.create('server').add_attribute(SoapRequest::SoapConstants::NAME, @item.server.name)
14
14
  soap_request.add_node(node_server)
15
- node_queue = SoapElement.create('queue')
15
+ node_queue = SoapRequest::SoapElement.create('queue')
16
16
  node_server.add_node(node_queue)
17
- node_action = SoapElement.create('action').add_attributes({ op: op, by: :id }).add_content(ids.join(','))
17
+ node_action = SoapRequest::SoapElement.create('action').add_attributes({ op:, by: :id }).add_content(ids.join(','))
18
18
  node_queue.add_node(node_action)
19
19
 
20
20
  soap_request
@@ -28,10 +28,10 @@ module Zm
28
28
  query[:field] = @item.fields.map { |k, v| { name: k, match: { value: v } } } unless @item.fields.empty?
29
29
  query.reject! { |_, v| v.nil? || v.empty? }
30
30
 
31
- soap_request = SoapElement.admin(SoapAdminConstants::GET_MAIL_QUEUE_REQUEST)
32
- node_server = SoapElement.create('server').add_attribute(SoapConstants::NAME, @item.server.name)
31
+ soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::GET_MAIL_QUEUE_REQUEST)
32
+ node_server = SoapRequest::SoapElement.create('server').add_attribute(SoapRequest::SoapConstants::NAME, @item.server.name)
33
33
  soap_request.add_node(node_server)
34
- node_queue = SoapElement.create('queue').add_attributes({ name: @item.mta_queue.name, scan: 1, query: query })
34
+ node_queue = SoapRequest::SoapElement.create('queue').add_attributes({ name: @item.mta_queue.name, scan: 1, query: })
35
35
  node_server.add_node(node_queue)
36
36
 
37
37
  soap_request
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module MtaQueueName
6
+ INCOMING = 'incoming'
7
+ DEFERRED = 'deferred'
8
+ CORRUPT = 'corrupt'
9
+ ACTIVE = 'active'
10
+ HOLD = 'hold'
11
+ ALL = [INCOMING, DEFERRED, CORRUPT, ACTIVE, HOLD].freeze
12
+ end
13
+ end
14
+ end
@@ -5,6 +5,7 @@ module Zm
5
5
  # Collection MtaQueues
6
6
  class MtaQueuesCollection < Base::ObjectsCollection
7
7
  def initialize(parent)
8
+ super()
8
9
  @parent = parent
9
10
  reset_query_params
10
11
  end
@@ -25,7 +26,7 @@ module Zm
25
26
  end
26
27
 
27
28
  def find(queue_name)
28
- raise ZmError, 'Unknown queue name' unless Zm::Client::MtaQueueName::ALL.include?(queue_name)
29
+ raise Zm::Error::ZmError, 'Unknown queue name' unless Zm::Client::MtaQueueName::ALL.include?(queue_name)
29
30
 
30
31
  all! if @queues_h.empty?
31
32
  @queues_h[queue_name]
@@ -34,8 +35,8 @@ module Zm
34
35
  private
35
36
 
36
37
  def make_query
37
- soap_request = SoapElement.admin(SoapAdminConstants::GET_MAIL_QUEUE_INFO_REQUEST)
38
- node_server = SoapElement.create('server').add_attribute(SoapConstants::NAME, @parent.name)
38
+ soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::GET_MAIL_QUEUE_INFO_REQUEST)
39
+ node_server = SoapRequest::SoapElement.create('server').add_attribute(SoapRequest::SoapConstants::NAME, @parent.name)
39
40
  soap_request.add_node(node_server)
40
41
  sac.invoke(soap_request)
41
42
  end
@@ -7,6 +7,7 @@ module Zm
7
7
  attr_reader :offset, :limit, :fields
8
8
 
9
9
  def initialize(parent)
10
+ super()
10
11
  @parent = parent
11
12
  reset_query_params
12
13
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ # Class one recipient for email
6
+ class Recipient
7
+ FROM = :f
8
+ TO = :t
9
+ CC = :c
10
+ BCC = :b
11
+
12
+ attr_accessor :field, :email, :display_name
13
+
14
+ def initialize(field, email, display_name = nil)
15
+ @email = email
16
+ @field = field.to_sym
17
+ @display_name = display_name
18
+ end
19
+ end
20
+ end
21
+ end
@@ -47,21 +47,5 @@ module Zm
47
47
  @recipients.select { |r| r.field == Recipient::FROM }
48
48
  end
49
49
  end
50
-
51
- # Class one recipient for email
52
- class Recipient
53
- FROM = :f
54
- TO = :t
55
- CC = :c
56
- BCC = :b
57
-
58
- attr_accessor :field, :email, :display_name
59
-
60
- def initialize(field, email, display_name = nil)
61
- @email = email
62
- @field = field.to_sym
63
- @display_name = display_name
64
- end
65
- end
66
50
  end
67
51
  end
@@ -4,7 +4,9 @@ module Zm
4
4
  module Client
5
5
  # objectClass: zimbraCalendarResource
6
6
  class Resource < Base::MailboxObject
7
- include RequestMethodsAdmin
7
+ include SoapRequest::RequestMethodsAdmin
8
+
9
+ has_jsns_builder
8
10
 
9
11
  LOCATION = 'Location'
10
12
  EQUIPMENT = 'Equipment'
@@ -26,12 +28,6 @@ module Zm
26
28
  def equipment?
27
29
  zimbraCalResType == EQUIPMENT
28
30
  end
29
-
30
- def jsns_builder
31
- return @jsns_builder if defined? @jsns_builder
32
-
33
- @jsns_builder = ResourceJsnsBuilder.new(self)
34
- end
35
31
  end
36
32
  end
37
33
  end