zm-ruby-client 2.2.7 → 3.0.0
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/.rubocop.yml +6 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +10 -6
- data/Gemfile +1 -6
- data/README.md +10 -15
- data/VERSION +1 -1
- data/lib/zm/client/account/account.rb +35 -22
- data/lib/zm/client/account/account_aliases_collection.rb +14 -6
- data/lib/zm/client/account/account_dls_membership_collection.rb +10 -4
- data/lib/zm/client/account/account_dls_owner_collection.rb +8 -5
- data/lib/zm/client/account/account_jsns_builder.rb +31 -19
- data/lib/zm/client/account/account_jsns_initializer.rb +4 -14
- data/lib/zm/client/account/accounts_builder.rb +1 -1
- data/lib/zm/client/account/accounts_collection.rb +15 -8
- data/lib/zm/client/ace/ace.rb +5 -5
- data/lib/zm/client/ace/ace_jsns_builder.rb +8 -8
- data/lib/zm/client/ace/ace_jsns_initializer.rb +7 -7
- data/lib/zm/client/ace/aces_builder.rb +1 -1
- data/lib/zm/client/ace/aces_collection.rb +2 -2
- data/lib/zm/client/appointment/appointment.rb +27 -24
- data/lib/zm/client/appointment/appointment_jsns_builder.rb +29 -20
- data/lib/zm/client/appointment/appointment_jsns_initializer.rb +14 -13
- data/lib/zm/client/appointment/appointments_builder.rb +1 -1
- data/lib/zm/client/appointment/appointments_collection.rb +8 -7
- data/lib/zm/client/backup/backup.rb +6 -2
- data/lib/zm/client/backup/backup_jsns_initializer.rb +14 -12
- data/lib/zm/client/backup/backups_builder.rb +1 -1
- data/lib/zm/client/backup/backups_collection.rb +2 -1
- data/lib/zm/client/base/account_search_objects_collection.rb +46 -20
- data/lib/zm/client/base/admin_objects_collection.rb +22 -27
- data/lib/zm/client/base/base_account_jsns_builder.rb +1 -4
- data/lib/zm/client/base/base_jsns_initializer.rb +8 -8
- data/lib/zm/client/base/mailbox_infos_collection.rb +23 -15
- data/lib/zm/client/base/mailbox_object.rb +174 -69
- data/lib/zm/client/base/mailbox_prefs_collection.rb +4 -8
- data/lib/zm/client/base/object.rb +2 -2
- data/lib/zm/client/base/objects_builder.rb +7 -3
- data/lib/zm/client/base/objects_collection.rb +4 -13
- data/lib/zm/client/base/zimbra_attribute.rb +4 -17
- data/lib/zm/client/base/zimbra_attributes_collection.rb +16 -9
- data/lib/zm/client/base.rb +0 -1
- data/lib/zm/client/cluster/batch_request.rb +50 -0
- data/lib/zm/client/cluster/cluster.rb +49 -27
- data/lib/zm/client/cluster/cluster_config.rb +129 -40
- data/lib/zm/client/common/recipients.rb +2 -2
- data/lib/zm/client/common/utils.rb +1 -13
- data/lib/zm/client/common.rb +0 -1
- data/lib/zm/client/connector/{rest_account.rb → rest_connector.rb} +40 -50
- data/lib/zm/client/connector/soap_account.rb +19 -15
- data/lib/zm/client/connector/soap_admin.rb +9 -9
- data/lib/zm/client/connector/soap_base.rb +24 -17
- data/lib/zm/client/connector/soap_error.rb +3 -23
- data/lib/zm/client/constant.rb +18 -16
- data/lib/zm/client/contact/contact.rb +21 -40
- data/lib/zm/client/contact/contact_jsns_builder.rb +1 -1
- data/lib/zm/client/contact/contact_jsns_initializer.rb +4 -26
- data/lib/zm/client/contact/contacts_builder.rb +1 -1
- data/lib/zm/client/contact/contacts_collection.rb +4 -24
- data/lib/zm/client/contact/group_contact_jsns_builder.rb +18 -13
- data/lib/zm/client/contact/mod_group_contact.rb +6 -2
- data/lib/zm/client/cos/cos.rb +35 -11
- data/lib/zm/client/cos/cos_domains_collection.rb +1 -1
- data/lib/zm/client/cos/cos_jsns_builder.rb +22 -9
- data/lib/zm/client/cos/cos_jsns_initializer.rb +2 -6
- data/lib/zm/client/cos/cos_servers_collection.rb +5 -6
- data/lib/zm/client/cos/coses_builder.rb +1 -1
- data/lib/zm/client/cos/coses_collection.rb +6 -4
- data/lib/zm/client/datasource/datasource.rb +27 -34
- data/lib/zm/client/datasource/datasource_jsns_builder.rb +1 -1
- data/lib/zm/client/datasource/datasource_jsns_initializer.rb +5 -6
- data/lib/zm/client/datasource/datasources_builder.rb +6 -9
- data/lib/zm/client/datasource/datasources_collection.rb +6 -5
- data/lib/zm/client/distributionlist/distributionlist.rb +22 -42
- data/lib/zm/client/distributionlist/distributionlist_aliases_collection.rb +14 -6
- data/lib/zm/client/distributionlist/distributionlist_jsns_builder.rb +20 -16
- data/lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb +2 -11
- data/lib/zm/client/distributionlist/distributionlist_members_collection.rb +20 -12
- data/lib/zm/client/distributionlist/distributionlist_owners_collection.rb +16 -5
- data/lib/zm/client/distributionlist/distributionlists_builder.rb +1 -1
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +12 -6
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +12 -6
- data/lib/zm/client/document/document.rb +16 -8
- data/lib/zm/client/document/document_jsns_builder.rb +1 -1
- data/lib/zm/client/document/document_jsns_initializer.rb +27 -26
- data/lib/zm/client/document/documents_builder.rb +1 -1
- data/lib/zm/client/document/documents_collection.rb +1 -1
- data/lib/zm/client/domain/domain.rb +18 -37
- data/lib/zm/client/domain/domain_accounts_collection.rb +1 -1
- data/lib/zm/client/domain/domain_distributionlists_collection.rb +1 -1
- data/lib/zm/client/domain/domain_jsns_builder.rb +18 -9
- data/lib/zm/client/domain/domain_jsns_initializer.rb +2 -6
- data/lib/zm/client/domain/domain_resources_collection.rb +1 -1
- data/lib/zm/client/domain/domains_builder.rb +1 -1
- data/lib/zm/client/domain/domains_collection.rb +12 -6
- data/lib/zm/client/filter_rules/filter_rule.rb +0 -9
- data/lib/zm/client/filter_rules/filter_rule_jsns_initializer.rb +7 -6
- data/lib/zm/client/filter_rules/filter_rules_builder.rb +1 -1
- data/lib/zm/client/filter_rules/filter_rules_collection.rb +5 -15
- data/lib/zm/client/filter_rules/outgoing_filter_rules_collection.rb +5 -2
- data/lib/zm/client/folder/folder.rb +73 -56
- data/lib/zm/client/folder/folder_grant.rb +7 -5
- data/lib/zm/client/folder/folder_grant_jsns_builder.rb +6 -3
- data/lib/zm/client/folder/folder_grants_collection.rb +2 -4
- data/lib/zm/client/folder/folder_jsns_builder.rb +14 -7
- data/lib/zm/client/folder/folder_jsns_initializer.rb +58 -40
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +4 -2
- data/lib/zm/client/folder/folders_builder.rb +1 -1
- data/lib/zm/client/folder/folders_collection.rb +21 -18
- data/lib/zm/client/folder/folders_jsns_builder.rb +4 -2
- data/lib/zm/client/folder/mod_document_folder.rb +5 -4
- data/lib/zm/client/identity/identities_builder.rb +1 -1
- data/lib/zm/client/identity/identities_collection.rb +6 -5
- data/lib/zm/client/identity/identity.rb +9 -29
- data/lib/zm/client/identity/identity_jsns_builder.rb +8 -4
- data/lib/zm/client/identity/identity_jsns_initializer.rb +5 -4
- data/lib/zm/client/license/license.rb +7 -1
- data/lib/zm/client/license/license_jsns_initializer.rb +8 -5
- data/lib/zm/client/license/licenses_collection.rb +1 -1
- data/lib/zm/client/mailbox/mailbox_item_concern.rb +33 -0
- data/lib/zm/client/mailbox/mailbox_item_id.rb +7 -0
- data/lib/zm/client/message/attachments_collection.rb +2 -2
- data/lib/zm/client/message/message.rb +56 -52
- data/lib/zm/client/message/message_flags.rb +21 -13
- data/lib/zm/client/message/message_jsns_builder.rb +11 -6
- data/lib/zm/client/message/message_jsns_initializer.rb +24 -23
- data/lib/zm/client/message/messages_builder.rb +1 -1
- data/lib/zm/client/message/messages_collection.rb +1 -15
- data/lib/zm/client/mountpoint/mountpoint.rb +17 -25
- data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +6 -3
- data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +25 -24
- data/lib/zm/client/mountpoint/mountpoints_builder.rb +1 -1
- data/lib/zm/client/mountpoint/mountpoints_collection.rb +13 -9
- data/lib/zm/client/mta_queue/mta_queue.rb +6 -2
- data/lib/zm/client/mta_queue/mta_queue_jsns_initializer.rb +3 -7
- data/lib/zm/client/mta_queue/mta_queues_builder.rb +3 -1
- data/lib/zm/client/mta_queue_item/mta_queue_item.rb +5 -3
- data/lib/zm/client/mta_queue_item/mta_queue_item_jsns_initializer.rb +1 -5
- data/lib/zm/client/mta_queue_item/mta_queue_items_builder.rb +3 -1
- data/lib/zm/client/mta_queue_item/mta_queue_items_collection.rb +3 -1
- data/lib/zm/client/resource/resource.rb +6 -18
- data/lib/zm/client/resource/resource_jsns_builder.rb +20 -13
- data/lib/zm/client/resource/resource_jsns_initializer.rb +4 -14
- data/lib/zm/client/resource/resources_builder.rb +1 -1
- data/lib/zm/client/resource/resources_collection.rb +12 -7
- data/lib/zm/client/search_folder/search_folder.rb +13 -29
- data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +6 -6
- data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +19 -18
- data/lib/zm/client/search_folder/search_folders_builder.rb +1 -1
- data/lib/zm/client/search_folder/search_folders_collection.rb +6 -5
- data/lib/zm/client/server/server.rb +9 -3
- data/lib/zm/client/server/server_accounts_collection.rb +4 -2
- data/lib/zm/client/server/server_jsns_initializer.rb +1 -5
- data/lib/zm/client/server/servers_builder.rb +1 -1
- data/lib/zm/client/server/servers_collection.rb +17 -9
- data/lib/zm/client/share/share.rb +5 -3
- data/lib/zm/client/share/share_jsns_initializer.rb +15 -14
- data/lib/zm/client/share/share_mountpoints_collection.rb +3 -6
- data/lib/zm/client/share/shares_builder.rb +1 -1
- data/lib/zm/client/share/shares_collection.rb +6 -3
- data/lib/zm/client/signature/signature.rb +6 -21
- data/lib/zm/client/signature/signature_jsns_builder.rb +12 -7
- data/lib/zm/client/signature/signature_jsns_initializer.rb +5 -4
- data/lib/zm/client/signature/signatures_builder.rb +1 -1
- data/lib/zm/client/signature/signatures_collection.rb +6 -5
- data/lib/zm/client/soap_request/request_methods_admin.rb +56 -0
- data/lib/zm/client/soap_request/request_methods_mailbox.rb +60 -0
- data/lib/zm/client/soap_request/soap_constants.rb +7 -0
- data/lib/zm/client/soap_request/soap_context.rb +11 -2
- data/lib/zm/client/soap_request.rb +3 -0
- data/lib/zm/client/tag/account_object_tags_collection.rb +11 -9
- data/lib/zm/client/tag/tag.rb +8 -44
- data/lib/zm/client/tag/tag_jsns_builder.rb +4 -2
- data/lib/zm/client/tag/tag_jsns_initializer.rb +7 -6
- data/lib/zm/client/tag/tags_builder.rb +1 -1
- data/lib/zm/client/tag/tags_collection.rb +6 -5
- data/lib/zm/client/task/task.rb +6 -5
- data/lib/zm/client/task/task_jsns_initializer.rb +28 -27
- data/lib/zm/client/task/tasks_builder.rb +1 -1
- data/lib/zm/client/task/tasks_collection.rb +2 -2
- data/lib/zm/client/token.rb +52 -0
- data/lib/zm/client/upload/upload.rb +101 -95
- data/lib/zm/client/zm_logger.rb +83 -0
- data/lib/zm/client.rb +6 -1
- data/lib/zm/modules/base.rb +0 -1
- data/lib/zm/modules/belongs_to_folder.rb +6 -7
- data/lib/zm/modules/belongs_to_tag.rb +3 -1
- data/lib/zm/modules/common/zimbra-attrs.csv +3 -4
- data/lib/zm/modules/inspector.rb +2 -2
- data/lib/zm/modules/missing_method_static_collection.rb +2 -2
- data/lib/zm/support/cache/entry.rb +63 -0
- data/lib/zm/support/cache/file_store.rb +141 -0
- data/lib/zm/support/cache/null_store.rb +43 -0
- data/lib/zm/support/cache/request_strategy.rb +10 -0
- data/lib/zm/support/cache/store.rb +197 -0
- data/lib/zm/support/cache/strategy.rb +13 -0
- data/lib/zm/support/cache.rb +26 -0
- data/lib/zm-ruby-client.rb +2 -2
- data/zm-ruby-client.gemspec +10 -15
- metadata +37 -36
- data/lib/zm/client/common/token_metadata.rb +0 -44
- data/lib/zm/modules/zm_logger.rb +0 -26
|
@@ -7,14 +7,15 @@ module Zm
|
|
|
7
7
|
def initialize(parent)
|
|
8
8
|
@child_class = Identity
|
|
9
9
|
@builder_class = IdentitiesBuilder
|
|
10
|
-
super
|
|
10
|
+
super
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
private
|
|
14
|
-
|
|
15
13
|
def make_query
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
@parent.soap_connector.invoke(build_query)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def build_query
|
|
18
|
+
SoapElement.account(SoapAccountConstants::GET_IDENTITIES_REQUEST)
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
end
|
|
@@ -4,43 +4,25 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
# class account identity
|
|
6
6
|
class Identity < Base::Object
|
|
7
|
+
include RequestMethodsMailbox
|
|
8
|
+
|
|
7
9
|
attr_accessor :id, :name, :zimbraPrefIdentityName, :zimbraPrefFromDisplay, :zimbraPrefFromAddress,
|
|
8
10
|
:zimbraPrefFromAddressType, :zimbraPrefReplyToEnabled, :zimbraPrefReplyToDisplay,
|
|
9
11
|
:zimbraPrefReplyToAddress, :zimbraPrefDefaultSignatureId, :zimbraPrefForwardReplySignatureId,
|
|
10
12
|
:zimbraPrefWhenSentToEnabled, :zimbraPrefWhenInFoldersEnabled, :zimbraPrefWhenSentToAddresses
|
|
11
13
|
|
|
12
14
|
def create!
|
|
13
|
-
rep = @parent.
|
|
15
|
+
rep = @parent.soap_connector.invoke(build_create)
|
|
14
16
|
IdentityJsnsInitializer.update(self, rep[:CreateIdentityResponse][:identity].first)
|
|
15
17
|
@id
|
|
16
18
|
end
|
|
17
19
|
|
|
18
|
-
def
|
|
19
|
-
@parent.sacc.invoke(jsns_builder.to_update)
|
|
20
|
-
true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def update!(hash)
|
|
24
|
-
return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?
|
|
25
|
-
|
|
26
|
-
do_update!(hash)
|
|
27
|
-
|
|
28
|
-
hash.each do |key, value|
|
|
29
|
-
update_attribute(key, value)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
true
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def rename!(new_name)
|
|
20
|
+
def rename!(*args)
|
|
36
21
|
raise NotImplementedError
|
|
37
22
|
end
|
|
38
23
|
|
|
39
|
-
def
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@parent.sacc.invoke(jsns_builder.to_delete)
|
|
43
|
-
@id = nil
|
|
24
|
+
def build_rename(*args)
|
|
25
|
+
raise NotImplementedError
|
|
44
26
|
end
|
|
45
27
|
|
|
46
28
|
def clone
|
|
@@ -55,12 +37,10 @@ module Zm
|
|
|
55
37
|
|
|
56
38
|
private
|
|
57
39
|
|
|
58
|
-
def do_update!(hash)
|
|
59
|
-
@parent.sacc.invoke(jsns_builder.to_patch(hash))
|
|
60
|
-
end
|
|
61
|
-
|
|
62
40
|
def jsns_builder
|
|
63
|
-
@jsns_builder
|
|
41
|
+
return @jsns_builder if defined? @jsns_builder
|
|
42
|
+
|
|
43
|
+
@jsns_builder = IdentityJsnsBuilder.new(self)
|
|
64
44
|
end
|
|
65
45
|
end
|
|
66
46
|
end
|
|
@@ -10,28 +10,32 @@ module Zm
|
|
|
10
10
|
|
|
11
11
|
def to_jsns
|
|
12
12
|
soap_request = SoapElement.account(SoapAccountConstants::CREATE_IDENTITY_REQUEST)
|
|
13
|
-
node_identity = SoapElement.create(SoapConstants::IDENTITY)
|
|
13
|
+
node_identity = SoapElement.create(SoapConstants::IDENTITY)
|
|
14
|
+
.add_attributes({ name: @item.name, _attrs: attrs })
|
|
14
15
|
soap_request.add_node(node_identity)
|
|
15
16
|
soap_request
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def to_update
|
|
19
20
|
soap_request = SoapElement.account(SoapAccountConstants::MODIFY_IDENTITY_REQUEST)
|
|
20
|
-
node_identity = SoapElement.create(SoapConstants::IDENTITY)
|
|
21
|
+
node_identity = SoapElement.create(SoapConstants::IDENTITY)
|
|
22
|
+
.add_attributes({ id: @item.id, _attrs: attrs })
|
|
21
23
|
soap_request.add_node(node_identity)
|
|
22
24
|
soap_request
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def to_patch(hash)
|
|
26
28
|
soap_request = SoapElement.account(SoapAccountConstants::MODIFY_IDENTITY_REQUEST)
|
|
27
|
-
node_identity = SoapElement.create(SoapConstants::IDENTITY)
|
|
29
|
+
node_identity = SoapElement.create(SoapConstants::IDENTITY)
|
|
30
|
+
.add_attributes({ id: @item.id, _attrs: hash })
|
|
28
31
|
soap_request.add_node(node_identity)
|
|
29
32
|
soap_request
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
def to_delete
|
|
33
36
|
soap_request = SoapElement.account(SoapAccountConstants::DELETE_IDENTITY_REQUEST)
|
|
34
|
-
node_identity = SoapElement.create(SoapConstants::IDENTITY)
|
|
37
|
+
node_identity = SoapElement.create(SoapConstants::IDENTITY)
|
|
38
|
+
.add_attributes({ id: @item.id })
|
|
35
39
|
soap_request.add_node(node_identity)
|
|
36
40
|
soap_request
|
|
37
41
|
end
|
|
@@ -6,13 +6,14 @@ module Zm
|
|
|
6
6
|
class IdentityJsnsInitializer
|
|
7
7
|
class << self
|
|
8
8
|
def create(parent, json)
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
Identity.new(parent).tap do |item|
|
|
10
|
+
update(item, json)
|
|
11
|
+
end
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def update(item, json)
|
|
14
|
-
item.id = json
|
|
15
|
-
item.name = json
|
|
15
|
+
item.id = json.delete(:id)
|
|
16
|
+
item.name = json.delete(:name)
|
|
16
17
|
|
|
17
18
|
return item if json[:_attrs].nil? || json[:_attrs].empty?
|
|
18
19
|
|
|
@@ -10,7 +10,13 @@ module Zm
|
|
|
10
10
|
:IssuedToEmail, :IssuedToName, :LicenseId, :MAPIConnectorAccountsLimit, :MobileSyncAccountsLimit,
|
|
11
11
|
:MobileSyncEnabled, :ResellerName, :SMIMEAccountsLimit, :TouchClientsAccountsLimit,
|
|
12
12
|
:TwoFactorAuthAccountsLimit, :ValidFrom, :ValidUntil, :VoiceAccountsLimit, :ZSSAccountsLimit,
|
|
13
|
-
:ZTalkAccountsLimit
|
|
13
|
+
:ZTalkAccountsLimit, :AttachmentIndexingEnabled, :BasicOneToOneChatAccountsLimit,
|
|
14
|
+
:BriefcaseAccountsLimit, :CalenderAccountsLimit, :ChatAccountsLimit, :ChatVideoAccountsLimit,
|
|
15
|
+
:ConversationEnabledAccountsLimit, :DelegatedAdminAccountsLimit, :DocumentEditingAccountsLimit,
|
|
16
|
+
:FeaturesOnHold, :GroupCalenderAccountsLimit, :ManageZimletsEnabledAccountsLimit,
|
|
17
|
+
:MultiFactorAuthEnabled, :ObjectStoreSupportEnabled, :SharingAccountsLimit,
|
|
18
|
+
:StorageManagementEnabled, :TaggingEnabledAccountsLimit, :TaskEnabledAccountsLimit,
|
|
19
|
+
:ViewInHtmlEnabledAccountsLimit
|
|
14
20
|
end
|
|
15
21
|
end
|
|
16
22
|
end
|
|
@@ -6,13 +6,16 @@ module Zm
|
|
|
6
6
|
class LicenseJsnsInitializer
|
|
7
7
|
class << self
|
|
8
8
|
def create(parent, json)
|
|
9
|
-
|
|
9
|
+
License.new(parent).tap do |item|
|
|
10
|
+
json[:attr].each do |a|
|
|
11
|
+
setter = "#{a.delete(:name)}="
|
|
12
|
+
value = a.dig(:maxLimit, :_content) || a.delete(:_content)
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
if item.respond_to?(setter)
|
|
15
|
+
item.send(setter, value)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
13
18
|
end
|
|
14
|
-
|
|
15
|
-
item
|
|
16
19
|
end
|
|
17
20
|
end
|
|
18
21
|
end
|
|
@@ -10,7 +10,7 @@ module Zm
|
|
|
10
10
|
|
|
11
11
|
def find
|
|
12
12
|
soap_request = SoapElement.admin(SoapAdminConstants::GET_LICENSE_REQUEST)
|
|
13
|
-
entry =
|
|
13
|
+
entry = @parent.soap_admin_connector.invoke(soap_request)[:GetLicenseResponse][:license].first
|
|
14
14
|
LicenseJsnsInitializer.create(@parent, entry)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'mailbox_item_id'
|
|
4
|
+
|
|
5
|
+
module Zm
|
|
6
|
+
module Client
|
|
7
|
+
module MailboxItemConcern
|
|
8
|
+
def id=(remote_id)
|
|
9
|
+
parts = remote_id.to_s.split(':').reverse
|
|
10
|
+
parts << nil if parts.length == 1
|
|
11
|
+
@id = MailboxItemID.new(*parts)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def id
|
|
15
|
+
return nil unless defined? @id
|
|
16
|
+
|
|
17
|
+
@id.item_id
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def mailbox_id
|
|
21
|
+
return nil unless defined? @id
|
|
22
|
+
|
|
23
|
+
@id.mailbox_id
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def l=(remote_l)
|
|
27
|
+
@l = remote_l.to_s.split(':').last
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
attr_reader :l
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -40,9 +40,9 @@ module Zm
|
|
|
40
40
|
|
|
41
41
|
url = account.home_url
|
|
42
42
|
|
|
43
|
-
url << '?' <<
|
|
43
|
+
url << '?' << h.map { |k, v| "#{k}=#{v}" }.join('&')
|
|
44
44
|
|
|
45
|
-
uploader =
|
|
45
|
+
uploader = @parent.build_uploader
|
|
46
46
|
uploader.download_file_with_url(url, dest_file_path)
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -6,8 +6,11 @@ module Zm
|
|
|
6
6
|
class Message < Base::Object
|
|
7
7
|
include BelongsToFolder
|
|
8
8
|
include BelongsToTag
|
|
9
|
+
include RequestMethodsMailbox
|
|
10
|
+
include MailboxItemConcern
|
|
9
11
|
|
|
10
|
-
attr_accessor :
|
|
12
|
+
attr_accessor :d, :f, :su, :fr, :autoSendTime, :mid, :idnt, :tn, :subject, :s
|
|
13
|
+
attr_reader :recipients, :attachments, :body
|
|
11
14
|
|
|
12
15
|
alias size s
|
|
13
16
|
|
|
@@ -15,94 +18,97 @@ module Zm
|
|
|
15
18
|
@parent = parent
|
|
16
19
|
@subject = ''
|
|
17
20
|
|
|
18
|
-
yield(self) if block_given?
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def recipients
|
|
22
|
-
return @recipients if defined? @recipients
|
|
23
|
-
|
|
24
21
|
@recipients = Recipients.new
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def attachments
|
|
28
|
-
return @attachments if defined? @attachments
|
|
29
|
-
|
|
22
|
+
@body = Body.new
|
|
30
23
|
@attachments = AttachmentsCollection.new
|
|
31
|
-
end
|
|
32
24
|
|
|
33
|
-
|
|
34
|
-
return @body if defined? @body
|
|
35
|
-
|
|
36
|
-
@body = Body.new
|
|
25
|
+
yield(self) if block_given?
|
|
37
26
|
end
|
|
38
27
|
|
|
39
|
-
def download(dest_file_path, fmt
|
|
40
|
-
uploader =
|
|
41
|
-
uploader.download_file(
|
|
28
|
+
def download(dest_file_path, fmt: 'eml')
|
|
29
|
+
uploader = @parent.build_uploader
|
|
30
|
+
uploader.download_file(dest_file_path, id, FolderView::MESSAGE, fmt:)
|
|
42
31
|
end
|
|
43
32
|
|
|
44
|
-
def read
|
|
45
|
-
uploader =
|
|
46
|
-
uploader.read_file(
|
|
33
|
+
def read
|
|
34
|
+
uploader = @parent.build_uploader
|
|
35
|
+
uploader.read_file(id, FolderView::MESSAGE, fmt: 'eml')
|
|
47
36
|
end
|
|
48
37
|
|
|
49
38
|
def date
|
|
50
|
-
@date
|
|
39
|
+
return @date if defined? @date
|
|
40
|
+
|
|
41
|
+
@date = Time.at(d.to_i / 1000)
|
|
51
42
|
end
|
|
52
43
|
|
|
53
44
|
def flags
|
|
54
|
-
@flags
|
|
45
|
+
return @flags if defined? @flags
|
|
46
|
+
|
|
47
|
+
@flags = FlagsCollection.new(self)
|
|
55
48
|
end
|
|
56
49
|
|
|
57
50
|
def create!(*args)
|
|
58
51
|
raise NotImplementedError
|
|
59
52
|
end
|
|
60
53
|
|
|
54
|
+
def build_create
|
|
55
|
+
raise NotImplementedError
|
|
56
|
+
end
|
|
57
|
+
|
|
61
58
|
def modify!(*args)
|
|
62
59
|
raise NotImplementedError
|
|
63
60
|
end
|
|
64
61
|
|
|
65
|
-
def
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
tn: tn
|
|
74
|
-
}
|
|
62
|
+
def build_modify
|
|
63
|
+
raise NotImplementedError
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def update!(attrs)
|
|
67
|
+
authorized_keys = %i[l rgb color f tn]
|
|
68
|
+
|
|
69
|
+
attrs.reject! { |k| !authorized_keys.include?(k) }
|
|
75
70
|
|
|
76
|
-
attrs.
|
|
71
|
+
attrs.merge!({ op: :update, id: id })
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
attrs.compact!
|
|
74
|
+
|
|
75
|
+
soap_request = SoapElement.mail(SoapMailConstants::ITEM_ACTION_REQUEST)
|
|
79
76
|
node_action = SoapElement.create(SoapConstants::ACTION).add_attributes(attrs)
|
|
80
77
|
soap_request.add_node(node_action)
|
|
81
|
-
@parent.
|
|
78
|
+
@parent.soap_connector.invoke(soap_request)
|
|
82
79
|
end
|
|
83
80
|
|
|
84
81
|
def rename!(*args)
|
|
85
82
|
raise NotImplementedError
|
|
86
83
|
end
|
|
87
84
|
|
|
88
|
-
def
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
@parent.sacc.invoke(jsns_builder.to_delete)
|
|
92
|
-
@id = nil
|
|
85
|
+
def build_rename(*args)
|
|
86
|
+
raise NotImplementedError
|
|
93
87
|
end
|
|
94
88
|
|
|
95
89
|
def unspam!
|
|
96
|
-
@parent.
|
|
90
|
+
@parent.soap_connector.invoke(build_unspam)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def build_unspam
|
|
94
|
+
jsns_builder.to_unspam
|
|
97
95
|
end
|
|
98
96
|
|
|
99
97
|
def spam!
|
|
100
|
-
@parent.
|
|
98
|
+
@parent.soap_connector.invoke(build_spam)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def build_spam
|
|
102
|
+
jsns_builder.to_spam
|
|
101
103
|
end
|
|
102
104
|
|
|
103
105
|
def send!
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
@parent.soap_connector.invoke(build_send)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def build_send
|
|
110
|
+
SoapElement.mail(SoapMailConstants::SEND_MSG_REQUEST)
|
|
111
|
+
.add_attributes(jsns_builder.to_jsns)
|
|
106
112
|
end
|
|
107
113
|
|
|
108
114
|
# content fo an email
|
|
@@ -110,12 +116,10 @@ module Zm
|
|
|
110
116
|
attr_accessor :text, :html
|
|
111
117
|
end
|
|
112
118
|
|
|
113
|
-
def sacc
|
|
114
|
-
@parent.sacc
|
|
115
|
-
end
|
|
116
|
-
|
|
117
119
|
def jsns_builder
|
|
118
|
-
@jsns_builder
|
|
120
|
+
return @jsns_builder if defined? @jsns_builder
|
|
121
|
+
|
|
122
|
+
@jsns_builder = MessageJsnsBuilder.new(self)
|
|
119
123
|
end
|
|
120
124
|
end
|
|
121
125
|
end
|
|
@@ -10,11 +10,7 @@ module Zm
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def all
|
|
13
|
-
@all
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def all!
|
|
17
|
-
@parent.f.to_s.chars
|
|
13
|
+
@all ||= @parent.f.to_s.chars
|
|
18
14
|
end
|
|
19
15
|
|
|
20
16
|
# properties
|
|
@@ -74,23 +70,35 @@ module Zm
|
|
|
74
70
|
# actions
|
|
75
71
|
|
|
76
72
|
def unread!
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
@parent.soap_connector.invoke(build_unread)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def build_unread
|
|
77
|
+
build({ op: '!read', id: @parent.id })
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
def read!
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
@parent.soap_connector.invoke(build_read)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def build_read
|
|
85
|
+
build({ op: 'read', id: @parent.id })
|
|
84
86
|
end
|
|
85
87
|
|
|
86
88
|
def unflag!
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
@parent.soap_connector.invoke(build_unflag)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def build_unflag
|
|
93
|
+
build({ op: '!flag', id: @parent.id })
|
|
89
94
|
end
|
|
90
95
|
|
|
91
96
|
def flag!
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
@parent.soap_connector.invoke(build_flag)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def build_flag
|
|
101
|
+
build({ op: 'flag', id: @parent.id })
|
|
94
102
|
end
|
|
95
103
|
|
|
96
104
|
private
|
|
@@ -15,16 +15,17 @@ module Zm
|
|
|
15
15
|
e: recipients_jsns,
|
|
16
16
|
su: { _content: @item.su },
|
|
17
17
|
mp: body_jsns
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
|
+
jsns.compact!
|
|
19
20
|
|
|
20
|
-
jsns[:did] = @item.id if @item.l.to_i == FolderDefault::DRAFTS
|
|
21
|
+
jsns[:did] = @item.id if @item.l.to_i == FolderDefault::DRAFTS.id
|
|
21
22
|
|
|
22
23
|
jsns
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def attachments_jsns
|
|
26
27
|
@item.attachments.all.map do |attachment|
|
|
27
|
-
{
|
|
28
|
+
h = {
|
|
28
29
|
part: attachment.part,
|
|
29
30
|
mid: attachment.mid,
|
|
30
31
|
aid: attachment.aid,
|
|
@@ -33,7 +34,9 @@ module Zm
|
|
|
33
34
|
filename: attachment.filename,
|
|
34
35
|
ci: attachment.ci,
|
|
35
36
|
cd: attachment.cd
|
|
36
|
-
}
|
|
37
|
+
}
|
|
38
|
+
h.compact!
|
|
39
|
+
h
|
|
37
40
|
end
|
|
38
41
|
end
|
|
39
42
|
|
|
@@ -41,11 +44,13 @@ module Zm
|
|
|
41
44
|
return nil if @item.recipients.all.empty?
|
|
42
45
|
|
|
43
46
|
@item.recipients.all.map do |recipient|
|
|
44
|
-
{
|
|
47
|
+
h = {
|
|
45
48
|
t: recipient.field,
|
|
46
49
|
a: recipient.email,
|
|
47
50
|
p: recipient.display_name
|
|
48
|
-
}
|
|
51
|
+
}
|
|
52
|
+
h.compact!
|
|
53
|
+
h
|
|
49
54
|
end
|
|
50
55
|
end
|
|
51
56
|
|
|
@@ -6,29 +6,30 @@ module Zm
|
|
|
6
6
|
class MessageJsnsInitializer
|
|
7
7
|
class << self
|
|
8
8
|
def create(parent, json)
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
Message.new(parent).tap do |item|
|
|
10
|
+
update(item, json)
|
|
11
|
+
end
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def update(item, json)
|
|
14
|
-
item.id = json
|
|
15
|
-
item.d = json
|
|
16
|
-
item.l = json
|
|
17
|
-
item.su = json
|
|
18
|
-
item.fr = json
|
|
19
|
-
item.autoSendTime = json
|
|
20
|
-
item.mid = json
|
|
21
|
-
item.idnt = json
|
|
22
|
-
item.f = json
|
|
23
|
-
item.tn = json
|
|
24
|
-
item.s = json
|
|
15
|
+
item.id = json.delete(:id)
|
|
16
|
+
item.d = json.delete(:d)
|
|
17
|
+
item.l = json.delete(:l)
|
|
18
|
+
item.su = json.delete(:su)
|
|
19
|
+
item.fr = json.delete(:fr)
|
|
20
|
+
item.autoSendTime = json.delete(:autoSendTime)
|
|
21
|
+
item.mid = json.delete(:mid)
|
|
22
|
+
item.idnt = json.delete(:idnt)
|
|
23
|
+
item.f = json.delete(:f)
|
|
24
|
+
item.tn = json.delete(:tn)
|
|
25
|
+
item.s = json.delete(:s)
|
|
25
26
|
|
|
26
27
|
json[:e].each do |e|
|
|
27
|
-
recipient = Recipient.new(e
|
|
28
|
+
recipient = Recipient.new(e.delete(:t), e.delete(:a), e.delete(:p))
|
|
28
29
|
item.recipients.add(recipient)
|
|
29
30
|
end
|
|
30
31
|
|
|
31
|
-
update_mps(item, json
|
|
32
|
+
update_mps(item, json.delete(:mp))
|
|
32
33
|
|
|
33
34
|
item
|
|
34
35
|
end
|
|
@@ -56,14 +57,14 @@ module Zm
|
|
|
56
57
|
|
|
57
58
|
def update_attachment(item, json)
|
|
58
59
|
pj = Zm::Client::Message::Attachment.new(self)
|
|
59
|
-
pj.mid = json
|
|
60
|
-
pj.aid = json
|
|
61
|
-
pj.ct = json
|
|
62
|
-
pj.s = json
|
|
63
|
-
pj.filename = json
|
|
64
|
-
pj.ci = json
|
|
65
|
-
pj.cd = json
|
|
66
|
-
pj.part = json
|
|
60
|
+
pj.mid = json.delete(:mid)
|
|
61
|
+
pj.aid = json.delete(:aid)
|
|
62
|
+
pj.ct = json.delete(:ct)
|
|
63
|
+
pj.s = json.delete(:s)
|
|
64
|
+
pj.filename = json.delete(:filename)
|
|
65
|
+
pj.ci = json.delete(:ci)
|
|
66
|
+
pj.cd = json.delete(:cd)
|
|
67
|
+
pj.part = json.delete(:part)
|
|
67
68
|
item.attachments.add(pj)
|
|
68
69
|
end
|
|
69
70
|
end
|
|
@@ -5,7 +5,7 @@ module Zm
|
|
|
5
5
|
# Collection Messages
|
|
6
6
|
class MessagesCollection < Base::AccountSearchObjectsCollection
|
|
7
7
|
def initialize(parent)
|
|
8
|
-
super
|
|
8
|
+
super
|
|
9
9
|
@child_class = Message
|
|
10
10
|
@builder_class = MessagesBuilder
|
|
11
11
|
@type = SoapConstants::MESSAGE
|
|
@@ -23,20 +23,6 @@ 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
|
-
|
|
40
26
|
private
|
|
41
27
|
|
|
42
28
|
def build_options
|