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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4de72020fc5b06ed81e86eec0c27f10fbbd9d09de6f65d3299f8ed467cb5058f
|
|
4
|
+
data.tar.gz: fcc142156bdc55b58c33c66433bf7ca278ff396381514f646b74b6101b26115d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2df2ca3bdcc7ee18ebcb865e34d5a8335e2da2eff4191c83261d20ced0510f8434081f0b33ea186af791e81c56ded88b084375eed245277810cc6157282e9ce4
|
|
7
|
+
data.tar.gz: dfaa387e98fc19098640927f85d4318119d9c198c8d9e95a991c3d90fe13d1fea0524e26b2fabec1c2d6ac9d25f7dc06f5a9d7fb4105fdf280206584a62e9ae4
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -25,27 +25,28 @@ module Zm
|
|
|
25
25
|
module Client
|
|
26
26
|
# objectClass: zimbraAccount
|
|
27
27
|
class Account < Base::AdminObject
|
|
28
|
-
attr_reader :name, :id, :token
|
|
29
|
-
attr_writer :home_url
|
|
30
|
-
attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
|
|
28
|
+
# attr_reader :name, :id, :token
|
|
29
|
+
# attr_writer :home_url
|
|
30
|
+
# attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
|
|
31
|
+
attr_accessor :name, :id, :token, :home_url, :password, :domainkey, :carLicense
|
|
31
32
|
|
|
32
|
-
def initialize(parent
|
|
33
|
-
extend(AccountCommon)
|
|
33
|
+
def initialize(parent)
|
|
34
|
+
# extend(AccountCommon)
|
|
34
35
|
super(parent)
|
|
35
36
|
@grantee_type = 'usr'.freeze
|
|
36
37
|
end
|
|
37
38
|
|
|
38
|
-
def init_by_hash(attrs)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
39
|
+
# def init_by_hash(attrs)
|
|
40
|
+
# attrs.each do |k, v|
|
|
41
|
+
# self.instance_variable_set(arrow_name(k), v)
|
|
42
|
+
# end
|
|
43
|
+
# end
|
|
43
44
|
|
|
44
|
-
def to_h
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
end
|
|
45
|
+
# def to_h
|
|
46
|
+
# hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
|
|
47
|
+
# hashmap.delete_if { |_, v| v.nil? }
|
|
48
|
+
# hashmap
|
|
49
|
+
# end
|
|
49
50
|
|
|
50
51
|
def all_instance_variable_keys
|
|
51
52
|
AccountCommon::ZM_ACCOUNT_ATTRS
|
|
@@ -99,7 +100,7 @@ module Zm
|
|
|
99
100
|
end
|
|
100
101
|
|
|
101
102
|
def domain_name
|
|
102
|
-
@name.split('@').last
|
|
103
|
+
@domain_name ||= @name.split('@').last
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
def domain_key
|
|
@@ -107,7 +108,7 @@ module Zm
|
|
|
107
108
|
end
|
|
108
109
|
|
|
109
110
|
def infos
|
|
110
|
-
@infos
|
|
111
|
+
@infos || read_infos
|
|
111
112
|
end
|
|
112
113
|
|
|
113
114
|
def read_infos
|
|
@@ -117,6 +118,7 @@ module Zm
|
|
|
117
118
|
@public_url = @infos[:publicURL]
|
|
118
119
|
@zimbraCOSId = @infos[:cos][:id]
|
|
119
120
|
@home_url = @infos[:rest]
|
|
121
|
+
@infos
|
|
120
122
|
end
|
|
121
123
|
|
|
122
124
|
def cos
|
|
@@ -253,6 +255,12 @@ module Zm
|
|
|
253
255
|
@id = rep[:Body][:CreateAccountResponse][:account].first[:id]
|
|
254
256
|
end
|
|
255
257
|
|
|
258
|
+
def set_password(new_password = nil)
|
|
259
|
+
new_password ||= @password
|
|
260
|
+
sac.set_password(@id, new_password)
|
|
261
|
+
@password = new_password
|
|
262
|
+
end
|
|
263
|
+
|
|
256
264
|
def aliases
|
|
257
265
|
@aliases ||= set_aliases
|
|
258
266
|
end
|
|
@@ -335,6 +343,10 @@ module Zm
|
|
|
335
343
|
@dls_owner ||= AccountDlsOwnerCollection.new(self)
|
|
336
344
|
end
|
|
337
345
|
|
|
346
|
+
def ranking(op, email = nil)
|
|
347
|
+
sacc.ranking_action(@token, op, email)
|
|
348
|
+
end
|
|
349
|
+
|
|
338
350
|
def init_from_json(json)
|
|
339
351
|
@used = json[:used] if json[:used]
|
|
340
352
|
@zimbraMailQuota = json[:limit] if json[:limit]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for initialize account
|
|
6
|
+
class AccountJsnsInitializer
|
|
7
|
+
class << self
|
|
8
|
+
def create(parent, json)
|
|
9
|
+
item = Account.new(parent)
|
|
10
|
+
|
|
11
|
+
update(item, json)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def update(item, json)
|
|
15
|
+
|
|
16
|
+
attr_types_h = item.parent.zimbra_attributes.all_account_attr_types_h
|
|
17
|
+
|
|
18
|
+
# puts attr_types_h
|
|
19
|
+
|
|
20
|
+
item.id = json[:id]
|
|
21
|
+
item.name = json[:name]
|
|
22
|
+
|
|
23
|
+
json[:a].reject! { |n| n[:n].nil? }
|
|
24
|
+
json_map = Hash[json[:a].map { |n| [n[:n], n[:_content]] }].freeze
|
|
25
|
+
|
|
26
|
+
# puts json_map
|
|
27
|
+
|
|
28
|
+
# item.parent.zimbra_attributes.all_account_attrs.each do |attr|
|
|
29
|
+
# if attr.type.nil?
|
|
30
|
+
# # p attr
|
|
31
|
+
# else
|
|
32
|
+
# json_field = json_map[attr.name]
|
|
33
|
+
# puts json_field unless json_field.nil?
|
|
34
|
+
# end
|
|
35
|
+
# end
|
|
36
|
+
|
|
37
|
+
item.init_from_json(json)
|
|
38
|
+
|
|
39
|
+
item
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -7,12 +7,15 @@ module Zm
|
|
|
7
7
|
def initialize(parent, json)
|
|
8
8
|
super(parent, json)
|
|
9
9
|
@child_class = Account
|
|
10
|
+
@json_item_key = :account
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
def make
|
|
14
|
+
return [] if json_items.nil?
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
json_items.map do |entry|
|
|
17
|
+
AccountJsnsInitializer.create(@parent, entry)
|
|
18
|
+
end
|
|
16
19
|
end
|
|
17
20
|
end
|
|
18
21
|
end
|
|
@@ -3,45 +3,36 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# Collection Accounts
|
|
6
|
-
class AccountsCollection < Base::
|
|
6
|
+
class AccountsCollection < Base::AdminObjectsCollection
|
|
7
7
|
def initialize(parent)
|
|
8
8
|
@child_class = Account
|
|
9
|
-
@
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def ldap
|
|
14
|
-
@apply_cos = 0
|
|
15
|
-
self
|
|
9
|
+
@builder_class = AccountsBuilder
|
|
10
|
+
@search_type = SearchType::ACCOUNT
|
|
11
|
+
super(parent)
|
|
16
12
|
end
|
|
17
13
|
|
|
18
14
|
def find_by(hash)
|
|
19
15
|
rep = sac.get_account(hash.values.first, hash.keys.first, attrs_comma, @apply_cos)
|
|
20
|
-
reset_query_params
|
|
21
16
|
entry = rep[:Body][:GetAccountResponse][:account].first
|
|
17
|
+
# puts entry
|
|
22
18
|
|
|
19
|
+
reset_query_params
|
|
23
20
|
build_from_entry(entry)
|
|
24
21
|
end
|
|
25
22
|
|
|
26
|
-
def
|
|
27
|
-
|
|
23
|
+
def quotas
|
|
24
|
+
return nil if @domain_name.nil? && @target_server_id.nil?
|
|
25
|
+
|
|
26
|
+
json = sac.get_quota_usage(@domain_name, @all_servers, @limit, @offset, @sort_by, @sort_ascending, @refresh, @target_server_id)
|
|
28
27
|
reset_query_params
|
|
29
|
-
|
|
28
|
+
@builder_class.new(@parent, json).make
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
private
|
|
33
32
|
|
|
34
|
-
def build_response
|
|
35
|
-
AccountsBuilder.new(@parent, make_query).make
|
|
36
|
-
end
|
|
37
|
-
|
|
38
33
|
def reset_query_params
|
|
39
34
|
super
|
|
40
|
-
@search_type = SearchType::ACCOUNT
|
|
41
35
|
@attrs = SearchType::Attributes::ACCOUNT.dup
|
|
42
|
-
@all_servers = 1
|
|
43
|
-
@refresh = 0
|
|
44
|
-
@apply_cos = 1
|
|
45
36
|
end
|
|
46
37
|
end
|
|
47
38
|
end
|
data/lib/zm/client/account.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'zm/client/account/account'
|
|
4
|
+
require 'zm/client/account/account_jsns_initializer'
|
|
4
5
|
require 'zm/client/account/accounts_builder'
|
|
5
6
|
require 'zm/client/account/accounts_collection'
|
|
6
7
|
require 'zm/client/account/account_dls_membership_collection'
|
data/lib/zm/client/ace/ace.rb
CHANGED
|
@@ -9,23 +9,36 @@ module Zm
|
|
|
9
9
|
|
|
10
10
|
attr_accessor *INSTANCE_VARIABLE_KEYS
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
INSTANCE_VARIABLE_KEYS
|
|
14
|
-
var_name = "@#{key}"
|
|
15
|
-
instance_variable_set(var_name, json[key])
|
|
16
|
-
end
|
|
12
|
+
def all_instance_variable_keys
|
|
13
|
+
INSTANCE_VARIABLE_KEYS
|
|
17
14
|
end
|
|
18
15
|
|
|
19
16
|
def create!
|
|
20
|
-
|
|
17
|
+
rep = @parent.sacc.grant_rights(get_token, jsns_builder.to_jsns)
|
|
18
|
+
json = rep[:Body][:GrantRightsResponse][:ace].first if rep[:Body][:GrantRightsResponse][:ace].is_a?(Array)
|
|
19
|
+
AceJsnsInitializer.update(self, json) unless json.nil?
|
|
20
|
+
true
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def delete!
|
|
24
|
-
|
|
24
|
+
@parent.sacc.revoke_rights(get_token, jsns_builder.to_delete)
|
|
25
|
+
@parent.all.delete(self)
|
|
26
|
+
true
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def jsns_builder
|
|
32
|
+
@jsns_builder ||= AceJsnsBuilder.new(self)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def get_token(target = self)
|
|
36
|
+
token = nil
|
|
37
|
+
return target.token if target.respond_to?(:token) && !target.token.nil?
|
|
38
|
+
|
|
39
|
+
token = get_token(target.parent) if target.respond_to?(:parent)
|
|
40
|
+
|
|
41
|
+
token
|
|
29
42
|
end
|
|
30
43
|
end
|
|
31
44
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account folder jsns builder
|
|
6
|
+
class AceJsnsBuilder < Base::BaseJsnsBuilder
|
|
7
|
+
|
|
8
|
+
def to_find
|
|
9
|
+
return nil if @item.rights.empty?
|
|
10
|
+
|
|
11
|
+
ace = @item.rights.map { |r| { right: r } }
|
|
12
|
+
{ ace: ace }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_jsns
|
|
16
|
+
ace = {
|
|
17
|
+
zid: @item.zid,
|
|
18
|
+
gt: @item.gt,
|
|
19
|
+
right: @item.right,
|
|
20
|
+
d: @item.d
|
|
21
|
+
}.reject { |_, v| v.nil? }
|
|
22
|
+
|
|
23
|
+
{ ace: ace }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_delete
|
|
27
|
+
ace = {
|
|
28
|
+
zid: @item.zid,
|
|
29
|
+
gt: @item.gt,
|
|
30
|
+
right: @item.right,
|
|
31
|
+
d: @item.d
|
|
32
|
+
}.reject { |_, v| v.nil? }
|
|
33
|
+
|
|
34
|
+
{ ace: ace }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for initialize account ace
|
|
6
|
+
class AceJsnsInitializer
|
|
7
|
+
class << self
|
|
8
|
+
def create(parent, json)
|
|
9
|
+
item = Ace.new(parent)
|
|
10
|
+
|
|
11
|
+
update(item, json)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def update(item, json)
|
|
15
|
+
|
|
16
|
+
item.instance_variable_set(:@zid, json[:zid])
|
|
17
|
+
item.instance_variable_set(:@gt, json[:gt])
|
|
18
|
+
item.instance_variable_set(:@right, json[:right])
|
|
19
|
+
item.instance_variable_set(:@d, json[:d])
|
|
20
|
+
|
|
21
|
+
item
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -5,19 +5,16 @@ module Zm
|
|
|
5
5
|
# class factory [aces]
|
|
6
6
|
class AcesBuilder < Base::ObjectsBuilder
|
|
7
7
|
def initialize(parent, json)
|
|
8
|
-
|
|
9
|
-
@
|
|
8
|
+
super(parent, json)
|
|
9
|
+
@child_class = Ace
|
|
10
|
+
@json_item_key = :ace
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def make
|
|
13
|
-
|
|
14
|
-
return [] if root.nil?
|
|
14
|
+
return [] if json_items.nil?
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ace = Ace.new(@parent)
|
|
19
|
-
ace.init_from_json(s)
|
|
20
|
-
ace
|
|
16
|
+
json_items.map do |entry|
|
|
17
|
+
AceJsnsInitializer.create(@parent, entry)
|
|
21
18
|
end
|
|
22
19
|
end
|
|
23
20
|
end
|
|
@@ -3,33 +3,47 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# collection account aces
|
|
6
|
-
class AcesCollection < Base::
|
|
6
|
+
class AcesCollection < Base::AccountObjectsCollection
|
|
7
|
+
attr_reader :rights
|
|
8
|
+
|
|
7
9
|
def initialize(parent)
|
|
8
|
-
|
|
10
|
+
super(parent)
|
|
11
|
+
@builder_class = AcesBuilder
|
|
12
|
+
@jsns_builder = AceJsnsBuilder.new(self)
|
|
9
13
|
reset_query_params
|
|
10
14
|
end
|
|
11
15
|
|
|
12
16
|
def new
|
|
13
|
-
ace = Ace.new(
|
|
17
|
+
ace = Ace.new(self)
|
|
14
18
|
yield(ace) if block_given?
|
|
15
19
|
ace
|
|
16
20
|
end
|
|
17
21
|
|
|
18
|
-
def
|
|
19
|
-
@rights
|
|
22
|
+
def where(*rights)
|
|
23
|
+
@rights += rights
|
|
24
|
+
@rights.uniq!
|
|
20
25
|
self
|
|
21
26
|
end
|
|
22
27
|
|
|
28
|
+
def soap_account_connector
|
|
29
|
+
@parent.soap_account_connector
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
alias sacc soap_account_connector
|
|
33
|
+
|
|
23
34
|
private
|
|
24
35
|
|
|
36
|
+
def make_query
|
|
37
|
+
@parent.sacc.get_rights(@parent.token, @jsns_builder.to_find)
|
|
38
|
+
end
|
|
39
|
+
|
|
25
40
|
def build_response
|
|
26
|
-
|
|
27
|
-
ab = AcesBuilder.new @parent, rep
|
|
28
|
-
ab.make
|
|
41
|
+
@builder_class.new(self, make_query).make
|
|
29
42
|
end
|
|
30
43
|
|
|
31
44
|
def reset_query_params
|
|
32
|
-
@rights = %i[sendAs sendOnBehalfOf]
|
|
45
|
+
# @rights = %i[sendAs sendOnBehalfOf]
|
|
46
|
+
@rights = []
|
|
33
47
|
end
|
|
34
48
|
end
|
|
35
49
|
end
|
data/lib/zm/client/ace.rb
CHANGED
|
@@ -15,7 +15,6 @@ module Zm
|
|
|
15
15
|
alias description desc
|
|
16
16
|
alias parent_id l
|
|
17
17
|
|
|
18
|
-
# def initialize(parent, json = nil)
|
|
19
18
|
def initialize(parent)
|
|
20
19
|
@parent = parent
|
|
21
20
|
@recipients = Recipients.new
|
|
@@ -26,8 +25,8 @@ module Zm
|
|
|
26
25
|
yield(self) if block_given?
|
|
27
26
|
end
|
|
28
27
|
|
|
29
|
-
def
|
|
30
|
-
INSTANCE_VARIABLE_KEYS
|
|
28
|
+
def all_instance_variable_keys
|
|
29
|
+
INSTANCE_VARIABLE_KEYS
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
def folder
|
|
@@ -41,7 +40,6 @@ module Zm
|
|
|
41
40
|
end
|
|
42
41
|
|
|
43
42
|
def create!
|
|
44
|
-
jsns_builder = AppointmentJsnsBuilder.new(self)
|
|
45
43
|
rep = @parent.sacc.create_appointment(@parent.token, jsns_builder.to_jsns)
|
|
46
44
|
rep_h = rep[:Body][:CreateAppointmentResponse]
|
|
47
45
|
|
|
@@ -51,7 +49,6 @@ module Zm
|
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
def modify!
|
|
54
|
-
jsns_builder = AppointmentJsnsBuilder.new(self)
|
|
55
52
|
@parent.sacc.modify_appointment(@parent.token, jsns_builder.to_update)
|
|
56
53
|
end
|
|
57
54
|
|
|
@@ -64,8 +61,8 @@ module Zm
|
|
|
64
61
|
end
|
|
65
62
|
|
|
66
63
|
def delete!
|
|
67
|
-
jsns_builder = AppointmentJsnsBuilder.new(self)
|
|
68
64
|
@parent.sacc.cancel_appointment(@parent.token, jsns_builder.to_delete)
|
|
65
|
+
super
|
|
69
66
|
end
|
|
70
67
|
|
|
71
68
|
def free!
|
|
@@ -138,6 +135,12 @@ module Zm
|
|
|
138
135
|
@rsvp = rsvp
|
|
139
136
|
end
|
|
140
137
|
end
|
|
138
|
+
|
|
139
|
+
private
|
|
140
|
+
|
|
141
|
+
def jsns_builder
|
|
142
|
+
@jsns_builder ||= AppointmentJsnsBuilder.new(self)
|
|
143
|
+
end
|
|
141
144
|
end
|
|
142
145
|
end
|
|
143
146
|
end
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# collection of appointments
|
|
6
|
-
class AppointmentsCollection < Base::
|
|
7
|
-
attr_accessor :more
|
|
8
|
-
|
|
6
|
+
class AppointmentsCollection < Base::AccountSearchObjectsCollection
|
|
9
7
|
def initialize(parent)
|
|
10
|
-
|
|
11
|
-
@
|
|
12
|
-
|
|
8
|
+
super(parent)
|
|
9
|
+
@child_class = Appointment
|
|
10
|
+
@builder_class = AppointmentsBuilder
|
|
11
|
+
@type = 'appointment'
|
|
12
|
+
@sort_by = 'dateAsc'
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def find(id)
|
|
@@ -17,90 +17,6 @@ module Zm
|
|
|
17
17
|
entry = rep[:Body][:GetMsgResponse][:m].first
|
|
18
18
|
AppointmentJsnsInitializer.new(@parent, entry).create
|
|
19
19
|
end
|
|
20
|
-
|
|
21
|
-
def new
|
|
22
|
-
appointment = Appointment.new(@parent)
|
|
23
|
-
yield(appointment) if block_given?
|
|
24
|
-
appointment
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def start_at(start_at)
|
|
28
|
-
@start_at = start_at
|
|
29
|
-
self
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def end_at(end_at)
|
|
33
|
-
@end_at = end_at
|
|
34
|
-
self
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def folders(folders)
|
|
38
|
-
@folders = folders
|
|
39
|
-
@folder_ids = @folders.map(&:id)
|
|
40
|
-
self
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def folder_ids(folder_ids)
|
|
44
|
-
@folder_ids = folder_ids
|
|
45
|
-
self
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def where(query)
|
|
49
|
-
@query = query
|
|
50
|
-
self
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def ids
|
|
54
|
-
search_builder.ids
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
|
|
59
|
-
def search_response
|
|
60
|
-
rep = @parent.sacc.search(@parent.token, 'appointment', @offset, @limit, 'dateAsc', query, build_options)
|
|
61
|
-
@more = rep[:Body][:SearchResponse][:more]
|
|
62
|
-
rep
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def search_builder
|
|
66
|
-
AppointmentsBuilder.new(@parent, search_response)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def build_response
|
|
70
|
-
appointments = search_builder.make
|
|
71
|
-
appointments.each { |appo| appo.folder = find_folder(appo) } unless @folders.empty?
|
|
72
|
-
appointments
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def build_options
|
|
76
|
-
return {} if !@start_at.is_a?(Time) && !@end_at.is_a?(Time)
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
calExpandInstStart: (@start_at.to_f * 1000).to_i,
|
|
80
|
-
calExpandInstEnd: (@end_at.to_f * 1000).to_i,
|
|
81
|
-
}
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def query
|
|
85
|
-
return @query unless @query.nil?
|
|
86
|
-
|
|
87
|
-
return nil if @folder_ids.empty?
|
|
88
|
-
|
|
89
|
-
@folder_ids.map { |id| %Q{inid:"#{id}"} }.join(' OR ')
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def find_folder(appointment)
|
|
93
|
-
@folders.find { |folder| folder.id == appointment.l }
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def reset_query_params
|
|
97
|
-
super
|
|
98
|
-
@start_at = nil
|
|
99
|
-
@end_at = nil
|
|
100
|
-
@query = nil
|
|
101
|
-
@folder_ids = []
|
|
102
|
-
@folders = []
|
|
103
|
-
end
|
|
104
20
|
end
|
|
105
21
|
end
|
|
106
22
|
end
|
|
@@ -13,12 +13,16 @@ module Zm
|
|
|
13
13
|
parent
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
hashmap.delete_if { |_, v| v.nil? }
|
|
19
|
-
hashmap
|
|
16
|
+
def all_instance_variable_keys
|
|
17
|
+
INSTANCE_VARIABLE_KEYS
|
|
20
18
|
end
|
|
21
19
|
|
|
20
|
+
# def to_h
|
|
21
|
+
# hashmap = Hash[INSTANCE_VARIABLE_KEYS.map { |key| [key, instance_variable_get(arrow_name(key))] }]
|
|
22
|
+
# hashmap.delete_if { |_, v| v.nil? }
|
|
23
|
+
# hashmap
|
|
24
|
+
# end
|
|
25
|
+
|
|
22
26
|
def to_s
|
|
23
27
|
to_h.to_s
|
|
24
28
|
end
|