zm-ruby-client 0.17.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -6
- data/lib/zm/client/connector/soap_account.rb +13 -57
- data/lib/zm/client/connector/soap_admin.rb +55 -36
- data/lib/zm/client/connector/soap_base.rb +3 -11
- data/lib/zm/client/cos/cos.rb +3 -2
- data/lib/zm/client/identity/identity.rb +12 -14
- data/lib/zm/client/version.rb +2 -2
- data/zm-ruby-client.gemspec +14 -10
- metadata +8 -37
- data/lib/zm/client/connector/soap_xml_builder.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4b4dd19cb4e0dd0107505e94a9d5baae36a993393c8d4c3f4dd6149fbe259ed
|
4
|
+
data.tar.gz: daaec8fa6d6c48ef87c6431ce65981737b0e23a1f3879742cd1bb0cffec51445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc487248c2708e6dde5604da87220f5635d680b7c1d93f4a8a07dbc1780f72a75b0bcdcbb0335c5b0a30fab450c58ecb6ebdf3ce0ca0a68ff0f2bf1870929b1f
|
7
|
+
data.tar.gz: 9694b2433f9d9ae61eb0e67ace5a9db23fef736feb17276cb04f8aa91c427705c18844b93afc6e5ee3f704cc5c02f4200f522be2508a9b0e3df73d1bc66ccf30
|
data/Gemfile
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
ruby '
|
3
|
+
ruby '>= 2.6'
|
4
4
|
|
5
|
-
gem 'addressable', '~> 2.
|
6
|
-
gem 'curb', '~> 0
|
7
|
-
gem '
|
8
|
-
gem 'gyoku', '~>1.3.1'
|
9
|
-
gem 'version_sorter'
|
5
|
+
gem 'addressable', '~> 2.8'
|
6
|
+
gem 'curb', '~> 1.0'
|
7
|
+
gem 'version_sorter', '~>2.3'
|
@@ -2,21 +2,15 @@
|
|
2
2
|
|
3
3
|
require_relative 'soap_base'
|
4
4
|
require_relative 'soap_error'
|
5
|
-
require 'gyoku'
|
6
|
-
|
7
|
-
# include OpenSSL
|
8
|
-
# include Digest
|
9
5
|
|
10
6
|
module Zm
|
11
7
|
module Client
|
12
8
|
class SoapAccountConnector < SoapBaseConnector
|
13
|
-
|
14
|
-
# SOAP_PATH = '/service/soap/'
|
15
9
|
MAILSPACE = 'urn:zimbraMail'
|
16
10
|
ACCOUNTSPACE = 'urn:zimbraAccount'
|
17
|
-
A_NODE_PROC =
|
18
|
-
A_NODE_PROC_NAME =
|
19
|
-
A_NODE_PROC_ARROW_NAME =
|
11
|
+
A_NODE_PROC = ->(n) { { n: n.first, _content: n.last } }
|
12
|
+
A_NODE_PROC_NAME = ->(n) { { name: n.first, _content: n.last } }
|
13
|
+
A_NODE_PROC_ARROW_NAME = ->(n) { { :@name => n.first, content!: n.last } }
|
20
14
|
|
21
15
|
def initialize(scheme, host, port)
|
22
16
|
super(scheme, host, port, '/service/soap/')
|
@@ -322,26 +316,20 @@ module Zm
|
|
322
316
|
curl_request(body)
|
323
317
|
end
|
324
318
|
|
325
|
-
def create_identity(token, name, attrs =
|
319
|
+
def create_identity(token, name, attrs = {})
|
326
320
|
soap_name = :CreateIdentityRequest
|
327
|
-
req = { identity: {
|
328
|
-
body =
|
329
|
-
body[:
|
330
|
-
|
331
|
-
# puts body_xml
|
332
|
-
# todo ne fonctionne pas en JS !
|
333
|
-
curl_xml(body_xml)
|
321
|
+
req = { identity: { name: name, _attrs: attrs } }
|
322
|
+
body = init_hash_request(token, soap_name, ACCOUNTSPACE)
|
323
|
+
body[:Body][soap_name].merge!(req)
|
324
|
+
curl_request(body)
|
334
325
|
end
|
335
326
|
|
336
|
-
def modify_identity(token, id, attrs =
|
327
|
+
def modify_identity(token, id, attrs = {})
|
337
328
|
soap_name = :ModifyIdentityRequest
|
338
|
-
req = { identity: {
|
339
|
-
body =
|
340
|
-
body[:
|
341
|
-
|
342
|
-
# puts body_xml
|
343
|
-
# todo ne fonctionne pas en JS !
|
344
|
-
curl_xml(body_xml)
|
329
|
+
req = { identity: { id: id, _attrs: attrs } }
|
330
|
+
body = init_hash_request(token, soap_name, ACCOUNTSPACE)
|
331
|
+
body[:Body][soap_name].merge!(req)
|
332
|
+
curl_request(body)
|
345
333
|
end
|
346
334
|
|
347
335
|
def delete_identity(token, id)
|
@@ -362,18 +350,6 @@ module Zm
|
|
362
350
|
curl_request(body)
|
363
351
|
end
|
364
352
|
|
365
|
-
def modify_prefs(token, prefs)
|
366
|
-
soap_name = :ModifyPrefsRequest
|
367
|
-
req = { pref: prefs.map { |pref, value| { name: pref, _content: value } } }
|
368
|
-
body = init_hash_request(token, soap_name, ACCOUNTSPACE)
|
369
|
-
body[:Body][soap_name].merge!(req) if req.any?
|
370
|
-
#puts body
|
371
|
-
#curl_request(body)
|
372
|
-
#puts SoapXmlBuilder.new(body).to_xml
|
373
|
-
# todo ne fonctionne pas en JS !
|
374
|
-
curl_xml(SoapXmlBuilder.new(body).to_xml)
|
375
|
-
end
|
376
|
-
|
377
353
|
def get_filter_rules(token)
|
378
354
|
soap_name = :GetFilterRulesRequest
|
379
355
|
body = init_hash_request(token, soap_name)
|
@@ -481,26 +457,6 @@ module Zm
|
|
481
457
|
}
|
482
458
|
}.merge(hash_header(token))
|
483
459
|
end
|
484
|
-
|
485
|
-
def init_hash_arrow_request(token, soap_name, namespace = MAILSPACE)
|
486
|
-
{ Envelope: {
|
487
|
-
:@xmlns => 'http://schemas.xmlsoap.org/soap/envelope/',
|
488
|
-
'@xmlns:urn' => 'urn:zimbra',
|
489
|
-
Header: {
|
490
|
-
context: {
|
491
|
-
authToken: token,
|
492
|
-
:@xmlns => BASESPACE,
|
493
|
-
format: {
|
494
|
-
:@type => 'js'
|
495
|
-
}
|
496
|
-
}
|
497
|
-
},
|
498
|
-
Body: {
|
499
|
-
soap_name => { :@xmlns => namespace }
|
500
|
-
}
|
501
|
-
}
|
502
|
-
}
|
503
|
-
end
|
504
460
|
end
|
505
461
|
end
|
506
462
|
end
|
@@ -2,15 +2,12 @@
|
|
2
2
|
|
3
3
|
require_relative 'soap_base'
|
4
4
|
require_relative 'soap_error'
|
5
|
-
require_relative 'soap_xml_builder'
|
6
5
|
|
7
6
|
module Zm
|
8
7
|
module Client
|
9
8
|
class SoapAdminConnector < SoapBaseConnector
|
10
|
-
|
11
|
-
# SOAP_PATH = '/service/admin/soap/'
|
12
9
|
ADMINSPACE = 'urn:zimbraAdmin'
|
13
|
-
A_NODE_PROC =
|
10
|
+
A_NODE_PROC = ->(n) { { n: n.first, _content: n.last } }
|
14
11
|
|
15
12
|
attr_accessor :token
|
16
13
|
|
@@ -45,7 +42,7 @@ module Zm
|
|
45
42
|
def count_object(type)
|
46
43
|
soap_name = :CountObjectsRequest
|
47
44
|
body = init_hash_request(soap_name)
|
48
|
-
req = { type: type}
|
45
|
+
req = { type: type }
|
49
46
|
body[:Body][soap_name].merge!(req)
|
50
47
|
curl_request(body)
|
51
48
|
end
|
@@ -88,7 +85,7 @@ module Zm
|
|
88
85
|
curl_request(body)
|
89
86
|
end
|
90
87
|
|
91
|
-
def create_data_source(name, account_id, type, attrs = {
|
88
|
+
def create_data_source(name, account_id, type, attrs = {})
|
92
89
|
req = {
|
93
90
|
id: account_id,
|
94
91
|
dataSource: {
|
@@ -139,22 +136,28 @@ module Zm
|
|
139
136
|
curl_request(body)
|
140
137
|
end
|
141
138
|
|
142
|
-
def create_cos(name, attrs =
|
143
|
-
req = { name: name }
|
139
|
+
def create_cos(name, attrs = [])
|
140
|
+
req = { name: { _content: name } }
|
141
|
+
req[:a] = attrs.map do |i|
|
142
|
+
if i.last.is_a?(Array)
|
143
|
+
i.last.map do |j|
|
144
|
+
[i.first, j]
|
145
|
+
end
|
146
|
+
else
|
147
|
+
[i]
|
148
|
+
end
|
149
|
+
end.flatten(1).map(&A_NODE_PROC)
|
150
|
+
|
144
151
|
body = init_hash_request(:CreateCosRequest)
|
145
152
|
body[:Body][:CreateCosRequest].merge!(req)
|
146
|
-
|
147
|
-
# a: attrs.to_a.map { |n| { n: n.first, _content: n.last } }
|
148
|
-
# puts SoapXmlBuilder.new(body).to_xml
|
149
|
-
# todo ne fonctionne pas !
|
150
|
-
curl_xml(SoapXmlBuilder.new(body).to_xml)
|
153
|
+
curl_request(body)
|
151
154
|
end
|
152
155
|
|
153
|
-
def modify_cos(id,
|
156
|
+
def modify_cos(id, _attrs = nil)
|
154
157
|
# req = { _jsns: ADMINSPACE, id: id, a: attrs.to_a.map{ |n| { n: n.first, _content: n.last } } }
|
155
158
|
req = { _jsns: ADMINSPACE, id: id }
|
156
159
|
body = { Body: { ModifyCosRequest: req } }.merge(hash_header(@token))
|
157
|
-
#
|
160
|
+
# TODO: ne fonctionne pas !
|
158
161
|
# peut-être seul la version xml fonctionne. Il faudrait créer une fonction qui converti le json en xml
|
159
162
|
curl_request(body)
|
160
163
|
end
|
@@ -162,7 +165,15 @@ module Zm
|
|
162
165
|
def create_account(name, password = nil, attrs = [])
|
163
166
|
soap_name = :CreateAccountRequest
|
164
167
|
req = { name: name, password: password }.reject { |_, v| v.nil? }
|
165
|
-
req[:a] = attrs.map
|
168
|
+
req[:a] = attrs.map do |i|
|
169
|
+
if i.last.is_a?(Array)
|
170
|
+
i.last.map do |j|
|
171
|
+
[i.first, j]
|
172
|
+
end
|
173
|
+
else
|
174
|
+
[i]
|
175
|
+
end
|
176
|
+
end.flatten(1).map(&A_NODE_PROC)
|
166
177
|
# req[:a] = attrs.map{|i|i.last.is_a?(Array) ? i.last.map{|j|[i.first, j]} : [i]}.flatten(1).map { |n| { n: n.first, _content: n.last } }
|
167
178
|
body = init_hash_request(soap_name)
|
168
179
|
body[:Body][soap_name].merge!(req)
|
@@ -173,7 +184,15 @@ module Zm
|
|
173
184
|
soap_name = :CreateCalendarResourceRequest
|
174
185
|
req = { name: name, password: password }
|
175
186
|
req.reject! { |_, v| v.nil? }
|
176
|
-
req[:a] = attrs.map
|
187
|
+
req[:a] = attrs.map do |i|
|
188
|
+
if i.last.is_a?(Array)
|
189
|
+
i.last.map do |j|
|
190
|
+
[i.first, j]
|
191
|
+
end
|
192
|
+
else
|
193
|
+
[i]
|
194
|
+
end
|
195
|
+
end.flatten(1).map(&A_NODE_PROC)
|
177
196
|
body = init_hash_request(soap_name)
|
178
197
|
body[:Body][soap_name].merge!(req)
|
179
198
|
curl_request(body)
|
@@ -182,7 +201,15 @@ module Zm
|
|
182
201
|
def create_distribution_list(name, attrs = [])
|
183
202
|
soap_name = :CreateDistributionListRequest
|
184
203
|
req = { name: name }
|
185
|
-
req[:a] = attrs.map
|
204
|
+
req[:a] = attrs.map do |i|
|
205
|
+
if i.last.is_a?(Array)
|
206
|
+
i.last.map do |j|
|
207
|
+
[i.first, j]
|
208
|
+
end
|
209
|
+
else
|
210
|
+
[i]
|
211
|
+
end
|
212
|
+
end.flatten(1).map(&A_NODE_PROC)
|
186
213
|
body = init_hash_request(soap_name)
|
187
214
|
body[:Body][soap_name].merge!(req)
|
188
215
|
curl_request(body)
|
@@ -210,14 +237,6 @@ module Zm
|
|
210
237
|
curl_request(body)
|
211
238
|
end
|
212
239
|
|
213
|
-
def set_password(id, new_password)
|
214
|
-
soap_name = :SetPasswordRequest
|
215
|
-
req = { id: id, newPassword: new_password }
|
216
|
-
body = init_hash_request(soap_name)
|
217
|
-
body[:Body][soap_name].merge!(req)
|
218
|
-
curl_request(body)
|
219
|
-
end
|
220
|
-
|
221
240
|
def add_account_alias(id, email)
|
222
241
|
generic_alias(:AddAccountAliasRequest, id, email)
|
223
242
|
end
|
@@ -226,7 +245,6 @@ module Zm
|
|
226
245
|
generic_alias(:RemoveAccountAliasRequest, id, email)
|
227
246
|
end
|
228
247
|
|
229
|
-
|
230
248
|
def rename_account(id, email)
|
231
249
|
generic_rename(:RenameAccountRequest, id, email)
|
232
250
|
end
|
@@ -240,7 +258,7 @@ module Zm
|
|
240
258
|
end
|
241
259
|
|
242
260
|
def generic_members(soap_name, id, emails)
|
243
|
-
req = { id: id, dlm: emails.map { |email| {_content: email} } }
|
261
|
+
req = { id: id, dlm: emails.map { |email| { _content: email } } }
|
244
262
|
body = init_hash_request(soap_name)
|
245
263
|
body[:Body][soap_name].merge!(req)
|
246
264
|
curl_request(body)
|
@@ -371,8 +389,8 @@ module Zm
|
|
371
389
|
curl_request(body)
|
372
390
|
end
|
373
391
|
|
374
|
-
def search_directory(query = nil, maxResults = nil, limit = nil, offset = nil, domain = nil, applyCos = nil,
|
375
|
-
|
392
|
+
def search_directory(query = nil, maxResults = nil, limit = nil, offset = nil, domain = nil, applyCos = nil,
|
393
|
+
applyConfig = nil, sortBy = nil, types = nil, sortAscending = nil, countOnly = nil, attrs = nil)
|
376
394
|
# Désactivé car moins performant !
|
377
395
|
# req = Hash[method(__method__).parameters.map{ |p|[p.last, (eval p.last.to_s)] }].select!{ |k,v|!v.nil? }
|
378
396
|
|
@@ -400,7 +418,8 @@ module Zm
|
|
400
418
|
curl_request(body)
|
401
419
|
end
|
402
420
|
|
403
|
-
def get_quota_usage(domain = nil, allServers = nil, limit = nil, offset = nil, sortBy = nil, sortAscending = nil,
|
421
|
+
def get_quota_usage(domain = nil, allServers = nil, limit = nil, offset = nil, sortBy = nil, sortAscending = nil,
|
422
|
+
refresh = nil, target_server_id = nil)
|
404
423
|
soap_name = :GetQuotaUsageRequest
|
405
424
|
req = {
|
406
425
|
domain: domain,
|
@@ -421,9 +440,9 @@ module Zm
|
|
421
440
|
def get_mailbox(id)
|
422
441
|
soap_name = :GetMailboxRequest
|
423
442
|
req = {
|
424
|
-
|
425
|
-
|
426
|
-
|
443
|
+
mbox: {
|
444
|
+
id: id
|
445
|
+
}
|
427
446
|
}
|
428
447
|
body = init_hash_request(soap_name)
|
429
448
|
body[:Body][soap_name].merge!(req)
|
@@ -504,7 +523,8 @@ module Zm
|
|
504
523
|
soap_name = :MailQueueActionRequest
|
505
524
|
value = [value] unless value.is_a?(Array)
|
506
525
|
body = init_hash_request(soap_name)
|
507
|
-
req = { server: { name: server_name,
|
526
|
+
req = { server: { name: server_name,
|
527
|
+
queue: { name: queue_name, action: { op: op, by: by, _content: value.join(',') } } } }
|
508
528
|
body[:Body][soap_name].merge!(req)
|
509
529
|
curl_request(body)
|
510
530
|
end
|
@@ -515,7 +535,6 @@ module Zm
|
|
515
535
|
req = { query: {} }
|
516
536
|
body[:Body][soap_name].merge!(req)
|
517
537
|
curl_request(body)
|
518
|
-
# curl_xml(SoapXmlBuilder.new(body).to_xml)
|
519
538
|
end
|
520
539
|
|
521
540
|
def set_password(id, new_password)
|
@@ -54,18 +54,10 @@ module Zm
|
|
54
54
|
soapbody
|
55
55
|
end
|
56
56
|
|
57
|
-
def curl_xml(xml, error_handler = SoapError)
|
58
|
-
logger.debug xml
|
59
|
-
@curl.http_post(xml)
|
60
|
-
|
61
|
-
soapbody = JSON.parse(@curl.body_str, symbolize_names: true)
|
62
|
-
raise(error_handler, soapbody) if @curl.status.to_i >= 400
|
63
|
-
|
64
|
-
soapbody
|
65
|
-
end
|
66
|
-
|
67
57
|
def hash_header(token, target_server = nil)
|
68
|
-
context = { authToken: token, userAgent: { name: :zmsoap }, targetServer: target_server }.delete_if
|
58
|
+
context = { authToken: token, userAgent: { name: :zmsoap }, targetServer: target_server }.delete_if do |_, v|
|
59
|
+
v.nil?
|
60
|
+
end
|
69
61
|
{ Header: { context: context, _jsns: BASESPACE } }
|
70
62
|
end
|
71
63
|
end
|
data/lib/zm/client/cos/cos.rb
CHANGED
@@ -39,7 +39,8 @@ module Zm
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def create!
|
42
|
-
sac.create_cos(name, instance_variables_array(attrs_write))
|
42
|
+
rep = sac.create_cos(name, instance_variables_array(attrs_write))
|
43
|
+
@id = rep[:Body][:CreateCosResponse][:cos].first[:id]
|
43
44
|
end
|
44
45
|
|
45
46
|
def servers
|
@@ -47,7 +48,7 @@ module Zm
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def accounts
|
50
|
-
#
|
51
|
+
# TODO: sélectionner tous les comptes qui ont zimbraCOSID=self.id
|
51
52
|
end
|
52
53
|
|
53
54
|
private
|
@@ -4,18 +4,17 @@ module Zm
|
|
4
4
|
module Client
|
5
5
|
# class account identity
|
6
6
|
class Identity < Base::AccountObject
|
7
|
-
|
8
7
|
INSTANCE_VARIABLE_KEYS = %i[id name zimbraPrefIdentityName zimbraPrefFromDisplay zimbraPrefFromAddress
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
zimbraPrefFromAddressType zimbraPrefReplyToEnabled zimbraPrefReplyToDisplay zimbraPrefReplyToAddress
|
9
|
+
zimbraPrefDefaultSignatureId zimbraPrefForwardReplySignatureId zimbraPrefWhenSentToEnabled
|
10
|
+
zimbraPrefWhenInFoldersEnabled zimbraPrefWhenSentToAddresses].freeze
|
12
11
|
|
13
12
|
ATTRS_WRITE = %i[zimbraPrefIdentityName zimbraPrefFromDisplay zimbraPrefFromAddress
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
zimbraPrefFromAddressType zimbraPrefReplyToEnabled zimbraPrefReplyToDisplay zimbraPrefReplyToAddress
|
14
|
+
zimbraPrefDefaultSignatureId zimbraPrefForwardReplySignatureId zimbraPrefWhenSentToEnabled
|
15
|
+
zimbraPrefWhenInFoldersEnabled zimbraPrefWhenSentToAddresses].freeze
|
17
16
|
|
18
|
-
attr_accessor
|
17
|
+
attr_accessor(*INSTANCE_VARIABLE_KEYS)
|
19
18
|
|
20
19
|
def all_instance_variable_keys
|
21
20
|
INSTANCE_VARIABLE_KEYS
|
@@ -33,7 +32,7 @@ module Zm
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def create!
|
36
|
-
rep = @parent.sacc.create_identity(@parent.token, name, instance_variables_array(ATTRS_WRITE))
|
35
|
+
rep = @parent.sacc.create_identity(@parent.token, name, Hash[instance_variables_array(ATTRS_WRITE)])
|
37
36
|
init_from_json(rep[:Body][:CreateIdentityResponse][:identity].first)
|
38
37
|
end
|
39
38
|
|
@@ -44,9 +43,9 @@ module Zm
|
|
44
43
|
arrow_attr_sym = "@#{k}".to_sym
|
45
44
|
|
46
45
|
if v.respond_to?(:empty?) && v.empty?
|
47
|
-
|
46
|
+
remove_instance_variable(arrow_attr_sym) if instance_variable_get(arrow_attr_sym)
|
48
47
|
else
|
49
|
-
|
48
|
+
instance_variable_set(arrow_attr_sym, v)
|
50
49
|
end
|
51
50
|
end
|
52
51
|
end
|
@@ -60,12 +59,11 @@ module Zm
|
|
60
59
|
super
|
61
60
|
end
|
62
61
|
|
63
|
-
def rename!(new_name)
|
64
|
-
end
|
62
|
+
def rename!(new_name); end
|
65
63
|
|
66
64
|
def clone
|
67
65
|
new_identity = super do |obj|
|
68
|
-
[
|
66
|
+
%i[@zimbraPrefDefaultSignatureId @zimbraPrefForwardReplySignatureId].each do |arrow_key|
|
69
67
|
obj.remove_instance_variable(arrow_key) if obj.instance_variable_get(arrow_key)
|
70
68
|
end
|
71
69
|
end
|
data/lib/zm/client/version.rb
CHANGED
data/zm-ruby-client.gemspec
CHANGED
@@ -1,25 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
4
5
|
|
5
6
|
require './lib/zm-ruby-client'
|
6
7
|
|
7
8
|
Gem::Specification.new do |s|
|
9
|
+
s.platform = Gem::Platform::RUBY
|
8
10
|
s.name = 'zm-ruby-client'
|
9
|
-
s.version = Zm::Client
|
11
|
+
s.version = Zm::Client.gem_version.to_s
|
10
12
|
s.date = `date '+%Y-%m-%d'`
|
11
13
|
s.summary = 'zm-ruby-client'
|
12
14
|
s.description = 'Zimbra Soap Librairy using SOAP Json interface'
|
15
|
+
|
16
|
+
s.required_ruby_version = '>= 2.6'
|
17
|
+
s.license = 'GPL-3.0'
|
18
|
+
|
13
19
|
s.authors = ['Maxime Désécot']
|
14
20
|
s.email = 'maxime.desecot@gmail.com'
|
15
|
-
s.files = `git ls-files`.split("\n")
|
16
21
|
s.homepage = 'https://github.com/RaoH37/zm-ruby-client'
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
17
24
|
s.require_paths = ['lib']
|
18
|
-
s.license = 'GPL-3.0'
|
19
25
|
|
20
|
-
s.add_dependency('addressable', ['~> 2.
|
21
|
-
s.add_dependency('curb', ['~> 0
|
22
|
-
s.add_dependency('nokogiri', ['~> 1.10.1'])
|
23
|
-
s.add_dependency('gyoku', ['~> 1.3.1'])
|
26
|
+
s.add_dependency('addressable', ['~> 2.8'])
|
27
|
+
s.add_dependency('curb', ['~> 1.0'])
|
24
28
|
s.add_dependency('version_sorter', ['~> 2.3.0'])
|
25
|
-
end
|
29
|
+
end
|
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: 0.
|
4
|
+
version: 0.18.0
|
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: 2023-
|
11
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -16,56 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: curb
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: nokogiri
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.10.1
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.10.1
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: gyoku
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.3.1
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 1.3.1
|
40
|
+
version: '1.0'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: version_sorter
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,7 +116,6 @@ files:
|
|
144
116
|
- lib/zm/client/connector/soap_admin.rb
|
145
117
|
- lib/zm/client/connector/soap_base.rb
|
146
118
|
- lib/zm/client/connector/soap_error.rb
|
147
|
-
- lib/zm/client/connector/soap_xml_builder.rb
|
148
119
|
- lib/zm/client/constant.rb
|
149
120
|
- lib/zm/client/contact.rb
|
150
121
|
- lib/zm/client/contact/contact.rb
|
@@ -286,14 +257,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
286
257
|
requirements:
|
287
258
|
- - ">="
|
288
259
|
- !ruby/object:Gem::Version
|
289
|
-
version: '
|
260
|
+
version: '2.6'
|
290
261
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
291
262
|
requirements:
|
292
263
|
- - ">="
|
293
264
|
- !ruby/object:Gem::Version
|
294
265
|
version: '0'
|
295
266
|
requirements: []
|
296
|
-
rubygems_version: 3.
|
267
|
+
rubygems_version: 3.4.10
|
297
268
|
signing_key:
|
298
269
|
specification_version: 4
|
299
270
|
summary: zm-ruby-client
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'nokogiri'
|
4
|
-
# https://stackoverflow.com/questions/11933451/converting-nested-hash-into-xml-using-nokogiri
|
5
|
-
|
6
|
-
class SoapXmlBuilder
|
7
|
-
ATTRS_NODE_PROC = ->(k, _) { k.to_s.start_with?('_') }
|
8
|
-
|
9
|
-
def initialize(hash)
|
10
|
-
@hash = hash
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_xml
|
14
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
15
|
-
xml.Envelope('xmlns' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:urn' => 'urn:zimbra') do
|
16
|
-
header(xml)
|
17
|
-
body(xml)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
builder.to_xml
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def header(xml)
|
26
|
-
return unless @hash[:Header]
|
27
|
-
|
28
|
-
xml.Header do
|
29
|
-
xml.context_('xmlns' => 'urn:zimbra') do
|
30
|
-
xml.authToken @hash[:Header][:context][:authToken]
|
31
|
-
if @hash[:Header][:context][:targetServer]
|
32
|
-
xml.targetServer @hash[:Header][:context][:targetServer]
|
33
|
-
end
|
34
|
-
xml.format('type' => 'js')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def body(xml)
|
40
|
-
return unless @hash[:Body]
|
41
|
-
|
42
|
-
xml.Body do
|
43
|
-
generate_xml(@hash[:Body], xml)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def generate_xml(hash, xml)
|
48
|
-
hash.each do |req_name, req_h|
|
49
|
-
xml.send(req_name, transform_keys(req_h.select(&ATTRS_NODE_PROC))) do
|
50
|
-
req_h.reject(&ATTRS_NODE_PROC).each do |label, value|
|
51
|
-
if value.is_a?(Hash)
|
52
|
-
generate_xml(value, xml)
|
53
|
-
elsif value.is_a?(Array)
|
54
|
-
value.each do |el|
|
55
|
-
xml.send(label, el.reject(&ATTRS_NODE_PROC), el[:_content])
|
56
|
-
end
|
57
|
-
else
|
58
|
-
xml.send(label, value)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def transform_keys(hash)
|
66
|
-
Hash[hash.map { |k, v| [k.to_s.sub(/\A_/, '').sub('jsns', 'xmlns'), v] }]
|
67
|
-
end
|
68
|
-
end
|