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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/README.md +6 -0
- data/lib/zm/client/account/account.rb +29 -17
- data/lib/zm/client/account/account_jsns_initializer.rb +44 -0
- data/lib/zm/client/account/accounts_builder.rb +6 -3
- data/lib/zm/client/account/accounts_collection.rb +11 -20
- data/lib/zm/client/account.rb +1 -0
- data/lib/zm/client/ace/ace.rb +22 -9
- data/lib/zm/client/ace/ace_jsns_builder.rb +38 -0
- data/lib/zm/client/ace/ace_jsns_initializer.rb +26 -0
- data/lib/zm/client/ace/aces_builder.rb +6 -9
- data/lib/zm/client/ace/aces_collection.rb +23 -9
- data/lib/zm/client/ace.rb +2 -0
- data/lib/zm/client/appointment/appointment.rb +9 -6
- data/lib/zm/client/appointment/appointments_collection.rb +6 -90
- data/lib/zm/client/backup/backup.rb +8 -4
- data/lib/zm/client/base/account_object.rb +34 -0
- data/lib/zm/client/base/account_objects_collection.rb +14 -0
- data/lib/zm/client/base/account_search_objects_collection.rb +125 -0
- data/lib/zm/client/base/admin_object.rb +6 -0
- data/lib/zm/client/base/admin_objects_collection.rb +65 -0
- data/lib/zm/client/base/base_jsns_builder.rb +19 -0
- data/lib/zm/client/base/base_jsns_initializer.rb +29 -0
- data/lib/zm/client/base/folder_object.rb +41 -0
- data/lib/zm/client/base/ldap_filter.rb +33 -0
- data/lib/zm/client/base/object.rb +19 -0
- data/lib/zm/client/base/objects_builder.rb +4 -0
- data/lib/zm/client/base/objects_collection.rb +11 -32
- data/lib/zm/client/base/zimbra_attribute.rb +119 -0
- data/lib/zm/client/base/zimbra_attributes_collection.rb +38 -0
- data/lib/zm/client/base.rb +15 -0
- data/lib/zm/client/cluster/cluster.rb +43 -7
- data/lib/zm/client/cluster/cluster_config.rb +19 -17
- data/lib/zm/client/connector/rest_account.rb +0 -3
- data/lib/zm/client/connector/soap_account.rb +66 -123
- data/lib/zm/client/connector/soap_admin.rb +28 -16
- data/lib/zm/client/connector/soap_base.rb +11 -3
- data/lib/zm/client/contact/contact.rb +2 -1
- data/lib/zm/client/contact/contacts_builder.rb +3 -13
- data/lib/zm/client/contact/contacts_collection.rb +6 -12
- data/lib/zm/client/cos/cos.rb +9 -5
- data/lib/zm/client/cos/coses_builder.rb +1 -16
- data/lib/zm/client/cos/coses_collection.rb +6 -9
- data/lib/zm/client/distributionlist/distributionlist.rb +44 -6
- data/lib/zm/client/distributionlist/distributionlists_builder.rb +2 -17
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +4 -11
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +24 -0
- data/lib/zm/client/distributionlist.rb +1 -0
- data/lib/zm/client/document/document.rb +7 -9
- data/lib/zm/client/domain/domain.rb +11 -6
- data/lib/zm/client/domain/domain_accounts_collection.rb +13 -0
- data/lib/zm/client/domain/domains_builder.rb +1 -19
- data/lib/zm/client/domain/domains_collection.rb +7 -10
- data/lib/zm/client/domain.rb +1 -0
- data/lib/zm/client/folder/folder.rb +50 -124
- data/lib/zm/client/folder/folder_grant.rb +44 -22
- data/lib/zm/client/folder/folder_grant_jsns_builder.rb +43 -0
- data/lib/zm/client/folder/folder_grants_collection.rb +35 -0
- data/lib/zm/client/folder/folder_jsns_builder.rb +132 -0
- data/lib/zm/client/folder/folder_jsns_initializer.rb +49 -0
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +40 -0
- data/lib/zm/client/folder/folder_retention_policy.rb +8 -30
- data/lib/zm/client/folder/folders_builder.rb +2 -2
- data/lib/zm/client/folder/folders_collection.rb +21 -19
- data/lib/zm/client/folder/folders_jsns_builder.rb +22 -0
- data/lib/zm/client/folder.rb +6 -0
- data/lib/zm/client/identity/identities_builder.rb +4 -15
- data/lib/zm/client/identity/identities_collection.rb +7 -13
- data/lib/zm/client/identity/identity.rb +7 -5
- data/lib/zm/client/message/message.rb +111 -21
- data/lib/zm/client/message/messages_builder.rb +1 -1
- data/lib/zm/client/message/messages_collection.rb +10 -92
- data/lib/zm/client/mountpoint/mountpoint.rb +15 -68
- data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +100 -0
- data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +33 -0
- data/lib/zm/client/mountpoint/mountpoints_builder.rb +1 -1
- data/lib/zm/client/mountpoint/mountpoints_collection.rb +14 -23
- data/lib/zm/client/mountpoint.rb +2 -0
- data/lib/zm/client/resource/resource.rb +5 -5
- data/lib/zm/client/resource/resources_builder.rb +1 -16
- data/lib/zm/client/resource/resources_collection.rb +5 -13
- data/lib/zm/client/search_folder/search_folder.rb +19 -39
- data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +86 -0
- data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +33 -0
- data/lib/zm/client/search_folder/search_folders_builder.rb +7 -11
- data/lib/zm/client/search_folder/search_folders_collection.rb +7 -15
- data/lib/zm/client/search_folder.rb +2 -0
- data/lib/zm/client/server/server.rb +7 -14
- data/lib/zm/client/server/server_accounts_collection.rb +19 -0
- data/lib/zm/client/server/servers_builder.rb +4 -16
- data/lib/zm/client/server/servers_collection.rb +5 -10
- data/lib/zm/client/server.rb +1 -0
- data/lib/zm/client/share/share.rb +2 -9
- data/lib/zm/client/share/shares_builder.rb +3 -12
- data/lib/zm/client/signature/signature.rb +17 -13
- data/lib/zm/client/signature/signature_jsns_builder.rb +5 -1
- data/lib/zm/client/signature/signature_jsns_initializer.rb +25 -0
- data/lib/zm/client/signature/signatures_builder.rb +7 -11
- data/lib/zm/client/signature/signatures_collection.rb +6 -14
- data/lib/zm/client/signature.rb +1 -0
- data/lib/zm/client/tag/tag.rb +27 -20
- data/lib/zm/client/tag/tag_jsns_builder.rb +55 -0
- data/lib/zm/client/tag/tag_jsns_initializer.rb +26 -0
- data/lib/zm/client/tag/tags_builder.rb +6 -9
- data/lib/zm/client/tag/tags_collection.rb +6 -12
- data/lib/zm/client/tag.rb +2 -0
- data/lib/zm/client/task/tasks_collection.rb +6 -90
- data/lib/zm/client/upload/upload.rb +1 -1
- data/lib/zm/client/version.rb +2 -2
- data/lib/zm/modules/common/dl_common.rb +3 -1
- data/lib/zm/modules/common/zimbra-attrs.json.bak +1 -0
- data/lib/zm/modules/zm_logger.rb +24 -0
- data/lib/zm/modules/zm_model.rb +41 -0
- data/test/accounts.rb +15 -1
- data/test/ace.rb +50 -0
- data/test/cluster.rb +41 -0
- data/test/cluster_zimbra_attributes.rb +38 -0
- data/test/folder.rb +125 -0
- data/test/folder_grant.rb +51 -0
- data/test/mountpoint.rb +49 -0
- data/test/retention_policies.rb +40 -0
- data/test/search_folder.rb +67 -0
- data/test/signature.rb +53 -0
- data/test/tag.rb +65 -0
- data/test/zimbra_attributes.rb +35 -0
- data/zm-ruby-client.gemspec +1 -0
- metadata +59 -3
|
@@ -3,20 +3,25 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# collection of folders
|
|
6
|
-
class FoldersCollection < Base::
|
|
7
|
-
METHODS_MISSING_LIST = %i[select each map length].to_set.freeze
|
|
6
|
+
class FoldersCollection < Base::AccountObjectsCollection
|
|
8
7
|
|
|
9
8
|
attr_reader :root
|
|
10
9
|
|
|
10
|
+
attr_accessor :view, :tr, :visible, :needGranteeName, :depth
|
|
11
|
+
|
|
11
12
|
def initialize(parent)
|
|
12
|
-
@
|
|
13
|
+
@child_class = Folder
|
|
14
|
+
@builder_class = FoldersBuilder
|
|
15
|
+
super(parent)
|
|
13
16
|
@root = nil
|
|
14
17
|
reset_query_params
|
|
15
18
|
end
|
|
16
19
|
|
|
17
|
-
def
|
|
18
|
-
folder =
|
|
19
|
-
|
|
20
|
+
def find(id)
|
|
21
|
+
folder = @child_class.new(@parent) do |f|
|
|
22
|
+
f.id = id
|
|
23
|
+
end
|
|
24
|
+
folder.reload!
|
|
20
25
|
folder
|
|
21
26
|
end
|
|
22
27
|
|
|
@@ -28,16 +33,7 @@ module Zm
|
|
|
28
33
|
end
|
|
29
34
|
|
|
30
35
|
def ids
|
|
31
|
-
|
|
32
|
-
fb.ids
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def all
|
|
36
|
-
@all || all!
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def all!
|
|
40
|
-
build_response
|
|
36
|
+
@builder_class.new(@parent, make_query).ids
|
|
41
37
|
end
|
|
42
38
|
|
|
43
39
|
def clear
|
|
@@ -74,8 +70,7 @@ module Zm
|
|
|
74
70
|
private
|
|
75
71
|
|
|
76
72
|
def build_response
|
|
77
|
-
|
|
78
|
-
fb = FoldersBuilder.new @parent, rep
|
|
73
|
+
fb = @builder_class.new(@parent, make_query)
|
|
79
74
|
@root = fb.make
|
|
80
75
|
@all = fb.flatten
|
|
81
76
|
@all.select! { |folder| folder.view == @view } unless @view.nil?
|
|
@@ -83,12 +78,19 @@ module Zm
|
|
|
83
78
|
end
|
|
84
79
|
|
|
85
80
|
def make_query
|
|
86
|
-
@parent.sacc.
|
|
81
|
+
@parent.sacc.get_folder(@parent.token, jsns_builder.to_jsns)
|
|
87
82
|
end
|
|
88
83
|
|
|
89
84
|
def reset_query_params
|
|
90
85
|
@view = nil
|
|
91
86
|
@tr = nil
|
|
87
|
+
@visible = nil
|
|
88
|
+
@needGranteeName = nil
|
|
89
|
+
@depth = nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def jsns_builder
|
|
93
|
+
@jsns_builder ||= FoldersJsnsBuilder.new(self)
|
|
92
94
|
end
|
|
93
95
|
end
|
|
94
96
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account collection folders jsns builder
|
|
6
|
+
class FoldersJsnsBuilder
|
|
7
|
+
def initialize(item)
|
|
8
|
+
@item = item
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_jsns
|
|
12
|
+
{
|
|
13
|
+
visible: @item.visible,
|
|
14
|
+
needGranteeName: @item.needGranteeName,
|
|
15
|
+
view: @item.view,
|
|
16
|
+
depth: @item.depth,
|
|
17
|
+
tr: @item.tr
|
|
18
|
+
}.delete_if { |_, v| v.nil? }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/zm/client/folder.rb
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'zm/client/folder/folder'
|
|
4
|
+
require 'zm/client/folder/folder_jsns_builder'
|
|
5
|
+
require 'zm/client/folder/folder_jsns_initializer'
|
|
6
|
+
require 'zm/client/folder/folders_jsns_builder'
|
|
4
7
|
require 'zm/client/folder/folder_grant'
|
|
8
|
+
require 'zm/client/folder/folder_grants_collection'
|
|
9
|
+
require 'zm/client/folder/folder_grant_jsns_builder'
|
|
5
10
|
require 'zm/client/folder/folder_retention_policy'
|
|
11
|
+
require 'zm/client/folder/folder_retention_policies_collection'
|
|
6
12
|
require 'zm/client/folder/folders_builder'
|
|
7
13
|
require 'zm/client/folder/folders_collection'
|
|
8
14
|
require 'zm/client/folder/mod_document_folder'
|
|
@@ -2,23 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
# class factory [
|
|
5
|
+
# class factory [identities]
|
|
6
6
|
class IdentitiesBuilder < Base::ObjectsBuilder
|
|
7
7
|
def initialize(parent, json)
|
|
8
|
-
|
|
9
|
-
@
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def make
|
|
13
|
-
root = @json[:Body][:GetIdentitiesResponse][:identity]
|
|
14
|
-
return [] if root.nil?
|
|
15
|
-
|
|
16
|
-
root = [root] unless root.is_a?(Array)
|
|
17
|
-
root.map do |s|
|
|
18
|
-
identity = Identity.new(@parent)
|
|
19
|
-
identity.init_from_json(s)
|
|
20
|
-
identity
|
|
21
|
-
end
|
|
8
|
+
super(parent, json)
|
|
9
|
+
@child_class = Identity
|
|
10
|
+
@json_item_key = :identity
|
|
22
11
|
end
|
|
23
12
|
end
|
|
24
13
|
end
|
|
@@ -2,24 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
# collection account
|
|
6
|
-
class IdentitiesCollection < Base::
|
|
5
|
+
# collection account identities
|
|
6
|
+
class IdentitiesCollection < Base::AccountObjectsCollection
|
|
7
7
|
def initialize(parent)
|
|
8
|
-
@
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def new
|
|
12
|
-
identity = Identity.new(@parent)
|
|
13
|
-
yield(identity) if block_given?
|
|
14
|
-
identity
|
|
8
|
+
@child_class = Identity
|
|
9
|
+
@builder_class = IdentitiesBuilder
|
|
10
|
+
super(parent)
|
|
15
11
|
end
|
|
16
12
|
|
|
17
13
|
private
|
|
18
14
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
ib = IdentitiesBuilder.new @parent, rep
|
|
22
|
-
ib.make
|
|
15
|
+
def make_query
|
|
16
|
+
@parent.sacc.get_all_identities(@parent.token)
|
|
23
17
|
end
|
|
24
18
|
end
|
|
25
19
|
end
|
|
@@ -17,13 +17,14 @@ module Zm
|
|
|
17
17
|
|
|
18
18
|
attr_accessor *INSTANCE_VARIABLE_KEYS
|
|
19
19
|
|
|
20
|
-
def
|
|
21
|
-
INSTANCE_VARIABLE_KEYS
|
|
20
|
+
def all_instance_variable_keys
|
|
21
|
+
INSTANCE_VARIABLE_KEYS
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def init_from_json(json)
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
@id = json[:id]
|
|
26
|
+
@name = json[:name]
|
|
27
|
+
all_instance_variable_keys.each do |key|
|
|
27
28
|
value = json[:_attrs][key]
|
|
28
29
|
next if value.nil?
|
|
29
30
|
|
|
@@ -55,7 +56,8 @@ module Zm
|
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
def delete!
|
|
58
|
-
@parent.sacc.delete_identity(@parent.token, id)
|
|
59
|
+
@parent.sacc.delete_identity(@parent.token, @id)
|
|
60
|
+
super
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
def rename!(new_name)
|
|
@@ -4,7 +4,7 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
# class message for account
|
|
6
6
|
class Message < Base::AccountObject
|
|
7
|
-
INSTANCE_VARIABLE_KEYS = %i[id date l su fr]
|
|
7
|
+
INSTANCE_VARIABLE_KEYS = %i[id date l su fr autoSendTime mid idnt]
|
|
8
8
|
attr_accessor *INSTANCE_VARIABLE_KEYS
|
|
9
9
|
|
|
10
10
|
attr_accessor :subject
|
|
@@ -22,6 +22,14 @@ module Zm
|
|
|
22
22
|
yield(self) if block_given?
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
def has_attachment?
|
|
26
|
+
@has_attachment ||= @attachments.all.any?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def all_instance_variable_keys
|
|
30
|
+
INSTANCE_VARIABLE_KEYS
|
|
31
|
+
end
|
|
32
|
+
|
|
25
33
|
def from
|
|
26
34
|
@from ||= @recipients.find { |r| r.field == Recipient::FROM }
|
|
27
35
|
end
|
|
@@ -31,15 +39,6 @@ module Zm
|
|
|
31
39
|
@l = folder.id
|
|
32
40
|
end
|
|
33
41
|
|
|
34
|
-
def to_jsns
|
|
35
|
-
{
|
|
36
|
-
attach: @attachments.to_jsns,
|
|
37
|
-
e: @recipients.to_jsns,
|
|
38
|
-
su: { _content: @subject },
|
|
39
|
-
mp: @body.to_jsns
|
|
40
|
-
}
|
|
41
|
-
end
|
|
42
|
-
|
|
43
42
|
def delete!
|
|
44
43
|
msg_action('delete')
|
|
45
44
|
end
|
|
@@ -89,6 +88,20 @@ module Zm
|
|
|
89
88
|
@parent.sacc.send_msg(@parent.token, to_jsns)
|
|
90
89
|
end
|
|
91
90
|
|
|
91
|
+
def to_jsns
|
|
92
|
+
h = {
|
|
93
|
+
id: @id,
|
|
94
|
+
attach: @attachments.to_jsns,
|
|
95
|
+
e: @recipients.to_jsns,
|
|
96
|
+
su: { _content: @su },
|
|
97
|
+
mp: @body.to_jsns
|
|
98
|
+
}.delete_if { |_, v| v.nil? }
|
|
99
|
+
|
|
100
|
+
h[:did] = @id if l.to_i == FolderDefault::DRAFTS[:id]
|
|
101
|
+
|
|
102
|
+
h
|
|
103
|
+
end
|
|
104
|
+
|
|
92
105
|
def init_from_json(json)
|
|
93
106
|
# puts json
|
|
94
107
|
@id = json[:id]
|
|
@@ -96,11 +109,54 @@ module Zm
|
|
|
96
109
|
@l = json[:l]
|
|
97
110
|
@su = json[:su]
|
|
98
111
|
@fr = json[:fr]
|
|
112
|
+
@autoSendTime = json[:autoSendTime]
|
|
113
|
+
@mid = json[:mid]
|
|
114
|
+
@idnt = json[:idnt]
|
|
115
|
+
@has_attachment = json[:f].to_s.include?('a')
|
|
99
116
|
|
|
100
117
|
json[:e].each do |e|
|
|
101
118
|
recipient = Recipient.new(e[:t], e[:a], e[:p])
|
|
102
119
|
@recipients.add(recipient)
|
|
103
120
|
end
|
|
121
|
+
|
|
122
|
+
init_part_from_json(json[:mp])
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def init_part_from_json(json)
|
|
126
|
+
return if json.nil?
|
|
127
|
+
# puts json
|
|
128
|
+
json = [json] unless json.is_a?(Array)
|
|
129
|
+
|
|
130
|
+
json.each do |json_part|
|
|
131
|
+
if ['text/plain', 'text/html'].include?(json_part[:ct])
|
|
132
|
+
init_body_from_json(json_part)
|
|
133
|
+
elsif json_part[:cd] == 'attachment'
|
|
134
|
+
init_attachment_from_json(json_part)
|
|
135
|
+
else
|
|
136
|
+
init_part_from_json(json_part[:mp])
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def init_body_from_json(json)
|
|
142
|
+
# puts "\ninit_body_from_json #{json}\n"
|
|
143
|
+
body.text = json[:content] if json[:ct] == 'text/plain'
|
|
144
|
+
body.html = json[:content] if json[:ct] == 'text/html'
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def init_attachment_from_json(json)
|
|
148
|
+
# puts "\ninit_attachment_from_json #{json}\n"
|
|
149
|
+
pj = Zm::Client::Message::Attachment.new(self)
|
|
150
|
+
# pj.part = json[:part],
|
|
151
|
+
pj.mid = json[:mid]
|
|
152
|
+
pj.aid = json[:aid]
|
|
153
|
+
pj.ct = json[:ct]
|
|
154
|
+
pj.s = json[:s]
|
|
155
|
+
pj.filename = json[:filename]
|
|
156
|
+
pj.ci = json[:ci]
|
|
157
|
+
pj.cd = json[:cd]
|
|
158
|
+
pj.part = json[:part]
|
|
159
|
+
attachments.add(pj)
|
|
104
160
|
end
|
|
105
161
|
|
|
106
162
|
def msg_action(action_name, options = {})
|
|
@@ -113,18 +169,18 @@ module Zm
|
|
|
113
169
|
attr_accessor :text, :html
|
|
114
170
|
|
|
115
171
|
def text_jsns
|
|
116
|
-
{ ct: 'text/plain', content: { _content: @text } }
|
|
172
|
+
@text.nil? ? nil : { ct: 'text/plain', content: { _content: @text } }
|
|
117
173
|
end
|
|
118
174
|
|
|
119
175
|
def html_jsns
|
|
120
|
-
{ ct: 'text/html', content: { _content: @html } }
|
|
176
|
+
@html.nil? ? nil : { ct: 'text/html', content: { _content: @html } }
|
|
121
177
|
end
|
|
122
178
|
|
|
123
179
|
def to_jsns
|
|
124
180
|
[
|
|
125
181
|
{
|
|
126
182
|
ct: 'multipart/alternative',
|
|
127
|
-
mp: [text_jsns, html_jsns]
|
|
183
|
+
mp: [text_jsns, html_jsns].compact
|
|
128
184
|
}
|
|
129
185
|
]
|
|
130
186
|
end
|
|
@@ -132,36 +188,66 @@ module Zm
|
|
|
132
188
|
|
|
133
189
|
# collection attachments
|
|
134
190
|
class Attachments
|
|
191
|
+
attr_reader :all
|
|
135
192
|
def initialize
|
|
136
|
-
@
|
|
193
|
+
@all = []
|
|
137
194
|
end
|
|
138
195
|
|
|
139
196
|
def add(attachment)
|
|
140
197
|
return unless attachment.is_a?(Attachment)
|
|
141
198
|
|
|
142
|
-
@
|
|
199
|
+
@all.push(attachment)
|
|
143
200
|
end
|
|
144
201
|
|
|
145
202
|
def to_jsns
|
|
146
|
-
@
|
|
203
|
+
@all.map(&:to_jsns)
|
|
147
204
|
end
|
|
148
205
|
end
|
|
149
206
|
|
|
150
207
|
# class attachment for email
|
|
151
208
|
class Attachment
|
|
152
|
-
attr_accessor :aid, :part, :mid
|
|
209
|
+
attr_accessor :aid, :part, :mid, :ct, :s, :filename, :ci, :cd
|
|
153
210
|
|
|
154
|
-
def initialize
|
|
211
|
+
def initialize(parent)
|
|
212
|
+
@parent = parent
|
|
155
213
|
yield(self) if block_given?
|
|
156
214
|
end
|
|
157
215
|
|
|
216
|
+
def download(dest_file_path)
|
|
217
|
+
h = {
|
|
218
|
+
id: @parent.id,
|
|
219
|
+
part: part,
|
|
220
|
+
auth: 'qp',
|
|
221
|
+
zauthtoken: account.token,
|
|
222
|
+
disp: 'a'
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
url = account.home_url
|
|
226
|
+
|
|
227
|
+
uri = Addressable::URI.new
|
|
228
|
+
uri.query_values = h
|
|
229
|
+
url << '?' << uri.query
|
|
230
|
+
|
|
231
|
+
uploader = Upload.new(@parent, RestAccountConnector.new)
|
|
232
|
+
uploader.download_file_with_url(url, dest_file_path)
|
|
233
|
+
end
|
|
234
|
+
|
|
158
235
|
def to_jsns
|
|
159
236
|
{
|
|
160
|
-
part:
|
|
161
|
-
mid:
|
|
162
|
-
aid:
|
|
237
|
+
part: part,
|
|
238
|
+
mid: mid,
|
|
239
|
+
aid: aid,
|
|
240
|
+
ct: ct,
|
|
241
|
+
s: s,
|
|
242
|
+
filename: filename,
|
|
243
|
+
ci: ci,
|
|
244
|
+
cd: cd
|
|
163
245
|
}.reject { |_, v| v.nil? }
|
|
164
246
|
end
|
|
247
|
+
|
|
248
|
+
def account
|
|
249
|
+
@parent.parent
|
|
250
|
+
end
|
|
165
251
|
end
|
|
166
252
|
|
|
167
253
|
# Collection recipients
|
|
@@ -212,6 +298,10 @@ module Zm
|
|
|
212
298
|
@display_name = display_name
|
|
213
299
|
end
|
|
214
300
|
|
|
301
|
+
def to_s
|
|
302
|
+
"#{@email} (#{@display_name})"
|
|
303
|
+
end
|
|
304
|
+
|
|
215
305
|
def to_jsns
|
|
216
306
|
{
|
|
217
307
|
t: @field,
|
|
@@ -3,108 +3,26 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# Collection Messages
|
|
6
|
-
class MessagesCollection < Base::
|
|
7
|
-
attr_accessor :more
|
|
8
|
-
|
|
6
|
+
class MessagesCollection < Base::AccountSearchObjectsCollection
|
|
9
7
|
def initialize(parent)
|
|
10
|
-
|
|
11
|
-
@
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def find(id)
|
|
17
|
-
rep = @parent.sacc.get_msg(@parent.token, id, { part: 0 })
|
|
18
|
-
entry = rep[:Body][:GetMsgResponse][:m].first
|
|
19
|
-
# puts entry
|
|
20
|
-
msg = Message.new(@parent)
|
|
21
|
-
msg.init_from_json(entry)
|
|
22
|
-
msg
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def new
|
|
26
|
-
message = Message.new(@parent)
|
|
27
|
-
yield(message) if block_given?
|
|
28
|
-
message
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def start_at(start_at)
|
|
32
|
-
@start_at = start_at
|
|
33
|
-
self
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def end_at(end_at)
|
|
37
|
-
@end_at = end_at
|
|
38
|
-
self
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def folders(folders)
|
|
42
|
-
@folders = folders
|
|
43
|
-
@folder_ids = @folders.map(&:id)
|
|
44
|
-
self
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def folder_ids(folder_ids)
|
|
48
|
-
@folder_ids = folder_ids
|
|
49
|
-
self
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def where(query)
|
|
53
|
-
@query = query
|
|
54
|
-
self
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def ids
|
|
58
|
-
search_builder.ids
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def all
|
|
62
|
-
build_response
|
|
8
|
+
super(parent)
|
|
9
|
+
@child_class = Message
|
|
10
|
+
@builder_class = MessagesBuilder
|
|
11
|
+
@type = 'message'
|
|
12
|
+
@sort_by = 'dateDesc'
|
|
63
13
|
end
|
|
64
14
|
|
|
65
15
|
private
|
|
66
16
|
|
|
67
|
-
def search_response
|
|
68
|
-
rep = @parent.sacc.search(@parent.token, 'message', @offset, @limit, 'dateDesc', query, build_options)
|
|
69
|
-
@more = rep[:Body][:SearchResponse][:more]
|
|
70
|
-
rep
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def search_builder
|
|
74
|
-
MessagesBuilder.new(@parent, search_response)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def build_response
|
|
78
|
-
messages = search_builder.make
|
|
79
|
-
messages.each { |msg| msg.folder = find_folder(msg) } unless @folders.empty?
|
|
80
|
-
messages
|
|
81
|
-
end
|
|
82
|
-
|
|
83
17
|
def build_options
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def query
|
|
90
|
-
return @query unless @query.nil?
|
|
91
|
-
|
|
92
|
-
return nil if @folder_ids.empty?
|
|
93
|
-
|
|
94
|
-
@folder_ids.map { |id| %Q{inid:"#{id}"} }.join(' OR ')
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def find_folder(message)
|
|
98
|
-
@folders.find { |folder| folder.id == message.l }
|
|
18
|
+
options = super
|
|
19
|
+
options[:recip] = @recip
|
|
20
|
+
options
|
|
99
21
|
end
|
|
100
22
|
|
|
101
23
|
def reset_query_params
|
|
102
24
|
super
|
|
103
|
-
@
|
|
104
|
-
@end_at = nil
|
|
105
|
-
@query = nil
|
|
106
|
-
@folder_ids = []
|
|
107
|
-
@folders = []
|
|
25
|
+
@recip = 2
|
|
108
26
|
end
|
|
109
27
|
end
|
|
110
28
|
end
|
|
@@ -3,92 +3,39 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# class for account mountpoint
|
|
6
|
-
class MountPoint < Base::
|
|
6
|
+
class MountPoint < Base::FolderObject
|
|
7
|
+
include Zm::Model::AttributeChangeObserver
|
|
8
|
+
|
|
7
9
|
INSTANCE_VARIABLE_KEYS = %i[
|
|
8
10
|
owner rev reminder ms deletable l rid uuid url f broken
|
|
9
11
|
luuid ruuid activesyncdisabled absFolderPath view zid name id
|
|
10
12
|
webOfflineSyncDays color rgb
|
|
11
13
|
].freeze
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
attr_reader :owner, :rev, :reminder, :ms, :deletable, :rid, :uuid, :url, :f, :broken, :luuid, :ruuid, :activesyncdisabled, :absFolderPath, :view, :zid, :id, :webOfflineSyncDays
|
|
16
|
+
|
|
17
|
+
define_changed_attributes :name, :color, :rgb, :l
|
|
14
18
|
|
|
15
|
-
def
|
|
16
|
-
INSTANCE_VARIABLE_KEYS
|
|
19
|
+
def all_instance_variable_keys
|
|
20
|
+
INSTANCE_VARIABLE_KEYS
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
alias parent_id l
|
|
20
24
|
|
|
21
|
-
def initialize(parent, json = nil)
|
|
22
|
-
@parent = parent
|
|
23
|
-
@l = 1
|
|
24
|
-
init_from_json(json) if json.is_a?(Hash)
|
|
25
|
-
yield(self) if block_given?
|
|
26
|
-
end
|
|
27
|
-
|
|
28
25
|
def create!
|
|
29
|
-
rep = @parent.sacc.create_mountpoint(@parent.token,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def build_create_options
|
|
34
|
-
{
|
|
35
|
-
l: @l,
|
|
36
|
-
name: @name,
|
|
37
|
-
view: @view,
|
|
38
|
-
zid: @zid,
|
|
39
|
-
rid: @rid,
|
|
40
|
-
url: @url,
|
|
41
|
-
color: @color,
|
|
42
|
-
rgb: @rgb,
|
|
43
|
-
f: @f
|
|
44
|
-
}.delete_if { |_, v| v.nil? }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def modify!
|
|
48
|
-
update!(build_update_options)
|
|
26
|
+
rep = @parent.sacc.create_mountpoint(@parent.token, jsns_builder.to_jsns)
|
|
27
|
+
json = rep[:Body][:CreateMountpointResponse][:link].first
|
|
28
|
+
MountpointJsnsInitializer.update(self, json)
|
|
49
29
|
end
|
|
50
30
|
|
|
51
31
|
def update!(options)
|
|
52
|
-
|
|
32
|
+
# todo
|
|
53
33
|
end
|
|
54
34
|
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
f: @f,
|
|
58
|
-
name: @name,
|
|
59
|
-
l: @l,
|
|
60
|
-
color: @color,
|
|
61
|
-
rgb: @rgb
|
|
62
|
-
}.delete_if { |_, v| v.nil? }
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def rename!(new_name)
|
|
66
|
-
@parent.sacc.folder_action(@parent.token, 'rename', @id, name: new_name)
|
|
67
|
-
@name = new_name
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def move!(folder_id)
|
|
71
|
-
@parent.sacc.folder_action(@parent.token, 'move', @id, l: folder_id)
|
|
72
|
-
@l = folder_id
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def color!(new_color)
|
|
76
|
-
key = new_color.to_i.zero? ? :rgb : :color
|
|
77
|
-
options = {}
|
|
78
|
-
options[key] = new_color
|
|
79
|
-
@parent.sacc.folder_action(@parent.token, 'color', @id, options)
|
|
80
|
-
instance_variable_set("@#{key}", new_color)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def delete!
|
|
84
|
-
@parent.sacc.folder_action(@parent.token, :delete, @id)
|
|
85
|
-
end
|
|
35
|
+
private
|
|
86
36
|
|
|
87
|
-
def
|
|
88
|
-
|
|
89
|
-
var_name = "@#{key}"
|
|
90
|
-
instance_variable_set(var_name, json[key])
|
|
91
|
-
end
|
|
37
|
+
def jsns_builder
|
|
38
|
+
@jsns_builder ||= MountpointJsnsBuilder.new(self)
|
|
92
39
|
end
|
|
93
40
|
end
|
|
94
41
|
end
|