zm-ruby-client 0.18.1 → 0.18.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e477be30a69440be21ac3e5b18765740fb696edfc51774bc7591ca0cbfd5fa6
4
- data.tar.gz: 0cf1765bff4390e229da1bd4ba9dbdca68f50e99b107cf7d85c8843eb17bd6ce
3
+ metadata.gz: d440e1ce50365f9c9225698840476f72397aa4ac165dfb52d484d9065e9044de
4
+ data.tar.gz: 01bbd079546b0aa7d94969d4b27cbb28ad069c3d8e652d5891651ab201147ecd
5
5
  SHA512:
6
- metadata.gz: ce5e56422548fdc7161d6559f447c5c58e8d93b9dd3386a9d6d99d20e4271ac38e638a28e3ea3cda116fc27ccab3fa9f53fa3fa1d77d9ed52873f010c461cbeb
7
- data.tar.gz: ef6f5bc1eb0b70582d142d189f31c11c4c0e6f0f73edcf4530cd4395e9e6290f094f9b67f24e937f481d70de2c7606bace543d11d48e500e031d88e40604f6e9
6
+ metadata.gz: 4f84d4885300650907d06b86f1c7979c0fbec790af950b65e15713946159b9de5ba92b0daebe420a21d62b90fcf50b8c2f7af9e375a414dd61c541364ca8d1e2
7
+ data.tar.gz: c8c3b854cf9fb4afd531164b41f15ebaf53eb85ae1e639a54ff23538eed2084510864736512ff9209a1c2ba276b0d98e270a7a5f41247dfae469b36f04a9bb32
@@ -57,7 +57,7 @@ module Zm
57
57
  end
58
58
 
59
59
  def ids
60
- @options = { resultMode: 1 }
60
+ @resultMode = 'IDS'
61
61
  search_builder.ids
62
62
  end
63
63
 
@@ -364,6 +364,19 @@ module Zm
364
364
  curl_request(body)
365
365
  end
366
366
 
367
+ def modify_prefs(token, hash)
368
+ soap_name = :ModifyPrefsRequest
369
+ body = init_hash_request(token, soap_name, ACCOUNTSPACE)
370
+
371
+ req = {
372
+ _attrs: hash
373
+ }
374
+
375
+ body[:Body][soap_name].merge!(req)
376
+
377
+ curl_request(body)
378
+ end
379
+
367
380
  def get_signatures(token)
368
381
  soap_name = :GetSignaturesRequest
369
382
  body = init_hash_request(token, soap_name, ACCOUNTSPACE)
@@ -153,12 +153,15 @@ module Zm
153
153
  curl_request(body)
154
154
  end
155
155
 
156
- def modify_cos(id, _attrs = nil)
157
- # req = { _jsns: ADMINSPACE, id: id, a: attrs.to_a.map{ |n| { n: n.first, _content: n.last } } }
158
- req = { _jsns: ADMINSPACE, id: id }
156
+ def modify_cos(id, attrs = nil)
157
+ req = { _jsns: ADMINSPACE, id: [{ _content: id }], a: attrs.to_a.map{ |n| { n: n.first, _content: n.last } } }
159
158
  body = { Body: { ModifyCosRequest: req } }.merge(hash_header(@token))
160
- # TODO: ne fonctionne pas !
161
- # peut-être seul la version xml fonctionne. Il faudrait créer une fonction qui converti le json en xml
159
+ curl_request(body)
160
+ end
161
+
162
+ def delete_cos(id)
163
+ req = { _jsns: ADMINSPACE, id: [{ _content: id }] }
164
+ body = { Body: { DeleteCosRequest: req } }.merge(hash_header(@token))
162
165
  curl_request(body)
163
166
  end
164
167
 
@@ -198,6 +201,10 @@ module Zm
198
201
  curl_request(body)
199
202
  end
200
203
 
204
+ def rename_resource(id, email)
205
+ generic_rename(:RenameCalendarResourceRequest, id, email)
206
+ end
207
+
201
208
  def create_distribution_list(name, attrs = [])
202
209
  soap_name = :CreateDistributionListRequest
203
210
  req = { name: name }
@@ -35,7 +35,11 @@ module Zm
35
35
  end
36
36
 
37
37
  def modify!
38
- # sac.modify_cos(id, instance_variables_array)
38
+ sac.modify_cos(id, instance_variables_array(attrs_write))
39
+ end
40
+
41
+ def delete!
42
+ sac.delete_cos(id)
39
43
  end
40
44
 
41
45
  def create!
@@ -17,11 +17,9 @@ module Zm
17
17
  @grantee_type = 'grp'.freeze
18
18
  end
19
19
 
20
- # def to_h
21
- # hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
22
- # hashmap.delete_if { |_, v| v.nil? }
23
- # hashmap
24
- # end
20
+ def domain_name
21
+ @domain_name ||= @name.split('@').last
22
+ end
25
23
 
26
24
  def all_instance_variable_keys
27
25
  DistributionListCommon::ALL_ATTRS
@@ -102,13 +100,33 @@ module Zm
102
100
  end
103
101
 
104
102
  def add_owners!(*emails)
105
- # todo à tester
106
- sac.distribution_list_action(@id, :id, { op: 'addOwners', owner: { by: :name, type: :usr, _content: emails } })
103
+ sac.distribution_list_action(
104
+ @id,
105
+ :id,
106
+ {
107
+ op: 'addOwners',
108
+ owner: emails.map do |email|
109
+ { by: :name, type: :usr, _content: email }
110
+ end
111
+ }
112
+ )
113
+
114
+ @owners += emails
107
115
  end
108
116
 
109
117
  def remove_owners!(*emails)
110
- # todo à tester
111
- sac.distribution_list_action(@id, :id, { op: 'removeOwners', owner: { by: :name, type: :usr, _content: emails } })
118
+ sac.distribution_list_action(
119
+ @id,
120
+ :id,
121
+ {
122
+ op: 'removeOwners',
123
+ owner: emails.map do |email|
124
+ { by: :name, type: :usr, _content: email }
125
+ end
126
+ }
127
+ )
128
+
129
+ @owners -= emails
112
130
  end
113
131
 
114
132
  def local_transport
@@ -6,7 +6,8 @@ module Zm
6
6
  class Domain < Base::AdminObject
7
7
  INSTANCE_VARIABLE_KEYS = %i[name description zimbraDomainName zimbraDomainStatus zimbraId zimbraDomainType
8
8
  zimbraDomainDefaultCOSId zimbraGalAccountId zimbraPreAuthKey zimbraGalLdapBindDn zimbraGalLdapBindPassword
9
- zimbraGalLdapFilter zimbraGalLdapSearchBase zimbraGalLdapURL zimbraGalMode zimbraMailTransport]
9
+ zimbraGalLdapFilter zimbraGalLdapSearchBase zimbraGalLdapURL zimbraGalMode zimbraMailTransport
10
+ zimbraPublicServiceHostname zimbraPublicServiceProtocol]
10
11
 
11
12
  attr_accessor *INSTANCE_VARIABLE_KEYS
12
13
 
@@ -54,6 +55,10 @@ module Zm
54
55
  @accounts ||= DomainAccountsCollection.new(self)
55
56
  end
56
57
 
58
+ def delete!
59
+ sac.generic_delete(:DeleteDomainRequest, id)
60
+ end
61
+
57
62
  # def account_quotas(server_id)
58
63
  # rep = sac.get_quota_usage(name, nil, nil, nil, nil, nil, nil, server_id)
59
64
  # AccountsBuilder.new(@parent, rep).make
@@ -14,6 +14,7 @@ module Zm
14
14
  :s, :i4ms, :i4next, :zid, :rid, :ruuid, :owner, :reminder, :acl, :itemCount, :broken, :deletable, :fb
15
15
 
16
16
  attr_accessor :folders, :grants, :retention_policies
17
+ attr_writer :absFolderPath
17
18
 
18
19
  define_changed_attributes :name, :color, :rgb, :l, :url, :f, :view
19
20
 
@@ -51,7 +51,7 @@ module Zm
51
51
  end
52
52
 
53
53
  def modify!
54
- @parent.sacc.modify_identity(@parent.token, id, instance_variables_array(ATTRS_WRITE))
54
+ @parent.sacc.modify_identity(@parent.token, id, Hash[instance_variables_array(ATTRS_WRITE)])
55
55
  end
56
56
 
57
57
  def delete!
@@ -16,7 +16,8 @@ module Zm
16
16
  end
17
17
 
18
18
  def ids
19
- @json[:Body][:SearchResponse][:hit].map { |s| s[:id] }
19
+ hits = @json.dig(:Body, :SearchResponse, :hit) || []
20
+ hits.map { |s| s[:id] }
20
21
  end
21
22
 
22
23
  def root
@@ -12,7 +12,8 @@ module Zm
12
12
  webOfflineSyncDays color rgb
13
13
  ].freeze
14
14
 
15
- attr_reader :owner, :rev, :reminder, :ms, :deletable, :rid, :uuid, :url, :f, :broken, :luuid, :ruuid, :activesyncdisabled, :absFolderPath, :view, :zid, :id, :webOfflineSyncDays
15
+ attr_reader :owner, :rev, :reminder, :ms, :deletable, :rid, :uuid, :url, :f, :broken, :luuid, :ruuid, :activesyncdisabled, :absFolderPath, :zid, :id, :webOfflineSyncDays
16
+ attr_writer :view, :zid, :rid
16
17
 
17
18
  define_changed_attributes :name, :color, :rgb, :l
18
19
 
@@ -32,6 +33,10 @@ module Zm
32
33
  # todo
33
34
  end
34
35
 
36
+ def fb
37
+ nil
38
+ end
39
+
35
40
  private
36
41
 
37
42
  def jsns_builder
@@ -17,7 +17,6 @@ module Zm
17
17
  color: @item.color,
18
18
  rgb: @item.rgb,
19
19
  url: @item.url,
20
- fb: @item.fb,
21
20
  view: @item.view,
22
21
  zid: @item.zid,
23
22
  rid: @item.rid
@@ -38,7 +37,6 @@ module Zm
38
37
  color: @item.color,
39
38
  rgb: @item.rgb,
40
39
  url: @item.url,
41
- fb: @item.fb,
42
40
  view: @item.view
43
41
  }.delete_if { |_, v| v.nil? }
44
42
 
@@ -6,8 +6,7 @@ module Zm
6
6
  module Client
7
7
  # objectClass: zimbraCalendarResource
8
8
  class Resource < Base::AdminObject
9
- # attr_reader :name, :id, :domainkey, :used, :token
10
- attr_accessor :home_url
9
+ attr_accessor :home_url, :zimbraCalResAutoDeclineRecurring
11
10
 
12
11
  def initialize(parent)
13
12
  extend(ResourceCommon)
@@ -15,12 +14,6 @@ module Zm
15
14
  @grantee_type = 'usr'.freeze
16
15
  end
17
16
 
18
- # def to_h
19
- # hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
20
- # hashmap.delete_if { |_, v| v.nil? }
21
- # hashmap
22
- # end
23
-
24
17
  def all_instance_variable_keys
25
18
  ResourceCommon::ALL_ATTRS
26
19
  end
@@ -110,40 +103,14 @@ module Zm
110
103
  @id = rep[:Body][:CreateCalendarResourceResponse][:calresource].first[:id]
111
104
  end
112
105
 
106
+ def rename!(email)
107
+ sac.rename_resource(@id, email)
108
+ @name = email
109
+ end
110
+
113
111
  def uploader
114
112
  @uploader ||= Upload.new(self)
115
113
  end
116
-
117
- # def download(folder_path, fmt, types, dest_file_path)
118
- # url_folder_path = File.join(@home_url, folder_path.to_s)
119
- # uri = Addressable::URI.new
120
- # uri.query_values = {
121
- # fmt: fmt,
122
- # types: types.join(','),
123
- # emptyname: 'Vide',
124
- # charset: 'UTF-8',
125
- # auth: 'qp',
126
- # zauthtoken: @token
127
- # }
128
- # url_folder_path << '?' << uri.query
129
- #
130
- # rac.download(url_folder_path, dest_file_path)
131
- # end
132
- #
133
- # def upload(folder_path, fmt, types, resolve, src_file_path)
134
- # url_folder_path = File.join(@home_url, folder_path.to_s)
135
- # uri = Addressable::URI.new
136
- # uri.query_values = {
137
- # fmt: fmt,
138
- # types: types.join(','),
139
- # resolve: resolve,
140
- # auth: 'qp',
141
- # zauthtoken: @token
142
- # }
143
- # url_folder_path << '?' << uri.query
144
- #
145
- # rac.upload(url_folder_path, src_file_path)
146
- # end
147
114
  end
148
115
  end
149
116
  end
@@ -10,7 +10,7 @@ module Zm
10
10
  module VERSION
11
11
  MAJOR = 0
12
12
  MINOR = 18
13
- TINY = 1
13
+ TINY = 2
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
16
16
  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.18.1
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Désécot
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-14 00:00:00.000000000 Z
11
+ date: 2023-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -249,7 +249,7 @@ homepage: https://github.com/RaoH37/zm-ruby-client
249
249
  licenses:
250
250
  - GPL-3.0
251
251
  metadata: {}
252
- post_install_message:
252
+ post_install_message:
253
253
  rdoc_options: []
254
254
  require_paths:
255
255
  - lib
@@ -264,8 +264,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  - !ruby/object:Gem::Version
265
265
  version: '0'
266
266
  requirements: []
267
- rubygems_version: 3.1.6
268
- signing_key:
267
+ rubygems_version: 3.4.19
268
+ signing_key:
269
269
  specification_version: 4
270
270
  summary: zm-ruby-client
271
271
  test_files: []