zm-ruby-client 0.18.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +2 -2
- data/README.md +7 -0
- data/lib/zm/client/account/account.rb +31 -308
- data/lib/zm/client/account/account_aliases_collection.rb +52 -0
- data/lib/zm/client/account/account_dls_membership_collection.rb +4 -1
- data/lib/zm/client/account/account_dls_owner_collection.rb +8 -1
- data/lib/zm/client/account/account_jsns_builder.rb +77 -0
- data/lib/zm/client/account/account_jsns_initializer.rb +9 -24
- data/lib/zm/client/account/accounts_builder.rb +0 -1
- data/lib/zm/client/account/accounts_collection.rb +32 -8
- data/lib/zm/client/account.rb +1 -0
- data/lib/zm/client/ace/ace.rb +6 -22
- data/lib/zm/client/ace/ace_jsns_builder.rb +15 -16
- data/lib/zm/client/ace/ace_jsns_initializer.rb +0 -1
- data/lib/zm/client/ace/aces_builder.rb +0 -1
- data/lib/zm/client/ace/aces_collection.rb +2 -18
- data/lib/zm/client/appointment/appointment.rb +38 -30
- data/lib/zm/client/appointment/appointment_jsns_builder.rb +22 -34
- data/lib/zm/client/appointment/appointment_jsns_initializer.rb +6 -3
- data/lib/zm/client/appointment/appointments_builder.rb +6 -18
- data/lib/zm/client/appointment/appointments_collection.rb +25 -4
- data/lib/zm/client/backup/backup.rb +4 -32
- data/lib/zm/client/backup/backup_jsns_initializer.rb +26 -0
- data/lib/zm/client/backup/backups_builder.rb +8 -13
- data/lib/zm/client/backup/backups_collection.rb +2 -1
- data/lib/zm/client/backup.rb +1 -0
- data/lib/zm/client/base/account_search_objects_collection.rb +34 -13
- data/lib/zm/client/base/admin_objects_collection.rb +82 -17
- data/lib/zm/client/base/base_account_jsns_builder.rb +98 -0
- data/lib/zm/client/base/base_jsns_builder.rb +47 -0
- data/lib/zm/client/base/base_jsns_initializer.rb +43 -12
- data/lib/zm/client/base/ldap_filter.rb +20 -5
- data/lib/zm/client/base/mailbox_infos_collection.rb +68 -0
- data/lib/zm/client/base/mailbox_object.rb +299 -0
- data/lib/zm/client/base/mailbox_prefs_collection.rb +75 -0
- data/lib/zm/client/base/object.rb +28 -62
- data/lib/zm/client/base/objects_builder.rb +4 -10
- data/lib/zm/client/base/objects_collection.rb +13 -10
- data/lib/zm/client/base/zimbra_attribute.rb +10 -8
- data/lib/zm/client/base/zimbra_attributes_collection.rb +154 -10
- data/lib/zm/client/base.rb +5 -5
- data/lib/zm/client/cluster/cluster.rb +43 -39
- data/lib/zm/client/cluster/cluster_config.rb +5 -5
- data/lib/zm/client/common/recipients.rb +3 -3
- data/lib/zm/client/common/token_metadata.rb +4 -1
- data/lib/zm/client/common/utils.rb +57 -0
- data/lib/zm/client/common.rb +2 -1
- data/lib/zm/client/connector/rest_account.rb +15 -28
- data/lib/zm/client/connector/soap_account.rb +38 -441
- data/lib/zm/client/connector/soap_admin.rb +16 -552
- data/lib/zm/client/connector/soap_base.rb +30 -21
- data/lib/zm/client/connector/soap_error.rb +1 -3
- data/lib/zm/client/constant.rb +21 -11
- data/lib/zm/client/contact/contact.rb +42 -83
- data/lib/zm/client/contact/contact_jsns_builder.rb +60 -0
- data/lib/zm/client/contact/contact_jsns_initializer.rb +78 -0
- data/lib/zm/client/contact/contact_member.rb +29 -28
- data/lib/zm/client/contact/contact_members_collection.rb +44 -0
- data/lib/zm/client/contact/contacts_builder.rb +8 -1
- data/lib/zm/client/contact/contacts_collection.rb +17 -1
- data/lib/zm/client/contact/group_contact_jsns_builder.rb +51 -0
- data/lib/zm/client/contact/mod_group_contact.rb +4 -67
- data/lib/zm/client/contact.rb +5 -1
- data/lib/zm/client/cos/cos.rb +35 -40
- data/lib/zm/client/cos/cos_accounts_collection.rb +19 -0
- data/lib/zm/client/cos/cos_domains_collection.rb +20 -0
- data/lib/zm/client/cos/cos_jsns_builder.rb +72 -0
- data/lib/zm/client/cos/cos_jsns_initializer.rb +29 -0
- data/lib/zm/client/cos/cos_servers_collection.rb +60 -0
- data/lib/zm/client/cos/coses_builder.rb +8 -1
- data/lib/zm/client/cos/coses_collection.rb +8 -5
- data/lib/zm/client/cos.rb +5 -0
- data/lib/zm/client/datasource/datasource.rb +69 -0
- data/lib/zm/client/datasource/datasource_jsns_builder.rb +32 -0
- data/lib/zm/client/datasource/datasource_jsns_initializer.rb +27 -0
- data/lib/zm/client/datasource/datasources_builder.rb +29 -0
- data/lib/zm/client/datasource/datasources_collection.rb +21 -0
- data/lib/zm/client/datasource.rb +7 -0
- data/lib/zm/client/distributionlist/distributionlist.rb +52 -118
- data/lib/zm/client/distributionlist/distributionlist_aces_collection.rb +31 -0
- data/lib/zm/client/distributionlist/distributionlist_aliases_collection.rb +53 -0
- data/lib/zm/client/distributionlist/distributionlist_jsns_builder.rb +82 -0
- data/lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb +32 -0
- data/lib/zm/client/distributionlist/distributionlist_members_collection.rb +47 -0
- data/lib/zm/client/distributionlist/distributionlist_owners_collection.rb +52 -0
- data/lib/zm/client/distributionlist/distributionlists_builder.rb +8 -1
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +8 -9
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +4 -1
- data/lib/zm/client/distributionlist.rb +2 -0
- data/lib/zm/client/document/document.rb +27 -24
- data/lib/zm/client/document/document_jsns_builder.rb +18 -0
- data/lib/zm/client/document/document_jsns_initializer.rb +44 -0
- data/lib/zm/client/document/documents_builder.rb +6 -16
- data/lib/zm/client/document/documents_collection.rb +17 -67
- data/lib/zm/client/document.rb +2 -0
- data/lib/zm/client/domain/domain.rb +39 -55
- data/lib/zm/client/domain/domain_accounts_collection.rb +1 -1
- data/lib/zm/client/domain/domain_distributionlists_collection.rb +13 -0
- data/lib/zm/client/domain/domain_jsns_builder.rb +69 -0
- data/lib/zm/client/domain/domain_jsns_initializer.rb +25 -0
- data/lib/zm/client/domain/domain_resources_collection.rb +13 -0
- data/lib/zm/client/domain/domains_builder.rb +8 -1
- data/lib/zm/client/domain/domains_collection.rb +7 -7
- data/lib/zm/client/domain.rb +4 -0
- data/lib/zm/client/filter_rule.rb +7 -0
- data/lib/zm/client/filter_rules/filter_rule.rb +10 -0
- data/lib/zm/client/filter_rules/filter_rule_jsns_initializer.rb +24 -0
- data/lib/zm/client/filter_rules/filter_rules_builder.rb +21 -0
- data/lib/zm/client/filter_rules/filter_rules_collection.rb +21 -0
- data/lib/zm/client/filter_rules/outgoing_filter_rules_collection.rb +15 -0
- data/lib/zm/client/folder/folder.rb +77 -61
- data/lib/zm/client/folder/folder_grant.rb +34 -14
- data/lib/zm/client/folder/folder_grant_jsns_builder.rb +15 -4
- data/lib/zm/client/folder/folder_grants_collection.rb +36 -2
- data/lib/zm/client/folder/folder_jsns_builder.rb +22 -48
- data/lib/zm/client/folder/folder_jsns_initializer.rb +34 -17
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +2 -3
- data/lib/zm/client/folder/folder_retention_policy.rb +0 -1
- data/lib/zm/client/folder/folders_builder.rb +7 -10
- data/lib/zm/client/folder/folders_collection.rb +5 -2
- data/lib/zm/client/folder/folders_jsns_builder.rb +3 -1
- data/lib/zm/client/folder/mod_document_folder.rb +10 -6
- data/lib/zm/client/folder.rb +1 -1
- data/lib/zm/client/identity/identities_builder.rb +8 -1
- data/lib/zm/client/identity/identities_collection.rb +2 -1
- data/lib/zm/client/identity/identity.rb +34 -42
- data/lib/zm/client/identity/identity_jsns_builder.rb +57 -0
- data/lib/zm/client/identity/identity_jsns_initializer.rb +29 -0
- data/lib/zm/client/identity.rb +3 -1
- data/lib/zm/client/license/license.rb +9 -22
- data/lib/zm/client/license/license_jsns_initializer.rb +20 -0
- data/lib/zm/client/license/licenses_collection.rb +3 -13
- data/lib/zm/client/license.rb +2 -1
- data/lib/zm/client/message/attachments_collection.rb +55 -0
- data/lib/zm/client/message/message.rb +36 -264
- data/lib/zm/client/message/message_flags.rb +107 -0
- data/lib/zm/client/message/message_jsns_builder.rb +85 -0
- data/lib/zm/client/message/message_jsns_initializer.rb +71 -0
- data/lib/zm/client/message/message_recipients.rb +59 -0
- data/lib/zm/client/message/messages_builder.rb +7 -18
- data/lib/zm/client/message/messages_collection.rb +17 -2
- data/lib/zm/client/message.rb +5 -0
- data/lib/zm/client/mountpoint/mountpoint.rb +43 -20
- data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +8 -53
- data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +22 -13
- data/lib/zm/client/mountpoint/mountpoints_builder.rb +4 -5
- data/lib/zm/client/mountpoint/mountpoints_collection.rb +1 -2
- data/lib/zm/client/mta_queue/mta_queue.rb +13 -28
- data/lib/zm/client/mta_queue/mta_queue_jsns_builder.rb +41 -0
- data/lib/zm/client/mta_queue/mta_queue_jsns_initializer.rb +23 -0
- data/lib/zm/client/mta_queue/mta_queues_builder.rb +4 -8
- data/lib/zm/client/mta_queue/mta_queues_collection.rb +8 -27
- data/lib/zm/client/mta_queue.rb +2 -0
- data/lib/zm/client/mta_queue_item/mta_queue_item.rb +4 -31
- data/lib/zm/client/mta_queue_item/mta_queue_item_jsns_initializer.rb +33 -0
- data/lib/zm/client/mta_queue_item/mta_queue_items_builder.rb +4 -9
- data/lib/zm/client/mta_queue_item/mta_queue_items_collection.rb +7 -42
- data/lib/zm/client/mta_queue_item.rb +2 -1
- data/lib/zm/client/resource/resource.rb +24 -91
- data/lib/zm/client/resource/resource_jsns_builder.rb +79 -0
- data/lib/zm/client/resource/resource_jsns_initializer.rb +29 -0
- data/lib/zm/client/resource/resources_builder.rb +8 -1
- data/lib/zm/client/resource/resources_collection.rb +9 -7
- data/lib/zm/client/resource.rb +2 -0
- data/lib/zm/client/search_folder/search_folder.rb +38 -16
- data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +38 -19
- data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +17 -13
- data/lib/zm/client/search_folder/search_folders_builder.rb +0 -1
- data/lib/zm/client/search_folder/search_folders_collection.rb +2 -1
- data/lib/zm/client/server/server.rb +16 -488
- data/lib/zm/client/server/server_jsns_initializer.rb +16 -0
- data/lib/zm/client/server/servers_builder.rb +8 -1
- data/lib/zm/client/server/servers_collection.rb +13 -5
- data/lib/zm/client/server.rb +1 -0
- data/lib/zm/client/share/share.rb +5 -43
- data/lib/zm/client/share/share_jsns_initializer.rb +32 -0
- data/lib/zm/client/share/share_mountpoints_collection.rb +38 -0
- data/lib/zm/client/share/shares_builder.rb +8 -1
- data/lib/zm/client/share/shares_collection.rb +11 -16
- data/lib/zm/client/share.rb +2 -0
- data/lib/zm/client/signature/signature.rb +25 -29
- data/lib/zm/client/signature/signature_jsns_builder.rb +31 -13
- data/lib/zm/client/signature/signature_jsns_initializer.rb +16 -12
- data/lib/zm/client/signature/signatures_builder.rb +1 -2
- data/lib/zm/client/signature/signatures_collection.rb +2 -1
- data/lib/zm/client/signature.rb +1 -1
- data/lib/zm/client/soap_request/account_soap_constants.rb +76 -0
- data/lib/zm/client/soap_request/admin_soap_constants.rb +214 -0
- data/lib/zm/client/soap_request/mail_soap_constants.rb +162 -0
- data/lib/zm/client/soap_request/soap_constants.rb +55 -0
- data/lib/zm/client/soap_request/soap_context.rb +38 -0
- data/lib/zm/client/soap_request/soap_element.rb +90 -0
- data/lib/zm/client/soap_request.rb +8 -0
- data/lib/zm/client/tag/account_object_tags_collection.rb +65 -0
- data/lib/zm/client/tag/tag.rb +34 -22
- data/lib/zm/client/tag/tag_jsns_builder.rb +14 -35
- data/lib/zm/client/tag/tag_jsns_initializer.rb +4 -6
- data/lib/zm/client/tag/tags_builder.rb +0 -1
- data/lib/zm/client/tag/tags_collection.rb +2 -1
- data/lib/zm/client/tag.rb +1 -0
- data/lib/zm/client/task/task.rb +18 -49
- data/lib/zm/client/task/task_jsns_initializer.rb +45 -0
- data/lib/zm/client/task/tasks_builder.rb +6 -16
- data/lib/zm/client/task/tasks_collection.rb +29 -0
- data/lib/zm/client/task.rb +1 -0
- data/lib/zm/client/upload/upload.rb +26 -30
- data/lib/zm/client/version.rb +3 -3
- data/lib/zm/client.rb +4 -1
- data/lib/zm/modules/base.rb +10 -0
- data/lib/zm/modules/belongs_to_folder.rb +37 -0
- data/lib/zm/modules/belongs_to_tag.rb +11 -0
- data/lib/zm/modules/common/zimbra-attrs.json +1 -1
- data/lib/zm/modules/has_soap_admin_connector.rb +12 -0
- data/lib/zm/modules/inspector.rb +24 -0
- data/lib/zm/modules/missing_method_static_collection.rb +13 -0
- data/lib/zm/modules/zm_logger.rb +3 -1
- data/lib/zm/modules/zm_model.rb +4 -2
- data/lib/zm/utils/thread_pool.rb +4 -2
- data/lib/zm-ruby-client.rb +2 -0
- data/zm-ruby-client.gemspec +12 -9
- metadata +93 -34
- data/lib/zm/client/base/account_object.rb +0 -51
- data/lib/zm/client/base/admin_object.rb +0 -51
- data/lib/zm/client/base/folder_object.rb +0 -41
- data/lib/zm/client/config.rb +0 -12
- data/lib/zm/client/data_source.rb +0 -5
- data/lib/zm/modules/common/account_common.rb +0 -71
- data/lib/zm/modules/common/cos_common.rb +0 -463
- data/lib/zm/modules/common/dl_common.rb +0 -38
- data/lib/zm/modules/common/identity_common.rb +0 -19
- data/lib/zm/modules/common/resource_common.rb +0 -59
- data/lib/zm/modules/common/signature_common.rb +0 -16
- data/lib/zm/modules/common/zimbra-attrs.json.bak +0 -1
- data/test/accounts.rb +0 -89
- data/test/ace.rb +0 -50
- data/test/cluster.rb +0 -41
- data/test/cluster_config.rb +0 -30
- data/test/cluster_zimbra_attributes.rb +0 -38
- data/test/coses.rb +0 -26
- data/test/domains.rb +0 -70
- data/test/folder.rb +0 -125
- data/test/folder_grant.rb +0 -51
- data/test/mountpoint.rb +0 -49
- data/test/retention_policies.rb +0 -40
- data/test/search_folder.rb +0 -67
- data/test/signature.rb +0 -53
- data/test/tag.rb +0 -65
- data/test/zimbra_attributes.rb +0 -35
@@ -6,470 +6,67 @@ require_relative 'soap_error'
|
|
6
6
|
module Zm
|
7
7
|
module Client
|
8
8
|
class SoapAccountConnector < SoapBaseConnector
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def auth_template(mail)
|
20
|
-
{
|
21
|
-
Body: {
|
22
|
-
AuthRequest: {
|
23
|
-
_jsns: ACCOUNTSPACE,
|
24
|
-
account: {
|
25
|
-
_content: mail,
|
26
|
-
by: :name
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def auth_preauth(mail, domainkey)
|
34
|
-
ts = (Time.now.to_i * 1000)
|
35
|
-
preauth = compute_preauth(mail, ts, domainkey)
|
36
|
-
body = auth_template(mail)
|
37
|
-
preauth_h = {
|
38
|
-
preauth: {
|
39
|
-
_content: preauth,
|
40
|
-
timestamp: ts
|
41
|
-
}
|
42
|
-
}
|
43
|
-
body[:Body][:AuthRequest].merge!(preauth_h)
|
44
|
-
do_auth(body)
|
45
|
-
end
|
46
|
-
|
47
|
-
def auth_password(mail, password)
|
48
|
-
body = auth_template(mail)
|
49
|
-
body[:Body][:AuthRequest].merge!({ password: password })
|
50
|
-
do_auth(body)
|
51
|
-
end
|
52
|
-
|
53
|
-
def do_auth(body)
|
54
|
-
res = curl_request(body, AuthError)
|
55
|
-
res[BODY][:AuthResponse][:authToken].first[:_content]
|
56
|
-
end
|
57
|
-
|
58
|
-
# -------------------------------
|
59
|
-
# APPOINTMENT
|
60
|
-
|
61
|
-
def get_appointment(token, id)
|
62
|
-
req = { id: id }
|
63
|
-
body = init_hash_request(token, :GetAppointmentRequest)
|
64
|
-
body[:Body][:GetAppointmentRequest].merge!(req)
|
65
|
-
curl_request(body)
|
66
|
-
end
|
67
|
-
|
68
|
-
def create_appointment(token, jsns)
|
69
|
-
soap_name = :CreateAppointmentRequest
|
70
|
-
body = init_hash_request(token, soap_name)
|
71
|
-
body[:Body][soap_name].merge!(jsns)
|
72
|
-
curl_request(body)
|
73
|
-
end
|
74
|
-
|
75
|
-
def modify_appointment(token, jsns)
|
76
|
-
soap_name = :ModifyAppointmentRequest
|
77
|
-
body = init_hash_request(token, soap_name)
|
78
|
-
body[:Body][soap_name].merge!(jsns)
|
79
|
-
curl_request(body)
|
80
|
-
end
|
81
|
-
|
82
|
-
def cancel_appointment(token, jsns)
|
83
|
-
soap_name = :CancelAppointmentRequest
|
84
|
-
body = init_hash_request(token, soap_name)
|
85
|
-
body[:Body][soap_name].merge!(jsns)
|
86
|
-
curl_request(body)
|
87
|
-
end
|
88
|
-
|
89
|
-
# -------------------------------
|
90
|
-
# CONTACT
|
91
|
-
|
92
|
-
def get_all_contacts(token, folder_id = nil)
|
93
|
-
body = init_hash_request(token, :GetContactsRequest)
|
94
|
-
unless folder_id.nil?
|
95
|
-
req = { l: folder_id }
|
96
|
-
body[:Body][:GetContactsRequest].merge!(req)
|
9
|
+
class << self
|
10
|
+
def create(config)
|
11
|
+
trans = new(
|
12
|
+
config.zimbra_public_scheme,
|
13
|
+
config.zimbra_public_host,
|
14
|
+
config.zimbra_public_port
|
15
|
+
)
|
16
|
+
trans.logger = config.logger
|
17
|
+
trans
|
97
18
|
end
|
98
|
-
curl_request(body)
|
99
|
-
end
|
100
|
-
|
101
|
-
def create_contact(token, folder_id, attrs)
|
102
|
-
a = attrs.to_a.map(&A_NODE_PROC)
|
103
|
-
soap_name = :CreateContactRequest
|
104
|
-
req = { cn: { a: a, l: folder_id } }
|
105
|
-
body = init_hash_request(token, soap_name)
|
106
|
-
body[:Body][soap_name].merge!(req)
|
107
|
-
curl_request(body)
|
108
|
-
end
|
109
|
-
|
110
|
-
def modify_contact(token, id, attrs)
|
111
|
-
a = attrs.to_a.map(&A_NODE_PROC)
|
112
|
-
soap_name = :ModifyContactRequest
|
113
|
-
req = { cn: { a: a, id: id } }
|
114
|
-
body = init_hash_request(token, soap_name)
|
115
|
-
body[:Body][soap_name].merge!(req)
|
116
|
-
curl_request(body)
|
117
|
-
end
|
118
|
-
|
119
|
-
def create_group_contact(token, folder_id, attrs, members = [])
|
120
|
-
soap_name = :CreateContactRequest
|
121
|
-
a = attrs.to_a.map(&A_NODE_PROC)
|
122
|
-
req = { cn: { a: a, l: folder_id, m: members } }
|
123
|
-
body = init_hash_request(token, soap_name)
|
124
|
-
body[:Body][soap_name].merge!(req)
|
125
|
-
curl_request(body)
|
126
|
-
end
|
127
|
-
|
128
|
-
def modify_group_contact(token, id, attrs, members = [])
|
129
|
-
soap_name = :ModifyContactRequest
|
130
|
-
a = attrs.to_a.map(&A_NODE_PROC)
|
131
|
-
req = { cn: { a: a, id: id, m: members } }
|
132
|
-
body = init_hash_request(token, soap_name)
|
133
|
-
body[:Body][soap_name].merge!(req)
|
134
|
-
curl_request(body)
|
135
|
-
end
|
136
|
-
|
137
|
-
def contact_action(token, op, id, options = {})
|
138
|
-
soap_name = :ContactActionRequest
|
139
|
-
action = { op: op, id: id }.merge(options)
|
140
|
-
req = { action: action }
|
141
|
-
body = init_hash_request(token, soap_name)
|
142
|
-
body[:Body][soap_name].merge!(req)
|
143
|
-
curl_request(body)
|
144
|
-
end
|
145
|
-
|
146
|
-
# -------------------------------
|
147
|
-
# DOCUMENT
|
148
|
-
|
149
|
-
def save_document(token, l, options = {})
|
150
|
-
soap_name = :SaveDocumentRequest
|
151
|
-
body = init_hash_request(token, soap_name)
|
152
|
-
req = { doc: { l: l } }
|
153
|
-
req[:doc].merge!(options)
|
154
|
-
body[:Body][soap_name].merge!(req)
|
155
|
-
curl_request(body)
|
156
|
-
end
|
157
|
-
|
158
|
-
def item_action(token, op, id, options = {})
|
159
|
-
soap_name = :ItemActionRequest
|
160
|
-
action = { op: op, id: id }.merge(options)
|
161
|
-
req = { action: action }
|
162
|
-
body = init_hash_request(token, soap_name)
|
163
|
-
body[:Body][soap_name].merge!(req)
|
164
|
-
curl_request(body)
|
165
|
-
end
|
166
|
-
|
167
|
-
# -------------------------------
|
168
|
-
# FOLDER
|
169
|
-
|
170
|
-
def get_folder(token, jsns)
|
171
|
-
jsns_request(:GetFolderRequest, token, jsns)
|
172
|
-
end
|
173
|
-
|
174
|
-
# def get_all_folders(token, view = nil, tr = nil)
|
175
|
-
# soap_name = :GetFolderRequest
|
176
|
-
# body = init_hash_request(token, soap_name)
|
177
|
-
# req = { view: view, tr: tr }.reject { |_, v| v.nil? }
|
178
|
-
# body[:Body][soap_name].merge!(req)
|
179
|
-
# curl_request(body)
|
180
|
-
# end
|
181
|
-
|
182
|
-
def create_folder(token, jsns)
|
183
|
-
jsns_request(:CreateFolderRequest, token, jsns)
|
184
|
-
end
|
185
|
-
|
186
|
-
def folder_action(token, jsns)
|
187
|
-
jsns_request(:FolderActionRequest, token, jsns)
|
188
|
-
end
|
189
|
-
|
190
|
-
def get_all_search_folders(token)
|
191
|
-
soap_name = :GetSearchFolderRequest
|
192
|
-
body = init_hash_request(token, soap_name)
|
193
|
-
curl_request(body)
|
194
19
|
end
|
195
20
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
def create_search_folder(token, jsns)
|
200
|
-
jsns_request(:CreateSearchFolderRequest, token, jsns)
|
21
|
+
def token
|
22
|
+
context.to_hash[:authToken]
|
201
23
|
end
|
202
24
|
|
203
|
-
def
|
204
|
-
|
25
|
+
def token=(value)
|
26
|
+
context.token(value)
|
205
27
|
end
|
206
28
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
def create_task(token, folder_id, name, description = nil, options = {})
|
211
|
-
comp = { name: name }
|
212
|
-
comp.merge!(options) if !options.nil? && !options.empty?
|
213
|
-
|
214
|
-
task = { su: name, l: folder_id, inv: { comp: [comp] } }
|
215
|
-
|
216
|
-
task[:mp] = { ct: 'text/plain', content: description } unless description.nil?
|
217
|
-
|
218
|
-
req = { m: task }
|
219
|
-
|
220
|
-
body = init_hash_request(token, :CreateTaskRequest)
|
221
|
-
body[:Body][:CreateTaskRequest].merge!(req)
|
222
|
-
curl_request(body)
|
223
|
-
end
|
224
|
-
|
225
|
-
# -------------------------------
|
226
|
-
# SHARE
|
227
|
-
|
228
|
-
def create_mountpoint(token, jsns)
|
229
|
-
jsns_request(:CreateMountpointRequest, token, jsns)
|
230
|
-
end
|
231
|
-
|
232
|
-
def get_share_info(token, options = {})
|
233
|
-
soap_name = :GetShareInfoRequest
|
234
|
-
req = { includeSelf: 0 }.merge!(options)
|
235
|
-
body = init_hash_request(token, soap_name, ACCOUNTSPACE)
|
236
|
-
body[:Body][soap_name].merge!(req)
|
237
|
-
curl_request(body)
|
238
|
-
end
|
239
|
-
|
240
|
-
def get_rights(token, jsns)
|
241
|
-
jsns_request(:GetRightsRequest, token, jsns, ACCOUNTSPACE)
|
242
|
-
end
|
243
|
-
|
244
|
-
def grant_rights(token, jsns)
|
245
|
-
jsns_request(:GrantRightsRequest, token, jsns, ACCOUNTSPACE)
|
246
|
-
end
|
247
|
-
|
248
|
-
def revoke_rights(token, jsns)
|
249
|
-
jsns_request(:RevokeRightsRequest, token, jsns, ACCOUNTSPACE)
|
250
|
-
end
|
251
|
-
|
252
|
-
# -------------------------------
|
253
|
-
# MESSAGE
|
254
|
-
|
255
|
-
def get_msg(token, id, options = {})
|
256
|
-
req = { m: { id: id } }
|
257
|
-
req[:m].merge!(options) unless options.empty?
|
258
|
-
body = init_hash_request(token, :GetMsgRequest)
|
259
|
-
body[:Body][:GetMsgRequest].merge!(req)
|
260
|
-
curl_request(body)
|
261
|
-
end
|
262
|
-
|
263
|
-
def msg_action(token, op, id, options = {})
|
264
|
-
action = { op: op, id: id }.merge(options)
|
265
|
-
req = { action: action }
|
266
|
-
body = init_hash_request(token, :MsgActionRequest)
|
267
|
-
body[:Body][:MsgActionRequest].merge!(req)
|
268
|
-
curl_request(body)
|
269
|
-
end
|
270
|
-
|
271
|
-
def send_msg(token, m)
|
272
|
-
req = { m: m }
|
273
|
-
body = init_hash_request(token, :SendMsgRequest)
|
274
|
-
body[:Body][:SendMsgRequest].merge!(req)
|
275
|
-
# curl_request(body)
|
276
|
-
end
|
277
|
-
|
278
|
-
def add_msg(token, l, eml, d = nil, f = nil, tn = nil)
|
279
|
-
key = :AddMsgRequest
|
280
|
-
m = {
|
281
|
-
l: l,
|
282
|
-
d: d,
|
283
|
-
f: f,
|
284
|
-
tn: tn,
|
285
|
-
content: { _content: eml }
|
286
|
-
}.reject { |_, v| v.nil? }
|
287
|
-
|
288
|
-
req = { m: m }
|
289
|
-
body = init_hash_request(token, key)
|
290
|
-
body[:Body][key].merge!(req)
|
291
|
-
|
292
|
-
curl_request(body)
|
293
|
-
end
|
294
|
-
|
295
|
-
# -------------------------------
|
296
|
-
# TAG
|
297
|
-
|
298
|
-
def get_tag(token)
|
299
|
-
body = init_hash_request(token, :GetTagRequest)
|
300
|
-
curl_request(body)
|
301
|
-
end
|
302
|
-
|
303
|
-
def create_tag(token, jsns)
|
304
|
-
jsns_request(:CreateTagRequest, token, jsns)
|
305
|
-
end
|
306
|
-
|
307
|
-
def tag_action(token, jsns)
|
308
|
-
jsns_request(:TagActionRequest, token, jsns)
|
309
|
-
end
|
310
|
-
|
311
|
-
# -------------------------------
|
312
|
-
# IDENTITY
|
313
|
-
|
314
|
-
def get_all_identities(token)
|
315
|
-
body = init_hash_request(token, :GetIdentitiesRequest, ACCOUNTSPACE)
|
316
|
-
curl_request(body)
|
317
|
-
end
|
318
|
-
|
319
|
-
def create_identity(token, name, attrs = {})
|
320
|
-
soap_name = :CreateIdentityRequest
|
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)
|
325
|
-
end
|
326
|
-
|
327
|
-
def modify_identity(token, id, attrs = {})
|
328
|
-
soap_name = :ModifyIdentityRequest
|
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)
|
333
|
-
end
|
334
|
-
|
335
|
-
def delete_identity(token, id)
|
336
|
-
soap_name = :DeleteIdentityRequest
|
337
|
-
req = { identity: { id: id } }
|
338
|
-
body = init_hash_request(token, soap_name, ACCOUNTSPACE)
|
339
|
-
body[:Body][soap_name].merge!(req)
|
340
|
-
curl_request(body)
|
341
|
-
end
|
342
|
-
|
343
|
-
# -------------------------------
|
344
|
-
# PREFERENCES
|
345
|
-
|
346
|
-
def get_prefs(token, *names)
|
347
|
-
req = { prefs: names.map { |name| { name: name } } }
|
348
|
-
body = init_hash_request(token, :GetPrefsRequest, ACCOUNTSPACE)
|
349
|
-
body[:Body][:GetPrefsRequest].merge!(req) if req.any?
|
350
|
-
curl_request(body)
|
351
|
-
end
|
352
|
-
|
353
|
-
def get_filter_rules(token)
|
354
|
-
soap_name = :GetFilterRulesRequest
|
355
|
-
body = init_hash_request(token, soap_name)
|
356
|
-
curl_request(body)
|
357
|
-
end
|
358
|
-
|
359
|
-
def modify_filter_rules(token, rules)
|
360
|
-
soap_name = :ModifyFilterRulesRequest
|
361
|
-
req = { filterRules: [{ filterRule: rules }] }
|
362
|
-
body = init_hash_request(token, soap_name)
|
363
|
-
body[:Body][soap_name].merge!(req)
|
364
|
-
curl_request(body)
|
365
|
-
end
|
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
|
-
|
380
|
-
def get_signatures(token)
|
381
|
-
soap_name = :GetSignaturesRequest
|
382
|
-
body = init_hash_request(token, soap_name, ACCOUNTSPACE)
|
383
|
-
curl_request(body)
|
384
|
-
end
|
385
|
-
|
386
|
-
def create_signature(token, jsns)
|
387
|
-
soap_name = :CreateSignatureRequest
|
388
|
-
body = init_hash_request(token, soap_name, ACCOUNTSPACE)
|
389
|
-
body[:Body][soap_name].merge!(jsns)
|
390
|
-
curl_request(body)
|
391
|
-
end
|
392
|
-
|
393
|
-
def modify_signature(token, jsns)
|
394
|
-
soap_name = :ModifySignatureRequest
|
395
|
-
body = init_hash_request(token, soap_name, ACCOUNTSPACE)
|
396
|
-
body[:Body][soap_name].merge!(jsns)
|
397
|
-
curl_request(body)
|
29
|
+
def initialize(scheme, host, port)
|
30
|
+
super(scheme, host, port, SoapAccountConstants::ACCOUNT_SERVICE_URI)
|
398
31
|
end
|
399
32
|
|
400
|
-
def
|
401
|
-
|
402
|
-
|
403
|
-
body[:Body][soap_name].merge!(jsns)
|
404
|
-
curl_request(body)
|
405
|
-
end
|
33
|
+
def auth_preauth(content, by, expires, domainkey)
|
34
|
+
ts = (Time.now.to_i * 1000)
|
35
|
+
preauth = compute_preauth(content, by, ts, expires, domainkey)
|
406
36
|
|
407
|
-
|
408
|
-
|
37
|
+
soap_request = SoapElement.account(SoapAccountConstants::AUTH_REQUEST)
|
38
|
+
node_account = SoapElement.create(SoapConstants::ACCOUNT).add_attribute(SoapConstants::BY,
|
39
|
+
by).add_content(content)
|
40
|
+
soap_request.add_node(node_account)
|
41
|
+
node_preauth = SoapElement.create(SoapConstants::PREAUTH).add_attribute(SoapConstants::TIMESTAMP,
|
42
|
+
ts).add_content(preauth)
|
43
|
+
soap_request.add_node(node_preauth)
|
409
44
|
|
410
|
-
|
411
|
-
req = { rights: rights, sections: sections }.reject { |_, v| v.nil? }
|
412
|
-
body = init_hash_request(token, :GetInfoRequest, ACCOUNTSPACE)
|
413
|
-
body[:Body][:GetInfoRequest].merge!(req) if req.any?
|
414
|
-
curl_request(body)
|
45
|
+
do_login(soap_request)
|
415
46
|
end
|
416
47
|
|
417
|
-
def
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
limit: limit,
|
424
|
-
sortBy: sortBy,
|
425
|
-
query: query,
|
426
|
-
header: [{ n: 'messageIdHeader' }]
|
427
|
-
}.merge!(options)
|
428
|
-
req.reject! { |_, v| v.nil? }
|
48
|
+
def auth_password(content, by, password)
|
49
|
+
soap_request = SoapElement.account(SoapAccountConstants::AUTH_REQUEST)
|
50
|
+
node_account = SoapElement.create(SoapConstants::ACCOUNT).add_attribute(SoapConstants::BY,
|
51
|
+
by).add_content(content)
|
52
|
+
soap_request.add_node(node_account)
|
53
|
+
soap_request.add_attribute('password', password)
|
429
54
|
|
430
|
-
|
431
|
-
body[:Body][soap_name].merge!(req) if req.any?
|
432
|
-
curl_request(body)
|
55
|
+
do_login(soap_request)
|
433
56
|
end
|
434
57
|
|
435
|
-
def
|
436
|
-
|
437
|
-
body[:Body][soap_name].merge!(jsns) if jsns.is_a?(Hash)
|
438
|
-
curl_request(body)
|
439
|
-
end
|
440
|
-
|
441
|
-
def ranking_action(token, op, email = nil)
|
442
|
-
soap_name = :RankingActionRequest
|
443
|
-
req = {
|
444
|
-
action: {
|
445
|
-
op: op,
|
446
|
-
email: email
|
447
|
-
}
|
448
|
-
}
|
449
|
-
req[:action].delete_if { |_, v| v.nil? }
|
450
|
-
|
451
|
-
body = init_hash_request(token, soap_name)
|
452
|
-
body[:Body][soap_name].merge!(req) if req.any?
|
453
|
-
|
454
|
-
curl_request(body)
|
58
|
+
def do_login(soap_request)
|
59
|
+
invoke(soap_request)[:AuthResponse][:authToken].first[:_content]
|
455
60
|
end
|
456
61
|
|
457
62
|
private
|
458
63
|
|
459
|
-
def compute_preauth(
|
460
|
-
data = "#{
|
64
|
+
def compute_preauth(content, by, ts, expires, domain_key)
|
65
|
+
data = "#{content}|#{by}|#{expires}|#{ts}"
|
461
66
|
digest = OpenSSL::Digest.new('sha1')
|
462
|
-
hmac = OpenSSL::HMAC.hexdigest(digest,
|
67
|
+
hmac = OpenSSL::HMAC.hexdigest(digest, domain_key, data)
|
463
68
|
hmac.to_s
|
464
69
|
end
|
465
|
-
|
466
|
-
def init_hash_request(token, soap_name, namespace = MAILSPACE)
|
467
|
-
{
|
468
|
-
Body: {
|
469
|
-
soap_name => { _jsns: namespace }
|
470
|
-
}
|
471
|
-
}.merge(hash_header(token))
|
472
|
-
end
|
473
70
|
end
|
474
71
|
end
|
475
72
|
end
|