zm-ruby-client 2.2.6 → 2.2.7
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/VERSION +1 -1
- data/lib/zm/client/connector/rest_account.rb +49 -15
- data/lib/zm/client/connector/soap_base.rb +2 -4
- data/lib/zm/client/connector/soap_error.rb +22 -2
- data/lib/zm/client/contact/group_contact_jsns_builder.rb +0 -6
- data/lib/zm/client/document/document_jsns_initializer.rb +1 -1
- data/lib/zm/client/filter_rules/filter_rule.rb +9 -0
- data/lib/zm/client/filter_rules/filter_rules_builder.rb +4 -1
- data/lib/zm/client/filter_rules/filter_rules_collection.rb +11 -0
- data/lib/zm/client/message/message.rb +41 -6
- data/lib/zm/client/message/message_jsns_initializer.rb +2 -1
- data/lib/zm/client/message/messages_collection.rb +14 -0
- data/lib/zm/client/tag/account_object_tags_collection.rb +1 -1
- data/lib/zm/client/upload/upload.rb +4 -0
- data/lib/zm/modules/common/zimbra-attrs.csv +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc00d91e324f3525589fe4aff9db5d55036d3d52881cc4e03a4019d4bd9a3f7c
|
4
|
+
data.tar.gz: 4429603c4c08dfa045d06fab04e3f1f73d90355b35ced2ebd5228888e26ef5a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac9161207764343feaaa8f90d64a4ea9d179eaedecfcfdbcdebf2b7e906a8a1f3122d269321dc4b96ee441087a33957fa452f01a2c0cb3a089da887e565e7ba0
|
7
|
+
data.tar.gz: 00e61ace101d6fd24ec2c57ff9a2cf5e79bc67d612f711199517dade6c9aae779c25ca628252e1cb5e2cb4bd2b5019f1b7384914292ab3dd2fbb0b124d8e2738
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.
|
1
|
+
2.2.7
|
@@ -28,36 +28,38 @@ module Zm
|
|
28
28
|
@cookies = cookies
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def read(download_url)
|
32
32
|
url, path = split_url(download_url)
|
33
33
|
|
34
|
-
conn =
|
35
|
-
faraday.response :logger, nil, { headers: true, bodies: true, errors: true } if @verbose
|
36
|
-
end
|
34
|
+
conn = conn_get(url)
|
37
35
|
|
38
|
-
|
36
|
+
data = +''
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
f.write chunk
|
44
|
-
end
|
38
|
+
response = conn.get(path) do |request|
|
39
|
+
request.options.on_data = Proc.new do |chunk, _, _|
|
40
|
+
data.concat(chunk)
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
44
|
if response.status >= 400
|
49
|
-
File.unlink(dest_file_path) if File.exist?(dest_file_path)
|
50
45
|
raise RestError, "Download failure: #{response.body} (status=#{response.status})"
|
51
46
|
end
|
47
|
+
|
48
|
+
data
|
49
|
+
end
|
50
|
+
|
51
|
+
def download(download_url, dest_file_path)
|
52
|
+
url, path = split_url(download_url)
|
53
|
+
|
54
|
+
conn = conn_get(url)
|
55
|
+
|
56
|
+
write_downloaded_file(dest_file_path, conn, path)
|
52
57
|
end
|
53
58
|
|
54
59
|
def upload(upload_url, src_file_path)
|
55
60
|
url, path = split_url(upload_url)
|
56
61
|
|
57
|
-
conn =
|
58
|
-
faraday.request :multipart
|
59
|
-
faraday.response :logger, nil, { headers: true, bodies: true, errors: true } if @verbose
|
60
|
-
end
|
62
|
+
conn = conn_multipart(url)
|
61
63
|
|
62
64
|
payload = { file: Faraday::Multipart::FilePart.new(src_file_path, nil) }
|
63
65
|
response = conn.post(path, payload)
|
@@ -76,6 +78,38 @@ module Zm
|
|
76
78
|
|
77
79
|
private
|
78
80
|
|
81
|
+
def conn_get(url)
|
82
|
+
Faraday.new(**http_options(url)) do |faraday|
|
83
|
+
faraday.response :logger, nil, { headers: true, bodies: true, errors: true } if @verbose
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def conn_multipart(url)
|
88
|
+
Faraday.new(**http_options(url)) do |faraday|
|
89
|
+
faraday.request :multipart
|
90
|
+
faraday.response :logger, nil, { headers: true, bodies: true, errors: true } if @verbose
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def write_downloaded_file(dest_file_path, conn, path)
|
95
|
+
response = nil
|
96
|
+
|
97
|
+
File.open(dest_file_path, 'wb') do |f|
|
98
|
+
response = conn.get(path) do |request|
|
99
|
+
request.options.on_data = Proc.new do |chunk, _, _|
|
100
|
+
f.write chunk
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if response.status >= 400
|
106
|
+
File.unlink(dest_file_path) if File.exist?(dest_file_path)
|
107
|
+
raise RestError, "Download failure: #{response.body} (status=#{response.status})"
|
108
|
+
end
|
109
|
+
|
110
|
+
response
|
111
|
+
end
|
112
|
+
|
79
113
|
def split_url(url)
|
80
114
|
uri = URI(url)
|
81
115
|
url = "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
@@ -72,13 +72,11 @@ module Zm
|
|
72
72
|
def do_request(body, error_handler = SoapError)
|
73
73
|
response = http_client.post(@soap_path, body)
|
74
74
|
|
75
|
-
soapbody = JSON.parse(response.body, symbolize_names: true)
|
76
|
-
|
77
75
|
if response.status >= 400
|
78
|
-
raise(error_handler,
|
76
|
+
raise(error_handler, response.body)
|
79
77
|
end
|
80
78
|
|
81
|
-
|
79
|
+
JSON.parse(response.body, symbolize_names: true)
|
82
80
|
end
|
83
81
|
|
84
82
|
def envelope(soap_element)
|
@@ -9,10 +9,30 @@ module Zm
|
|
9
9
|
attr_reader :reason, :code
|
10
10
|
|
11
11
|
def initialize(soapbody)
|
12
|
-
|
13
|
-
|
12
|
+
if soapbody.start_with?('{')
|
13
|
+
init_from_json(soapbody)
|
14
|
+
elsif soapbody.start_with?('<')
|
15
|
+
init_from_xml(soapbody)
|
16
|
+
end
|
17
|
+
|
14
18
|
super "[#{@code}] [#{@reason}]"
|
15
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def init_from_json(soapbody)
|
24
|
+
json = JSON.parse(soapbody, symbolize_names: true)
|
25
|
+
@reason = json[:Body][:Fault][:Reason][:Text]
|
26
|
+
@code = json[:Body][:Fault][:Detail][:Error][:Code]
|
27
|
+
end
|
28
|
+
|
29
|
+
def init_from_xml(soapbody)
|
30
|
+
code_match = soapbody.match(%r{<Code>(.*?)</Code>})
|
31
|
+
@code = code_match[1]
|
32
|
+
|
33
|
+
text_match = soapbody.match(%r{<soap:Reason>.*?<soap:Text>(.*?)</soap:Text>}m)
|
34
|
+
@reason = text_match[1]
|
35
|
+
end
|
16
36
|
end
|
17
37
|
|
18
38
|
class AuthError < SoapError
|
@@ -47,12 +47,6 @@ module Zm
|
|
47
47
|
|
48
48
|
alias to_create to_jsns
|
49
49
|
|
50
|
-
# def members_node
|
51
|
-
# @item.members.all.reject(&:current?).map do |m|
|
52
|
-
# { type: m.type, value: m.value, op: m.op }
|
53
|
-
# end
|
54
|
-
# end
|
55
|
-
|
56
50
|
def instance_variables_array
|
57
51
|
[[:nickname, @item.name], [:fullName, @item.name], [:fileAs, "8:#{@item.name}"], %i[type group]]
|
58
52
|
end
|
@@ -5,6 +5,15 @@ module Zm
|
|
5
5
|
# class account filter rule
|
6
6
|
class FilterRule < Base::Object
|
7
7
|
attr_accessor :name, :active, :filterTests, :filterActions
|
8
|
+
|
9
|
+
def to_h
|
10
|
+
{
|
11
|
+
name: name,
|
12
|
+
active: active,
|
13
|
+
filterTests: filterTests,
|
14
|
+
filterActions: filterActions
|
15
|
+
}
|
16
|
+
end
|
8
17
|
end
|
9
18
|
end
|
10
19
|
end
|
@@ -12,7 +12,10 @@ module Zm
|
|
12
12
|
def make
|
13
13
|
return [] if json_items.nil?
|
14
14
|
|
15
|
-
json_items.first[:filterRule]
|
15
|
+
rules = json_items.first[:filterRule]
|
16
|
+
return [] if rules.nil?
|
17
|
+
|
18
|
+
rules.map do |entry|
|
16
19
|
FilterRuleJsnsInitializer.create(@parent, entry)
|
17
20
|
end
|
18
21
|
end
|
@@ -10,6 +10,17 @@ module Zm
|
|
10
10
|
super(parent)
|
11
11
|
end
|
12
12
|
|
13
|
+
def save!
|
14
|
+
return false unless defined? @all
|
15
|
+
|
16
|
+
soap_request = SoapElement.mail(SoapMailConstants::MODIFY_FILTER_RULES_REQUEST)
|
17
|
+
node_rules = SoapElement.create(:filterRules).add_attribute(:filterRule, @all.map(&:to_h))
|
18
|
+
soap_request.add_node(node_rules)
|
19
|
+
@parent.sacc.invoke(soap_request)
|
20
|
+
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
13
24
|
private
|
14
25
|
|
15
26
|
def make_query
|
@@ -7,18 +7,33 @@ module Zm
|
|
7
7
|
include BelongsToFolder
|
8
8
|
include BelongsToTag
|
9
9
|
|
10
|
-
attr_accessor :id, :d, :l, :f, :su, :fr, :autoSendTime, :mid, :idnt, :tn, :subject
|
11
|
-
|
10
|
+
attr_accessor :id, :d, :l, :f, :su, :fr, :autoSendTime, :mid, :idnt, :tn, :subject, :s
|
11
|
+
|
12
|
+
alias size s
|
12
13
|
|
13
14
|
def initialize(parent)
|
14
15
|
@parent = parent
|
15
16
|
@subject = ''
|
16
17
|
|
18
|
+
yield(self) if block_given?
|
19
|
+
end
|
20
|
+
|
21
|
+
def recipients
|
22
|
+
return @recipients if defined? @recipients
|
23
|
+
|
17
24
|
@recipients = Recipients.new
|
18
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
def attachments
|
28
|
+
return @attachments if defined? @attachments
|
29
|
+
|
19
30
|
@attachments = AttachmentsCollection.new
|
31
|
+
end
|
20
32
|
|
21
|
-
|
33
|
+
def body
|
34
|
+
return @body if defined? @body
|
35
|
+
|
36
|
+
@body = Body.new
|
22
37
|
end
|
23
38
|
|
24
39
|
def download(dest_file_path, fmt = 'eml')
|
@@ -26,6 +41,11 @@ module Zm
|
|
26
41
|
uploader.download_file( Zm::Client::FolderDefault::ROOT[:path], fmt, [Zm::Client::FolderView::MESSAGE], [@id], dest_file_path)
|
27
42
|
end
|
28
43
|
|
44
|
+
def read(fmt = 'eml')
|
45
|
+
uploader = Upload.new(@parent, RestAccountConnector.new)
|
46
|
+
uploader.read_file( Zm::Client::FolderDefault::ROOT[:path], fmt, [Zm::Client::FolderView::MESSAGE], [@id])
|
47
|
+
end
|
48
|
+
|
29
49
|
def date
|
30
50
|
@date ||= Time.at(d.to_i / 1000)
|
31
51
|
end
|
@@ -42,8 +62,23 @@ module Zm
|
|
42
62
|
raise NotImplementedError
|
43
63
|
end
|
44
64
|
|
45
|
-
def update!(
|
46
|
-
|
65
|
+
def update!(l: nil, rgb: nil, color: nil, f: nil, tn: nil)
|
66
|
+
attrs = {
|
67
|
+
op: :update,
|
68
|
+
id: @id,
|
69
|
+
l: l,
|
70
|
+
rgb: rgb,
|
71
|
+
color: color,
|
72
|
+
f: f,
|
73
|
+
tn: tn
|
74
|
+
}
|
75
|
+
|
76
|
+
attrs.delete_if { |_, v| v.nil? }
|
77
|
+
|
78
|
+
soap_request = SoapElement.mail(SoapMailConstants::MSG_ACTION_REQUEST)
|
79
|
+
node_action = SoapElement.create(SoapConstants::ACTION).add_attributes(attrs)
|
80
|
+
soap_request.add_node(node_action)
|
81
|
+
@parent.sacc.invoke(soap_request)
|
47
82
|
end
|
48
83
|
|
49
84
|
def rename!(*args)
|
@@ -23,6 +23,20 @@ module Zm
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def delete_all(ids)
|
27
|
+
attrs = {
|
28
|
+
op: :delete,
|
29
|
+
id: ids.join(',')
|
30
|
+
}
|
31
|
+
|
32
|
+
attrs.delete_if { |_, v| v.nil? }
|
33
|
+
|
34
|
+
soap_request = SoapElement.mail(SoapMailConstants::MSG_ACTION_REQUEST)
|
35
|
+
node_action = SoapElement.create(SoapConstants::ACTION).add_attributes(attrs)
|
36
|
+
soap_request.add_node(node_action)
|
37
|
+
@parent.sacc.invoke(soap_request)
|
38
|
+
end
|
39
|
+
|
26
40
|
private
|
27
41
|
|
28
42
|
def build_options
|
@@ -26,6 +26,10 @@ module Zm
|
|
26
26
|
@rac.download(download_file_url(folder_path, fmt, types, ids), dest_file_path)
|
27
27
|
end
|
28
28
|
|
29
|
+
def read_file(folder_path, fmt, types, ids)
|
30
|
+
@rac.read(download_file_url(folder_path, fmt, types, ids))
|
31
|
+
end
|
32
|
+
|
29
33
|
def download_folder(id, fmt, dest_file_path)
|
30
34
|
@rac.download(download_folder_url(id, fmt), dest_file_path)
|
31
35
|
end
|
@@ -734,4 +734,5 @@ zimbraRecoveryAccountCodeValidity,"account,cos,calendarResource",,,single,,,cstr
|
|
734
734
|
zimbraResetPasswordRecoveryCodeExpiry,"account,cos,calendarResource",,,single,,,cstring,,,,
|
735
735
|
zimbraShowClientTOS,"account,domain,cos,calendarResource",,,single,,,cstring,,,,
|
736
736
|
zimbraDistributionListSendShareMessageToNewMembers,distributionList,,,single,,,boolean,,,,
|
737
|
-
zimbraServiceEnabled,,,server,multi,,,cstring,,,,
|
737
|
+
zimbraServiceEnabled,,,server,multi,,,cstring,,,,
|
738
|
+
zimbraVirtualHostname,domain,,,single,,,cstring,,,,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zm-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxime Désécot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -341,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
341
341
|
- !ruby/object:Gem::Version
|
342
342
|
version: 1.8.11
|
343
343
|
requirements: []
|
344
|
-
rubygems_version: 3.
|
344
|
+
rubygems_version: 3.5.22
|
345
345
|
signing_key:
|
346
346
|
specification_version: 4
|
347
347
|
summary: zm-ruby-client
|