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
@@ -9,13 +9,13 @@ module Zm
9
9
  end
10
10
 
11
11
  def to_create
12
- soap_request = SoapElement.admin(SoapAdminConstants::CREATE_DOMAIN_REQUEST)
13
- .add_attribute(SoapConstants::NAME, @item.name)
12
+ soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::CREATE_DOMAIN_REQUEST)
13
+ .add_attribute(SoapRequest::SoapConstants::NAME, @item.name)
14
14
 
15
15
  attrs_only_set_h.each do |key, values|
16
16
  values.each do |value|
17
- node_attr = SoapElement.create(SoapConstants::A)
18
- .add_attribute(SoapConstants::N, key)
17
+ node_attr = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::A)
18
+ .add_attribute(SoapRequest::SoapConstants::N, key)
19
19
  .add_content(value)
20
20
  soap_request.add_node(node_attr)
21
21
  end
@@ -25,12 +25,12 @@ module Zm
25
25
  end
26
26
 
27
27
  def to_update
28
- soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
29
- .add_attribute(SoapConstants::ID, @item.id)
28
+ soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
29
+ .add_attribute(SoapRequest::SoapConstants::ID, @item.id)
30
30
 
31
31
  attrs_only_set_h.each do |key, values|
32
32
  values.each do |value|
33
- node_attr = SoapElement.create(SoapConstants::A).add_attribute(SoapConstants::N, key).add_content(value)
33
+ node_attr = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::A).add_attribute(SoapRequest::SoapConstants::N, key).add_content(value)
34
34
  soap_request.add_node(node_attr)
35
35
  end
36
36
  end
@@ -39,14 +39,14 @@ module Zm
39
39
  end
40
40
 
41
41
  def to_patch(hash)
42
- soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
43
- .add_attribute(SoapConstants::ID, @item.id)
42
+ soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
43
+ .add_attribute(SoapRequest::SoapConstants::ID, @item.id)
44
44
 
45
45
  hash.each do |key, values|
46
46
  values = [values] unless values.is_a?(Array)
47
47
  values.each do |value|
48
- node_attr = SoapElement.create(SoapConstants::A)
49
- .add_attribute(SoapConstants::N, key)
48
+ node_attr = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::A)
49
+ .add_attribute(SoapRequest::SoapConstants::N, key)
50
50
  .add_content(value)
51
51
  soap_request.add_node(node_attr)
52
52
  end
@@ -56,8 +56,8 @@ module Zm
56
56
  end
57
57
 
58
58
  def to_delete
59
- SoapElement.admin(SoapAdminConstants::DELETE_DOMAIN_REQUEST)
60
- .add_attribute(SoapConstants::ID, @item.id)
59
+ SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::DELETE_DOMAIN_REQUEST)
60
+ .add_attribute(SoapRequest::SoapConstants::ID, @item.id)
61
61
  end
62
62
 
63
63
  def attrs_only_set_h
@@ -7,7 +7,7 @@ module Zm
7
7
  def initialize(parent)
8
8
  @child_class = Domain
9
9
  @builder_class = DomainsBuilder
10
- @search_type = SearchType::DOMAIN
10
+ @search_type = :domains
11
11
  super
12
12
  end
13
13
 
@@ -19,12 +19,12 @@ module Zm
19
19
  end
20
20
 
21
21
  def build_find_by(hash)
22
- soap_request = SoapElement.admin(SoapAdminConstants::GET_DOMAIN_REQUEST)
23
- node_domain = SoapElement.create(SoapConstants::DOMAIN)
24
- .add_attribute(SoapConstants::BY, hash.keys.first)
22
+ soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::GET_DOMAIN_REQUEST)
23
+ node_domain = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::DOMAIN)
24
+ .add_attribute(SoapRequest::SoapConstants::BY, hash.keys.first)
25
25
  .add_content(hash.values.first)
26
26
  soap_request.add_node(node_domain)
27
- soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma)
27
+ soap_request.add_attribute(SoapRequest::SoapConstants::ATTRS, attrs_comma)
28
28
  soap_request
29
29
  end
30
30
 
@@ -32,7 +32,14 @@ module Zm
32
32
 
33
33
  def reset_query_params
34
34
  super
35
- @attrs = SearchType::Attributes::DOMAIN.dup
35
+ @attrs = %w[
36
+ description
37
+ zimbraDomainName
38
+ zimbraDomainStatus
39
+ zimbraId
40
+ zimbraDomainType
41
+ zimbraDomainDefaultCOSId
42
+ ]
36
43
  end
37
44
  end
38
45
  end
@@ -15,7 +15,7 @@ module Zm
15
15
  end
16
16
 
17
17
  def build_query
18
- SoapElement.mail(SoapMailConstants::GET_FILTER_RULES_REQUEST)
18
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::GET_FILTER_RULES_REQUEST)
19
19
  end
20
20
  end
21
21
  end
@@ -11,7 +11,7 @@ module Zm
11
11
  end
12
12
 
13
13
  def build_query
14
- SoapElement.mail(SoapMailConstants::GET_OUTGOING_FILTER_RULES_REQUEST)
14
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::GET_OUTGOING_FILTER_RULES_REQUEST)
15
15
  end
16
16
  end
17
17
  end
@@ -4,9 +4,11 @@ module Zm
4
4
  module Client
5
5
  # class for account folder
6
6
  class Folder < 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 :type, :uuid, :name, :absFolderPath, :url, :luuid, :f, :view, :rev, :ms,
12
14
  :webOfflineSyncDays, :activesyncdisabled, :n, :s, :i4ms, :i4next, :zid, :rid, :ruuid,
@@ -112,16 +114,16 @@ module Zm
112
114
  def build_add_message(eml, d = nil, f = nil, tn = nil)
113
115
  m = {
114
116
  l: id,
115
- d: d,
116
- f: f,
117
- tn: tn,
117
+ d:,
118
+ f:,
119
+ tn:,
118
120
  content: { _content: eml }
119
121
  }
120
122
  m.compact!
121
123
 
122
- attrs = { m: m }
124
+ attrs = { m: }
123
125
 
124
- SoapElement.mail(SoapMailConstants::ADD_MSG_REQUEST)
126
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::ADD_MSG_REQUEST)
125
127
  .add_attributes(attrs)
126
128
  end
127
129
 
@@ -130,9 +132,9 @@ module Zm
130
132
  end
131
133
 
132
134
  def build_add_appointments(ics)
133
- attrs = { l: id, ct: SoapConstants::TEXT_CALENDAR }
134
- soap_request = SoapElement.mail(SoapMailConstants::IMPORT_APPOINTMENTS_REQUEST).add_attributes(attrs)
135
- node_content = SoapElement.create(SoapConstants::CONTENT).add_content(ics)
135
+ attrs = { l: id, ct: SoapRequest::SoapConstants::TEXT_CALENDAR }
136
+ soap_request = SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::IMPORT_APPOINTMENTS_REQUEST).add_attributes(attrs)
137
+ node_content = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::CONTENT).add_content(ics)
136
138
  soap_request.add_node(node_content)
137
139
  soap_request
138
140
  end
@@ -142,13 +144,32 @@ module Zm
142
144
  end
143
145
 
144
146
  def build_add_contacts(csv)
145
- attrs = { l: id, ct: SoapConstants::CSV }
146
- soap_request = SoapElement.mail(SoapMailConstants::IMPORT_CONTACTS_REQUEST).add_attributes(attrs)
147
- node_content = SoapElement.create(SoapConstants::CONTENT).add_content(csv)
147
+ attrs = { l: id, ct: SoapRequest::SoapConstants::CSV }
148
+ soap_request = SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::IMPORT_CONTACTS_REQUEST).add_attributes(attrs)
149
+ node_content = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::CONTENT).add_content(csv)
148
150
  soap_request.add_node(node_content)
149
151
  soap_request
150
152
  end
151
153
 
154
+ def export_contacts(csvfmt: nil, csvlocale: nil, csvsep: nil)
155
+ @parent.soap_connector
156
+ .invoke(build_export_contacts(csvfmt:, csvlocale:, csvsep:))
157
+ .dig(:ExportContactsResponse, :content)
158
+ end
159
+
160
+ def build_export_contacts(csvfmt: nil, csvlocale: nil, csvsep: nil)
161
+ attrs = {
162
+ l: id,
163
+ ct: SoapRequest::SoapConstants::CSV,
164
+ csvfmt:,
165
+ csvlocale:,
166
+ csvsep:
167
+ }
168
+ attrs.compact!
169
+
170
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::EXPORT_CONTACTS_REQUEST).add_attributes(attrs)
171
+ end
172
+
152
173
  def download(dest_file_path, fmt: nil)
153
174
  uploader = @parent.build_uploader
154
175
  uploader.download_folder(dest_file_path, id, fmt:)
@@ -158,14 +179,6 @@ module Zm
158
179
  uploader = @parent.build_uploader
159
180
  uploader.send_file(src_file_path, id, fmt:, type: view, resolve:)
160
181
  end
161
-
162
- private
163
-
164
- def jsns_builder
165
- return @jsns_builder if defined? @jsns_builder
166
-
167
- @jsns_builder = FolderJsnsBuilder.new(self)
168
- end
169
182
  end
170
183
  end
171
184
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module FolderDefault
6
+ FolderData = Data.define(:id, :name, :path, :type)
7
+
8
+ ROOT = FolderData.new(1, '', '/', 'unknown')
9
+ INBOX = FolderData.new(2, 'Inbox', '/Inbox', 'message')
10
+ TRASH = FolderData.new(3, 'Trash', '/Trash', 'unknown')
11
+ JUNK = FolderData.new(4, 'Junk', '/Junk', 'message')
12
+ SENT = FolderData.new(5, 'Sent', '/Sent', 'message')
13
+ DRAFTS = FolderData.new(6, 'Drafts', '/Drafts', 'message')
14
+ CONTACTS = FolderData.new(7, 'Contacts', '/Contacts', 'contact')
15
+ CALENDAR = FolderData.new(10, 'Calendar', '/Calendar', 'appointment')
16
+ EMAILED = FolderData.new(13, 'Emailed Contacts', '/Emailed Contacts', 'contact')
17
+ CHATS = FolderData.new(14, 'Chats', '/Chats', 'message')
18
+ TASKS = FolderData.new(15, 'Tasks', '/Tasks', 'task')
19
+ BRIEFCASE = FolderData.new(16, 'Briefcase', '/Briefcase', 'document')
20
+
21
+ ALL = [
22
+ ROOT,
23
+ BRIEFCASE,
24
+ CALENDAR,
25
+ CHATS,
26
+ CONTACTS,
27
+ DRAFTS,
28
+ EMAILED,
29
+ INBOX,
30
+ JUNK,
31
+ SENT,
32
+ TASKS,
33
+ TRASH
34
+ ].freeze
35
+
36
+ IDS = ALL.map(&:id).freeze
37
+ end
38
+ end
39
+ end
@@ -19,11 +19,11 @@ module Zm
19
19
  action: {
20
20
  op: :grant,
21
21
  id: @item.folder_id,
22
- grant: grant
22
+ grant:
23
23
  }
24
24
  }
25
25
 
26
- SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST)
26
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::FOLDER_ACTION_REQUEST)
27
27
  .add_attributes(attrs)
28
28
  end
29
29
 
@@ -41,7 +41,7 @@ module Zm
41
41
  }
42
42
  }
43
43
 
44
- SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST)
44
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::FOLDER_ACTION_REQUEST)
45
45
  .add_attributes(attrs)
46
46
  end
47
47
 
@@ -4,7 +4,7 @@ module Zm
4
4
  module Client
5
5
  # class for folder retention policies collection
6
6
  class FolderGrantsCollection
7
- include MissingMethodStaticCollection
7
+ include Zm::Utils::MissingMethodStaticCollection
8
8
 
9
9
  attr_reader :parent
10
10
 
@@ -3,10 +3,10 @@
3
3
  module Zm
4
4
  module Client
5
5
  # class for account folder jsns builder
6
- class FolderJsnsBuilder < BaseAccountJsnsBuilder
6
+ class FolderJsnsBuilder < Base::BaseAccountJsnsBuilder
7
7
  def to_find
8
8
  attrs = { folder: { l: @item.id } }
9
- SoapElement.mail(SoapMailConstants::GET_FOLDER_REQUEST).add_attributes(attrs)
9
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::GET_FOLDER_REQUEST).add_attributes(attrs)
10
10
  end
11
11
 
12
12
  def to_jsns
@@ -22,9 +22,9 @@ module Zm
22
22
  }
23
23
  folder.compact!
24
24
 
25
- attrs = { folder: folder }
25
+ attrs = { folder: }
26
26
 
27
- SoapElement.mail(SoapMailConstants::CREATE_FOLDER_REQUEST)
27
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::CREATE_FOLDER_REQUEST)
28
28
  .add_attributes(attrs)
29
29
  end
30
30
 
@@ -50,9 +50,9 @@ module Zm
50
50
  action.delete(:l)
51
51
  end
52
52
 
53
- attrs = { action: action }
53
+ attrs = { action: }
54
54
 
55
- SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST)
55
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::FOLDER_ACTION_REQUEST)
56
56
  .add_attributes(attrs)
57
57
  end
58
58
 
@@ -62,14 +62,14 @@ module Zm
62
62
  id: @item.id
63
63
  }.merge(options)
64
64
 
65
- attrs = { action: action }
65
+ attrs = { action: }
66
66
 
67
- SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST)
67
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::FOLDER_ACTION_REQUEST)
68
68
  .add_attributes(attrs)
69
69
  end
70
70
 
71
71
  def to_retentionpolicy
72
- retentionpolicy = @item.retention_policies.all.map { |rp| retentionpolicy_jsns(rp) }.reduce({}, :merge)
72
+ retentionpolicy = @item.retention_policies.all.each_with_object({}) { |rp, h| h.merge!(retentionpolicy_jsns(rp)) }
73
73
 
74
74
  attrs = {
75
75
  action: {
@@ -79,7 +79,7 @@ module Zm
79
79
  }
80
80
  }
81
81
 
82
- SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST)
82
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::FOLDER_ACTION_REQUEST)
83
83
  .add_attributes(attrs)
84
84
  end
85
85
 
@@ -90,9 +90,9 @@ module Zm
90
90
  recursive: false
91
91
  }
92
92
 
93
- attrs = { action: action }
93
+ attrs = { action: }
94
94
 
95
- SoapElement.mail(SoapMailConstants::FOLDER_ACTION_REQUEST)
95
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::FOLDER_ACTION_REQUEST)
96
96
  .add_attributes(attrs)
97
97
  end
98
98
 
@@ -55,7 +55,7 @@ module Zm
55
55
  end
56
56
  end
57
57
 
58
- item.extend(DocumentFolder) if item.view == Zm::Client::FolderView::DOCUMENT
58
+ item.extend(ModDocumentFolder) if item.view == Zm::Client::FolderView::DOCUMENT
59
59
 
60
60
  item
61
61
  end
@@ -4,7 +4,7 @@ module Zm
4
4
  module Client
5
5
  # class for folder retention policies collection
6
6
  class FolderRetentionPoliciesCollection
7
- include MissingMethodStaticCollection
7
+ include Zm::Utils::MissingMethodStaticCollection
8
8
 
9
9
  def initialize(parent)
10
10
  @parent = parent
@@ -25,12 +25,16 @@ module Zm
25
25
  end
26
26
 
27
27
  def save!
28
- @parent.soap_connector.invoke(jsns_builder.to_retentionpolicy)
28
+ soap_connector.invoke(jsns_builder.to_retentionpolicy)
29
29
  true
30
30
  end
31
31
 
32
32
  private
33
33
 
34
+ def soap_connector
35
+ @parent.parent.soap_connector
36
+ end
37
+
34
38
  def jsns_builder
35
39
  return @jsns_builder if defined? @jsns_builder
36
40
 
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module FolderView
6
+ UNKNOWN = 'unknown'
7
+ MESSAGE = 'message'
8
+ APPOINTMENT = 'appointment'
9
+ TASK = 'task'
10
+ DOCUMENT = 'document'
11
+ CONTACT = 'contact'
12
+ ALL = [MESSAGE, APPOINTMENT, TASK, DOCUMENT, CONTACT].freeze
13
+ end
14
+ end
15
+ end
@@ -18,7 +18,7 @@ module Zm
18
18
  }
19
19
  attrs.compact!
20
20
 
21
- SoapElement.mail(SoapMailConstants::GET_FOLDER_REQUEST)
21
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::GET_FOLDER_REQUEST)
22
22
  .add_attributes(attrs)
23
23
  end
24
24
  end
@@ -1,22 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DocumentFolder
4
- UUID_REGEX = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
3
+ module Zm
4
+ module Client
5
+ module ModDocumentFolder
6
+ UUID_REGEX = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
5
7
 
6
- def upload(file_path)
7
- uploader = @parent.build_uploader
8
- str = uploader.upload_attachment(file_path)
8
+ def upload(file_path)
9
+ uploader = @parent.build_uploader
10
+ str = uploader.upload_attachment(file_path)
9
11
 
10
- uuid = str.scan(UUID_REGEX).first
12
+ uuid = str.scan(UUID_REGEX).first
11
13
 
12
- raise Zm::Client::RestError, 'failed to extract uuid' if uuid.nil?
14
+ raise Zm::Error::RestError, 'failed to extract uuid' if uuid.nil?
13
15
 
14
- jsns = { doc: { l: @id, upload: { id: uuid } } }
16
+ jsns = { doc: { l: @id, upload: { id: uuid } } }
15
17
 
16
- soap_request = Zm::Client::SoapElement.mail(Zm::Client::SoapMailConstants::SAVE_DOCUMENT_REQUEST)
17
- .add_attributes(jsns)
18
- rep = @parent.soap_connector.invoke(soap_request)
18
+ soap_request = Zm::SoapRequest::SoapElement.mail(Zm::SoapRequest::SoapMailConstants::SAVE_DOCUMENT_REQUEST)
19
+ .add_attributes(jsns)
20
+ rep = @parent.soap_connector.invoke(soap_request)
19
21
 
20
- Zm::Client::DocumentJsnsInitializer.create(@parent, rep[:SaveDocumentResponse][:doc].first)
22
+ Zm::Client::DocumentJsnsInitializer.create(@parent, rep[:SaveDocumentResponse][:doc].first)
23
+ end
24
+ end
21
25
  end
22
26
  end
@@ -15,7 +15,7 @@ module Zm
15
15
  end
16
16
 
17
17
  def build_query
18
- SoapElement.account(SoapAccountConstants::GET_IDENTITIES_REQUEST)
18
+ SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::GET_IDENTITIES_REQUEST)
19
19
  end
20
20
  end
21
21
  end
@@ -4,7 +4,9 @@ module Zm
4
4
  module Client
5
5
  # class account identity
6
6
  class Identity < Base::Object
7
- include RequestMethodsMailbox
7
+ include SoapRequest::RequestMethodsMailbox
8
+ extend Relationship
9
+ has_jsns_builder
8
10
 
9
11
  attr_accessor :id, :name, :zimbraPrefIdentityName, :zimbraPrefFromDisplay, :zimbraPrefFromAddress,
10
12
  :zimbraPrefFromAddressType, :zimbraPrefReplyToEnabled, :zimbraPrefReplyToDisplay,
@@ -34,14 +36,6 @@ module Zm
34
36
  yield(new_identity) if block_given?
35
37
  new_identity
36
38
  end
37
-
38
- private
39
-
40
- def jsns_builder
41
- return @jsns_builder if defined? @jsns_builder
42
-
43
- @jsns_builder = IdentityJsnsBuilder.new(self)
44
- end
45
39
  end
46
40
  end
47
41
  end
@@ -9,32 +9,32 @@ module Zm
9
9
  end
10
10
 
11
11
  def to_jsns
12
- soap_request = SoapElement.account(SoapAccountConstants::CREATE_IDENTITY_REQUEST)
13
- node_identity = SoapElement.create(SoapConstants::IDENTITY)
12
+ soap_request = SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::CREATE_IDENTITY_REQUEST)
13
+ node_identity = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::IDENTITY)
14
14
  .add_attributes({ name: @item.name, _attrs: attrs })
15
15
  soap_request.add_node(node_identity)
16
16
  soap_request
17
17
  end
18
18
 
19
19
  def to_update
20
- soap_request = SoapElement.account(SoapAccountConstants::MODIFY_IDENTITY_REQUEST)
21
- node_identity = SoapElement.create(SoapConstants::IDENTITY)
20
+ soap_request = SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::MODIFY_IDENTITY_REQUEST)
21
+ node_identity = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::IDENTITY)
22
22
  .add_attributes({ id: @item.id, _attrs: attrs })
23
23
  soap_request.add_node(node_identity)
24
24
  soap_request
25
25
  end
26
26
 
27
27
  def to_patch(hash)
28
- soap_request = SoapElement.account(SoapAccountConstants::MODIFY_IDENTITY_REQUEST)
29
- node_identity = SoapElement.create(SoapConstants::IDENTITY)
28
+ soap_request = SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::MODIFY_IDENTITY_REQUEST)
29
+ node_identity = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::IDENTITY)
30
30
  .add_attributes({ id: @item.id, _attrs: hash })
31
31
  soap_request.add_node(node_identity)
32
32
  soap_request
33
33
  end
34
34
 
35
35
  def to_delete
36
- soap_request = SoapElement.account(SoapAccountConstants::DELETE_IDENTITY_REQUEST)
37
- node_identity = SoapElement.create(SoapConstants::IDENTITY)
36
+ soap_request = SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::DELETE_IDENTITY_REQUEST)
37
+ node_identity = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::IDENTITY)
38
38
  .add_attributes({ id: @item.id })
39
39
  soap_request.add_node(node_identity)
40
40
  soap_request
@@ -3,7 +3,7 @@
3
3
  module Zm
4
4
  module Client
5
5
  class LdapFilter
6
- include Zm::Inspector
6
+ include Zm::Utils::Inspector
7
7
 
8
8
  def initialize(base_filter = nil)
9
9
  @base_filter = base_filter
@@ -9,7 +9,7 @@ module Zm
9
9
  end
10
10
 
11
11
  def find
12
- soap_request = SoapElement.admin(SoapAdminConstants::GET_LICENSE_REQUEST)
12
+ soap_request = Zm::SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::GET_LICENSE_REQUEST)
13
13
  entry = @parent.soap_admin_connector.invoke(soap_request)[:GetLicenseResponse][:license].first
14
14
  LicenseJsnsInitializer.create(@parent, entry)
15
15
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'mailbox_item_id'
4
-
5
3
  module Zm
6
4
  module Client
7
5
  module MailboxItemConcern
@@ -4,10 +4,12 @@ module Zm
4
4
  module Client
5
5
  # class message for account
6
6
  class Message < Base::Object
7
- include BelongsToFolder
8
- include BelongsToTag
9
- include RequestMethodsMailbox
7
+ include Zm::Utils::BelongsToFolder
8
+ include Zm::Utils::BelongsToTag
9
+ include SoapRequest::RequestMethodsMailbox
10
10
  include MailboxItemConcern
11
+ extend Relationship
12
+ has_jsns_builder
11
13
 
12
14
  attr_accessor :d, :f, :su, :fr, :autoSendTime, :mid, :idnt, :tn, :subject, :s
13
15
  attr_reader :recipients, :attachments, :body
@@ -15,14 +17,13 @@ module Zm
15
17
  alias size s
16
18
 
17
19
  def initialize(parent)
18
- @parent = parent
19
20
  @subject = ''
20
21
 
21
- @recipients = Recipients.new
22
+ @recipients = MessageRecipients.new
22
23
  @body = Body.new
23
- @attachments = AttachmentsCollection.new
24
+ @attachments = MessageAttachmentsCollection.new
24
25
 
25
- yield(self) if block_given?
26
+ super
26
27
  end
27
28
 
28
29
  def download(dest_file_path, fmt: 'eml')
@@ -44,7 +45,7 @@ module Zm
44
45
  def flags
45
46
  return @flags if defined? @flags
46
47
 
47
- @flags = FlagsCollection.new(self)
48
+ @flags = MessageFlagsCollection.new(self)
48
49
  end
49
50
 
50
51
  def create!(*args)
@@ -66,14 +67,14 @@ module Zm
66
67
  def update!(attrs)
67
68
  authorized_keys = %i[l rgb color f tn]
68
69
 
69
- attrs.reject! { |k| !authorized_keys.include?(k) }
70
+ attrs.select! { |k| authorized_keys.include?(k) }
70
71
 
71
- attrs.merge!({ op: :update, id: id })
72
+ attrs.merge!({ op: :update, id: })
72
73
 
73
74
  attrs.compact!
74
75
 
75
- soap_request = SoapElement.mail(SoapMailConstants::ITEM_ACTION_REQUEST)
76
- node_action = SoapElement.create(SoapConstants::ACTION).add_attributes(attrs)
76
+ soap_request = SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::ITEM_ACTION_REQUEST)
77
+ node_action = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::ACTION).add_attributes(attrs)
77
78
  soap_request.add_node(node_action)
78
79
  @parent.soap_connector.invoke(soap_request)
79
80
  end
@@ -107,7 +108,7 @@ module Zm
107
108
  end
108
109
 
109
110
  def build_send
110
- SoapElement.mail(SoapMailConstants::SEND_MSG_REQUEST)
111
+ SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::SEND_MSG_REQUEST)
111
112
  .add_attributes(jsns_builder.to_jsns)
112
113
  end
113
114
 
@@ -115,12 +116,6 @@ module Zm
115
116
  class Body
116
117
  attr_accessor :text, :html
117
118
  end
118
-
119
- def jsns_builder
120
- return @jsns_builder if defined? @jsns_builder
121
-
122
- @jsns_builder = MessageJsnsBuilder.new(self)
123
- end
124
119
  end
125
120
  end
126
121
  end