zm-ruby-client 0.14.0 → 0.17.1

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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +1 -0
  4. data/README.md +6 -0
  5. data/lib/zm/client/account/account.rb +29 -17
  6. data/lib/zm/client/account/account_jsns_initializer.rb +44 -0
  7. data/lib/zm/client/account/accounts_builder.rb +6 -3
  8. data/lib/zm/client/account/accounts_collection.rb +11 -20
  9. data/lib/zm/client/account.rb +1 -0
  10. data/lib/zm/client/ace/ace.rb +22 -9
  11. data/lib/zm/client/ace/ace_jsns_builder.rb +38 -0
  12. data/lib/zm/client/ace/ace_jsns_initializer.rb +26 -0
  13. data/lib/zm/client/ace/aces_builder.rb +6 -9
  14. data/lib/zm/client/ace/aces_collection.rb +23 -9
  15. data/lib/zm/client/ace.rb +2 -0
  16. data/lib/zm/client/appointment/appointment.rb +9 -6
  17. data/lib/zm/client/appointment/appointments_collection.rb +6 -90
  18. data/lib/zm/client/backup/backup.rb +8 -4
  19. data/lib/zm/client/base/account_object.rb +34 -0
  20. data/lib/zm/client/base/account_objects_collection.rb +14 -0
  21. data/lib/zm/client/base/account_search_objects_collection.rb +125 -0
  22. data/lib/zm/client/base/admin_object.rb +6 -0
  23. data/lib/zm/client/base/admin_objects_collection.rb +65 -0
  24. data/lib/zm/client/base/base_jsns_builder.rb +19 -0
  25. data/lib/zm/client/base/base_jsns_initializer.rb +29 -0
  26. data/lib/zm/client/base/folder_object.rb +41 -0
  27. data/lib/zm/client/base/ldap_filter.rb +33 -0
  28. data/lib/zm/client/base/object.rb +19 -0
  29. data/lib/zm/client/base/objects_builder.rb +4 -0
  30. data/lib/zm/client/base/objects_collection.rb +11 -32
  31. data/lib/zm/client/base/zimbra_attribute.rb +119 -0
  32. data/lib/zm/client/base/zimbra_attributes_collection.rb +38 -0
  33. data/lib/zm/client/base.rb +15 -0
  34. data/lib/zm/client/cluster/cluster.rb +43 -7
  35. data/lib/zm/client/cluster/cluster_config.rb +19 -17
  36. data/lib/zm/client/connector/rest_account.rb +0 -3
  37. data/lib/zm/client/connector/soap_account.rb +66 -123
  38. data/lib/zm/client/connector/soap_admin.rb +28 -16
  39. data/lib/zm/client/connector/soap_base.rb +11 -3
  40. data/lib/zm/client/contact/contact.rb +2 -1
  41. data/lib/zm/client/contact/contacts_builder.rb +3 -13
  42. data/lib/zm/client/contact/contacts_collection.rb +6 -12
  43. data/lib/zm/client/cos/cos.rb +9 -5
  44. data/lib/zm/client/cos/coses_builder.rb +1 -16
  45. data/lib/zm/client/cos/coses_collection.rb +6 -9
  46. data/lib/zm/client/distributionlist/distributionlist.rb +44 -6
  47. data/lib/zm/client/distributionlist/distributionlists_builder.rb +2 -17
  48. data/lib/zm/client/distributionlist/distributionlists_collection.rb +4 -11
  49. data/lib/zm/client/distributionlist/dls_membership_collection.rb +24 -0
  50. data/lib/zm/client/distributionlist.rb +1 -0
  51. data/lib/zm/client/document/document.rb +7 -9
  52. data/lib/zm/client/domain/domain.rb +11 -6
  53. data/lib/zm/client/domain/domain_accounts_collection.rb +13 -0
  54. data/lib/zm/client/domain/domains_builder.rb +1 -19
  55. data/lib/zm/client/domain/domains_collection.rb +7 -10
  56. data/lib/zm/client/domain.rb +1 -0
  57. data/lib/zm/client/folder/folder.rb +50 -124
  58. data/lib/zm/client/folder/folder_grant.rb +44 -22
  59. data/lib/zm/client/folder/folder_grant_jsns_builder.rb +43 -0
  60. data/lib/zm/client/folder/folder_grants_collection.rb +35 -0
  61. data/lib/zm/client/folder/folder_jsns_builder.rb +132 -0
  62. data/lib/zm/client/folder/folder_jsns_initializer.rb +49 -0
  63. data/lib/zm/client/folder/folder_retention_policies_collection.rb +40 -0
  64. data/lib/zm/client/folder/folder_retention_policy.rb +8 -30
  65. data/lib/zm/client/folder/folders_builder.rb +2 -2
  66. data/lib/zm/client/folder/folders_collection.rb +21 -19
  67. data/lib/zm/client/folder/folders_jsns_builder.rb +22 -0
  68. data/lib/zm/client/folder.rb +6 -0
  69. data/lib/zm/client/identity/identities_builder.rb +4 -15
  70. data/lib/zm/client/identity/identities_collection.rb +7 -13
  71. data/lib/zm/client/identity/identity.rb +7 -5
  72. data/lib/zm/client/message/message.rb +111 -21
  73. data/lib/zm/client/message/messages_builder.rb +1 -1
  74. data/lib/zm/client/message/messages_collection.rb +10 -92
  75. data/lib/zm/client/mountpoint/mountpoint.rb +15 -68
  76. data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +100 -0
  77. data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +33 -0
  78. data/lib/zm/client/mountpoint/mountpoints_builder.rb +1 -1
  79. data/lib/zm/client/mountpoint/mountpoints_collection.rb +14 -23
  80. data/lib/zm/client/mountpoint.rb +2 -0
  81. data/lib/zm/client/resource/resource.rb +5 -5
  82. data/lib/zm/client/resource/resources_builder.rb +1 -16
  83. data/lib/zm/client/resource/resources_collection.rb +5 -13
  84. data/lib/zm/client/search_folder/search_folder.rb +19 -39
  85. data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +86 -0
  86. data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +33 -0
  87. data/lib/zm/client/search_folder/search_folders_builder.rb +7 -11
  88. data/lib/zm/client/search_folder/search_folders_collection.rb +7 -15
  89. data/lib/zm/client/search_folder.rb +2 -0
  90. data/lib/zm/client/server/server.rb +7 -14
  91. data/lib/zm/client/server/server_accounts_collection.rb +19 -0
  92. data/lib/zm/client/server/servers_builder.rb +4 -16
  93. data/lib/zm/client/server/servers_collection.rb +5 -10
  94. data/lib/zm/client/server.rb +1 -0
  95. data/lib/zm/client/share/share.rb +2 -9
  96. data/lib/zm/client/share/shares_builder.rb +3 -12
  97. data/lib/zm/client/signature/signature.rb +17 -13
  98. data/lib/zm/client/signature/signature_jsns_builder.rb +5 -1
  99. data/lib/zm/client/signature/signature_jsns_initializer.rb +25 -0
  100. data/lib/zm/client/signature/signatures_builder.rb +7 -11
  101. data/lib/zm/client/signature/signatures_collection.rb +6 -14
  102. data/lib/zm/client/signature.rb +1 -0
  103. data/lib/zm/client/tag/tag.rb +27 -20
  104. data/lib/zm/client/tag/tag_jsns_builder.rb +55 -0
  105. data/lib/zm/client/tag/tag_jsns_initializer.rb +26 -0
  106. data/lib/zm/client/tag/tags_builder.rb +6 -9
  107. data/lib/zm/client/tag/tags_collection.rb +6 -12
  108. data/lib/zm/client/tag.rb +2 -0
  109. data/lib/zm/client/task/tasks_collection.rb +6 -90
  110. data/lib/zm/client/upload/upload.rb +1 -1
  111. data/lib/zm/client/version.rb +2 -2
  112. data/lib/zm/modules/common/dl_common.rb +3 -1
  113. data/lib/zm/modules/common/zimbra-attrs.json.bak +1 -0
  114. data/lib/zm/modules/zm_logger.rb +24 -0
  115. data/lib/zm/modules/zm_model.rb +41 -0
  116. data/test/accounts.rb +15 -1
  117. data/test/ace.rb +50 -0
  118. data/test/cluster.rb +41 -0
  119. data/test/cluster_zimbra_attributes.rb +38 -0
  120. data/test/folder.rb +125 -0
  121. data/test/folder_grant.rb +51 -0
  122. data/test/mountpoint.rb +49 -0
  123. data/test/retention_policies.rb +40 -0
  124. data/test/search_folder.rb +67 -0
  125. data/test/signature.rb +53 -0
  126. data/test/tag.rb +65 -0
  127. data/test/zimbra_attributes.rb +35 -0
  128. data/zm-ruby-client.gemspec +1 -0
  129. metadata +59 -3
@@ -3,19 +3,18 @@
3
3
  module Zm
4
4
  module Client
5
5
  # Collection servers
6
- class ServersCollection < Base::ObjectsCollection
6
+ class ServersCollection < Base::AdminObjectsCollection
7
7
  def initialize(parent)
8
- @parent = parent
9
- # @service = ServerServices::MAILBOX
8
+ @child_class = Server
9
+ @builder_class = ServersBuilder
10
10
  @service = nil
11
+ super(parent)
11
12
  end
12
13
 
13
14
  def find_by(hash)
14
15
  rep = sac.get_server(hash.values.first, hash.keys.first)
15
16
  entry = rep[:Body][:GetServerResponse][:server].first
16
- server = Server.new(@parent)
17
- server.init_from_json(entry)
18
- server
17
+ build_from_entry(entry)
19
18
  end
20
19
 
21
20
  def where(service)
@@ -25,10 +24,6 @@ module Zm
25
24
 
26
25
  private
27
26
 
28
- def build_response
29
- ServersBuilder.new(@parent, make_query).make
30
- end
31
-
32
27
  def make_query
33
28
  sac.get_all_servers(@service)
34
29
  end
@@ -3,3 +3,4 @@
3
3
  require 'zm/client/server/server'
4
4
  require 'zm/client/server/servers_builder'
5
5
  require 'zm/client/server/servers_collection'
6
+ require 'zm/client/server/server_accounts_collection'
@@ -17,8 +17,8 @@ module Zm
17
17
  yield(self) if block_given?
18
18
  end
19
19
 
20
- def concat
21
- INSTANCE_VARIABLE_KEYS.map { |key| instance_variable_get(arrow_name(key)) }
20
+ def all_instance_variable_keys
21
+ INSTANCE_VARIABLE_KEYS
22
22
  end
23
23
 
24
24
  def create!
@@ -48,13 +48,6 @@ module Zm
48
48
  owner_name = (@ownerName || @ownerEmail).tr('/', '-')
49
49
  "#{folder_name} (#{owner_name})"
50
50
  end
51
-
52
- def init_from_json(json)
53
- INSTANCE_VARIABLE_KEYS.each do |key|
54
- var_name = "@#{key}"
55
- instance_variable_set(var_name, json[key])
56
- end
57
- end
58
51
  end
59
52
  end
60
53
  end
@@ -5,18 +5,9 @@ module Zm
5
5
  # class factory [shares]
6
6
  class ShareBuilder < Base::ObjectsBuilder
7
7
  def initialize(parent, json)
8
- @parent = parent
9
- @json = json
10
- end
11
-
12
- def make
13
- root = @json[:Body][:GetShareInfoResponse][:share]
14
- return [] if root.nil?
15
-
16
- root = [root] unless root.is_a?(Array)
17
- root.map do |s|
18
- Share.new(@parent, s)
19
- end
8
+ super(parent, json)
9
+ @child_class = Share
10
+ @json_item_key = :share
20
11
  end
21
12
  end
22
13
  end
@@ -4,37 +4,35 @@ module Zm
4
4
  module Client
5
5
  # class account signature
6
6
  class Signature < Base::AccountObject
7
+ include Zm::Model::AttributeChangeObserver
8
+
7
9
  TYPE_TXT = 'text/plain'
8
10
  TYPE_HTML = 'text/html'
9
11
 
10
12
  INSTANCE_VARIABLE_KEYS = %i[id name txt html]
11
13
 
12
- attr_accessor *INSTANCE_VARIABLE_KEYS
14
+ attr_reader :id
13
15
 
14
- def concat
15
- INSTANCE_VARIABLE_KEYS.map { |key| instance_variable_get(arrow_name(key)) }
16
- end
16
+ define_changed_attributes :name, :txt, :html
17
17
 
18
- def init_from_json(json)
19
- @id = json[:id]
20
- @name = json[:name]
21
- json[:content].each do |c|
22
- @txt = c[:_content] if c[:type] == TYPE_TXT
23
- @html = c[:_content] if c[:type] == TYPE_HTML
24
- end if json[:content].is_a?(Array)
18
+ def all_instance_variable_keys
19
+ INSTANCE_VARIABLE_KEYS
25
20
  end
26
21
 
27
22
  def create!
28
23
  rep = @parent.sacc.create_signature(@parent.token, as_jsns)
29
24
  @id = rep[:Body][:CreateSignatureResponse][:signature].first[:id]
25
+ super
30
26
  end
31
27
 
32
28
  def modify!
33
29
  @parent.sacc.modify_signature(@parent.token, as_jsns)
30
+ super
34
31
  end
35
32
 
36
33
  def delete!
37
- @parent.sacc.delete_signature(@parent.token, id)
34
+ @parent.sacc.delete_signature(@parent.token, jsns_builder.to_delete)
35
+ super
38
36
  end
39
37
 
40
38
  def type
@@ -54,8 +52,14 @@ module Zm
54
52
  html || txt
55
53
  end
56
54
 
55
+ private
56
+
57
+ def jsns_builder
58
+ @jsns_builder ||= SignatureJsnsBuilder.new(self)
59
+ end
60
+
57
61
  def as_jsns
58
- SignatureJsnsBuilder.new(self).to_jsns
62
+ jsns_builder.to_jsns
59
63
  end
60
64
  end
61
65
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Zm
4
4
  module Client
5
- # class for account signature
5
+ # class for account signature jsns builder
6
6
  class SignatureJsnsBuilder
7
7
 
8
8
  def initialize(signature)
@@ -24,6 +24,10 @@ module Zm
24
24
 
25
25
  jsns
26
26
  end
27
+
28
+ def to_delete
29
+ { signature: { id: @signature.id } }
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ # class for initialize account signature
6
+ class SignatureJsnsInitializer < Base::BaseJsnsInitializer
7
+
8
+ def initialize(parent, json)
9
+ super(parent, json)
10
+ @child_class = Signature
11
+ end
12
+
13
+ def create
14
+ super
15
+
16
+ @json[:content].each do |c|
17
+ @item.instance_variable_set(:@txt, c[:_content]) if c[:type] == Signature::TYPE_TXT
18
+ @item.instance_variable_set(:@html, c[:_content]) if c[:type] == Signature::TYPE_HTML
19
+ end if @json[:content].is_a?(Array)
20
+
21
+ @item
22
+ end
23
+ end
24
+ end
25
+ end
@@ -2,23 +2,19 @@
2
2
 
3
3
  module Zm
4
4
  module Client
5
- # class factory [folders]
5
+ # class factory [signatures]
6
6
  class SignaturesBuilder < Base::ObjectsBuilder
7
7
  def initialize(parent, json)
8
- @parent = parent
9
- @json = json
8
+ super(parent, json)
9
+ @child_class = Signature
10
+ @json_item_key = :signature
10
11
  end
11
12
 
12
13
  def make
13
- root = @json[:Body][:GetSignaturesResponse][:signature]
14
- return [] if root.nil?
14
+ return [] if json_items.nil?
15
15
 
16
- root = [root] unless root.is_a?(Array)
17
-
18
- root.map do |s|
19
- signature = Signature.new(@parent)
20
- signature.init_from_json(s)
21
- signature
16
+ json_items.map do |entry|
17
+ SignatureJsnsInitializer.new(@parent, entry).create
22
18
  end
23
19
  end
24
20
  end
@@ -3,25 +3,17 @@
3
3
  module Zm
4
4
  module Client
5
5
  # collection of signatures
6
- class SignaturesCollection < Base::ObjectsCollection
7
- METHODS_MISSING_LIST = %i[select each map length].to_set.freeze
8
-
6
+ class SignaturesCollection < Base::AccountObjectsCollection
9
7
  def initialize(parent)
10
- @parent = parent
11
- end
12
-
13
- def new
14
- signature = Signature.new(@parent)
15
- yield(signature) if block_given?
16
- signature
8
+ @child_class = Signature
9
+ @builder_class = SignaturesBuilder
10
+ super(parent)
17
11
  end
18
12
 
19
13
  private
20
14
 
21
- def build_response
22
- rep = @parent.sacc.get_signatures(@parent.token)
23
- sb = SignaturesBuilder.new @parent, rep
24
- sb.make
15
+ def make_query
16
+ @parent.sacc.get_signatures(@parent.token)
25
17
  end
26
18
  end
27
19
  end
@@ -2,5 +2,6 @@
2
2
 
3
3
  require 'zm/client/signature/signature'
4
4
  require 'zm/client/signature/signature_jsns_builder'
5
+ require 'zm/client/signature/signature_jsns_initializer'
5
6
  require 'zm/client/signature/signatures_builder'
6
7
  require 'zm/client/signature/signatures_collection'
@@ -4,41 +4,48 @@ module Zm
4
4
  module Client
5
5
  # class account tag
6
6
  class Tag < Base::AccountObject
7
+ include Zm::Model::AttributeChangeObserver
7
8
 
8
- INSTANCE_VARIABLE_KEYS = %i[id name color rgb u n d rev md ms]
9
+ INSTANCE_VARIABLE_KEYS = %i[id name color rgb]
9
10
 
10
- attr_accessor *INSTANCE_VARIABLE_KEYS
11
+ attr_accessor :id
11
12
 
12
- def concat
13
- INSTANCE_VARIABLE_KEYS.map { |key| instance_variable_get(arrow_name(key)) }
14
- end
13
+ define_changed_attributes :name, :color, :rgb
15
14
 
16
- def init_from_json(json)
17
- INSTANCE_VARIABLE_KEYS.each do |key|
18
- instance_variable_set(arrow_name(key), json[key])
19
- end
15
+ def all_instance_variable_keys
16
+ INSTANCE_VARIABLE_KEYS
20
17
  end
21
18
 
22
19
  def create!
23
- rep = @parent.sacc.create_tag(@parent.token, @name, @color, @rgb)
24
- init_from_json(rep[:Body][:CreateTagResponse][:tag].first)
20
+ rep = @parent.sacc.create_tag(@parent.token, jsns_builder.to_jsns)
21
+ json = rep[:Body][:CreateTagResponse][:tag].first
22
+ TagJsnsInitializer.update(self, json)
23
+ super
25
24
  end
26
25
 
27
26
  def modify!
28
- @parent.sacc.tag_action(@parent.token, :update, @id, { color: @color, rgb: @rgb })
27
+ @parent.sacc.tag_action(@parent.token, jsns_builder.to_update) if color_changed? || rgb_changed?
28
+ super
29
+ end
30
+
31
+ def update!(hash)
32
+ # todo
29
33
  end
30
34
 
31
35
  def delete!
32
- @parent.sacc.tag_action(@parent.token, :delete, @id)
36
+ @parent.sacc.tag_action(@parent.token, jsns_builder.to_delete)
37
+ super
33
38
  end
34
39
 
35
- def rename!(new_name)
36
- @parent.sacc.tag_action(
37
- @parent.token,
38
- :rename,
39
- @id,
40
- name: new_name
41
- )
40
+ def rename!
41
+ @parent.sacc.tag_action(@parent.token, jsns_builder.to_rename) if name_changed?
42
+ super
43
+ end
44
+
45
+ private
46
+
47
+ def jsns_builder
48
+ @jsns_builder ||= TagJsnsBuilder.new(self)
42
49
  end
43
50
  end
44
51
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ # class for account tag jsns builder
6
+ class TagJsnsBuilder
7
+
8
+ def initialize(tag)
9
+ @tag = tag
10
+ end
11
+
12
+ def to_jsns
13
+ tag = {
14
+ name: @tag.name,
15
+ color: @tag.color,
16
+ rgb: @tag.rgb
17
+ }.delete_if { |_, v| v.nil? }
18
+
19
+ { tag: tag }
20
+ end
21
+
22
+ alias to_create to_jsns
23
+
24
+ def to_update
25
+ action = {
26
+ op: :update,
27
+ id: @tag.id,
28
+ color: @tag.color,
29
+ rgb: @tag.rgb
30
+ }.reject { |_, v| v.nil? }
31
+
32
+ { action: action }
33
+ end
34
+
35
+ def to_delete
36
+ action = {
37
+ op: :delete,
38
+ id: @tag.id
39
+ }
40
+
41
+ { action: action }
42
+ end
43
+
44
+ def to_rename
45
+ action = {
46
+ op: :rename,
47
+ id: @tag.id,
48
+ name: @tag.name
49
+ }
50
+
51
+ { action: action }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ # class for initialize account tag
6
+ class TagJsnsInitializer
7
+ class << self
8
+ def create(parent, json)
9
+ item = Tag.new(parent)
10
+
11
+ update(item, json)
12
+ end
13
+
14
+ def update(item, json)
15
+
16
+ item.instance_variable_set(:@id, json[:id])
17
+ item.instance_variable_set(:@name, json[:name])
18
+ item.instance_variable_set(:@color, json[:color].to_i)
19
+ item.instance_variable_set(:@rgb, json[:rgb])
20
+
21
+ item
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -5,19 +5,16 @@ module Zm
5
5
  # class factory [tags]
6
6
  class TagBuilder < Base::ObjectsBuilder
7
7
  def initialize(parent, json)
8
- @parent = parent
9
- @json = json
8
+ super(parent, json)
9
+ @child_class = Tag
10
+ @json_item_key = :tag
10
11
  end
11
12
 
12
13
  def make
13
- root = @json[:Body][:GetTagResponse][:tag]
14
- return [] if root.nil?
14
+ return [] if json_items.nil?
15
15
 
16
- root = [root] unless root.is_a?(Array)
17
- root.map do |s|
18
- tag = Tag.new(@parent)
19
- tag.init_from_json(s)
20
- tag
16
+ json_items.map do |entry|
17
+ TagJsnsInitializer.create(@parent, entry)
21
18
  end
22
19
  end
23
20
  end
@@ -3,23 +3,17 @@
3
3
  module Zm
4
4
  module Client
5
5
  # collection account tags
6
- class TagsCollection < Base::ObjectsCollection
6
+ class TagsCollection < Base::AccountObjectsCollection
7
7
  def initialize(parent)
8
- @parent = parent
9
- end
10
-
11
- def new
12
- tag = Tag.new(@parent)
13
- yield(tag) if block_given?
14
- tag
8
+ @child_class = Tag
9
+ @builder_class = TagBuilder
10
+ super(parent)
15
11
  end
16
12
 
17
13
  private
18
14
 
19
- def build_response
20
- rep = @parent.sacc.get_tag(@parent.token)
21
- tb = TagBuilder.new @parent, rep
22
- tb.make
15
+ def make_query
16
+ @parent.sacc.get_tag(@parent.token)
23
17
  end
24
18
  end
25
19
  end
data/lib/zm/client/tag.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'zm/client/tag/tag'
4
+ require 'zm/client/tag/tag_jsns_builder'
5
+ require 'zm/client/tag/tag_jsns_initializer'
4
6
  require 'zm/client/tag/tags_builder'
5
7
  require 'zm/client/tag/tags_collection'
@@ -3,97 +3,13 @@
3
3
  module Zm
4
4
  module Client
5
5
  # collection of tasks
6
- class TasksCollection < Base::ObjectsCollection
7
- attr_accessor :more
8
-
6
+ class TasksCollection < Base::AccountSearchObjectsCollection
9
7
  def initialize(parent)
10
- @parent = parent
11
- @more = true
12
- reset_query_params
13
- end
14
-
15
- def new
16
- task = Task.new(@parent)
17
- yield(task) if block_given?
18
- task
19
- end
20
-
21
- def start_at(start_at)
22
- @start_at = start_at
23
- self
24
- end
25
-
26
- def end_at(end_at)
27
- @end_at = end_at
28
- self
29
- end
30
-
31
- def folders(folders)
32
- @folders = folders
33
- @folder_ids = @folders.map(&:id)
34
- self
35
- end
36
-
37
- def folder_ids(folder_ids)
38
- @folder_ids = folder_ids
39
- self
40
- end
41
-
42
- def where(query)
43
- @query = query
44
- self
45
- end
46
-
47
- def ids
48
- search_builder.ids
49
- end
50
-
51
- private
52
-
53
- def search_response
54
- rep = @parent.sacc.search(@parent.token, 'task', @offset, @limit, 'taskDueAsc', query, build_options)
55
- @more = rep[:Body][:SearchResponse][:more]
56
- rep
57
- end
58
-
59
- def search_builder
60
- TasksBuilder.new(@parent, search_response)
61
- end
62
-
63
- def build_response
64
- tasks = search_builder.make
65
- tasks.each { |appo| appo.folder = find_folder(appo) } unless @folders.empty?
66
- tasks
67
- end
68
-
69
- def build_options
70
- return {} if !@start_at.is_a?(Time) && !@end_at.is_a?(Time)
71
-
72
- {
73
- calExpandInstStart: (@start_at.to_f * 1000).to_i,
74
- calExpandInstEnd: (@end_at.to_f * 1000).to_i,
75
- }
76
- end
77
-
78
- def query
79
- return @query unless @query.nil?
80
-
81
- return nil if @folder_ids.empty?
82
-
83
- @folder_ids.map { |id| %Q{inid:"#{id}"} }.join(' OR ')
84
- end
85
-
86
- def find_folder(task)
87
- @folders.find { |folder| folder.id == task.l }
88
- end
89
-
90
- def reset_query_params
91
- super
92
- @start_at = nil
93
- @end_at = nil
94
- @query = nil
95
- @folder_ids = []
96
- @folders = []
8
+ super(parent)
9
+ @child_class = Task
10
+ @builder_class = TasksBuilder
11
+ @type = 'task'
12
+ @sort_by = 'taskDueAsc'
97
13
  end
98
14
  end
99
15
  end
@@ -44,7 +44,7 @@ module Zm
44
44
  uri.query_values = h
45
45
  url_folder_path << '?' << uri.query
46
46
 
47
- puts url_folder_path
47
+ # puts url_folder_path
48
48
 
49
49
  url_folder_path
50
50
  end
@@ -9,8 +9,8 @@ module Zm
9
9
 
10
10
  module VERSION
11
11
  MAJOR = 0
12
- MINOR = 14
13
- TINY = 0
12
+ MINOR = 17
13
+ TINY = 1
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
16
16
  end
@@ -8,10 +8,11 @@ module DistributionListCommon
8
8
  zimbraMailForwardingAddress
9
9
  description
10
10
  zimbraDistributionListSendShareMessageToNewMembers
11
+ zimbraHideInGal
11
12
  zimbraNotes
12
13
  ].freeze
13
14
 
14
- ATTRS_READ = %w[zimbraMailAlias]
15
+ ATTRS_READ = %w[zimbraMailAlias zimbraACE]
15
16
 
16
17
  ATTRS_WRITE = %w[
17
18
  zimbraMailStatus
@@ -20,6 +21,7 @@ module DistributionListCommon
20
21
  zimbraMailTransport
21
22
  zimbraMailForwardingAddress
22
23
  description
24
+ zimbraHideInGal
23
25
  zimbraDistributionListSendShareMessageToNewMembers
24
26
  ].freeze
25
27