zm-ruby-client 0.10.4
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 +7 -0
- data/.gitignore +58 -0
- data/Gemfile +8 -0
- data/LICENSE +674 -0
- data/README.md +47 -0
- data/SECURITY.md +21 -0
- data/lib/zm/client/account/account.rb +335 -0
- data/lib/zm/client/account/account_dls_membership_collection.rb +22 -0
- data/lib/zm/client/account/account_dls_owner_collection.rb +22 -0
- data/lib/zm/client/account/accounts_builder.rb +19 -0
- data/lib/zm/client/account/accounts_collection.rb +48 -0
- data/lib/zm/client/account.rb +7 -0
- data/lib/zm/client/ace/ace.rb +32 -0
- data/lib/zm/client/ace/aces_builder.rb +25 -0
- data/lib/zm/client/ace/aces_collection.rb +36 -0
- data/lib/zm/client/ace.rb +5 -0
- data/lib/zm/client/appointment/appointment.rb +143 -0
- data/lib/zm/client/appointment/appointment_jsns_builder.rb +125 -0
- data/lib/zm/client/appointment/appointment_jsns_initializer.rb +129 -0
- data/lib/zm/client/appointment/appointments_builder.rb +33 -0
- data/lib/zm/client/appointment/appointments_collection.rb +106 -0
- data/lib/zm/client/appointment.rb +7 -0
- data/lib/zm/client/backup/backup.rb +59 -0
- data/lib/zm/client/backup/backups_builder.rb +26 -0
- data/lib/zm/client/backup/backups_collection.rb +22 -0
- data/lib/zm/client/backup.rb +5 -0
- data/lib/zm/client/base/account_object.rb +17 -0
- data/lib/zm/client/base/admin_object.rb +45 -0
- data/lib/zm/client/base/object.rb +80 -0
- data/lib/zm/client/base/objects_builder.rb +31 -0
- data/lib/zm/client/base/objects_collection.rb +135 -0
- data/lib/zm/client/base.rb +7 -0
- data/lib/zm/client/cluster/cluster.rb +117 -0
- data/lib/zm/client/cluster/cluster_config.rb +100 -0
- data/lib/zm/client/cluster.rb +4 -0
- data/lib/zm/client/common/message.rb +10 -0
- data/lib/zm/client/common/recipients.rb +67 -0
- data/lib/zm/client/common.rb +4 -0
- data/lib/zm/client/config.rb +12 -0
- data/lib/zm/client/connector/rest_account.rb +74 -0
- data/lib/zm/client/connector/soap_account.rb +562 -0
- data/lib/zm/client/connector/soap_admin.rb +512 -0
- data/lib/zm/client/connector/soap_base.rb +65 -0
- data/lib/zm/client/connector/soap_error.rb +26 -0
- data/lib/zm/client/connector/soap_xml_builder.rb +68 -0
- data/lib/zm/client/constant.rb +217 -0
- data/lib/zm/client/contact/contact.rb +124 -0
- data/lib/zm/client/contact/contact_member.rb +73 -0
- data/lib/zm/client/contact/contacts_builder.rb +24 -0
- data/lib/zm/client/contact/contacts_collection.rb +26 -0
- data/lib/zm/client/contact/mod_group_contact.rb +74 -0
- data/lib/zm/client/contact.rb +7 -0
- data/lib/zm/client/cos/cos.rb +59 -0
- data/lib/zm/client/cos/coses_builder.rb +29 -0
- data/lib/zm/client/cos/coses_collection.rb +33 -0
- data/lib/zm/client/cos.rb +5 -0
- data/lib/zm/client/data_source.rb +5 -0
- data/lib/zm/client/distributionlist/distributionlist.rb +125 -0
- data/lib/zm/client/distributionlist/distributionlists_builder.rb +29 -0
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +41 -0
- data/lib/zm/client/distributionlist.rb +5 -0
- data/lib/zm/client/document/document.rb +47 -0
- data/lib/zm/client/document/documents_builder.rb +31 -0
- data/lib/zm/client/document/documents_collection.rb +93 -0
- data/lib/zm/client/document.rb +5 -0
- data/lib/zm/client/domain/domain.rb +74 -0
- data/lib/zm/client/domain/domains_builder.rb +32 -0
- data/lib/zm/client/domain/domains_collection.rb +36 -0
- data/lib/zm/client/domain.rb +5 -0
- data/lib/zm/client/folder/folder.rb +215 -0
- data/lib/zm/client/folder/folder_grant.rb +58 -0
- data/lib/zm/client/folder/folder_retention_policy.rb +48 -0
- data/lib/zm/client/folder/folders_builder.rb +58 -0
- data/lib/zm/client/folder/folders_collection.rb +70 -0
- data/lib/zm/client/folder/mod_document_folder.rb +17 -0
- data/lib/zm/client/folder.rb +8 -0
- data/lib/zm/client/identity/identities_builder.rb +25 -0
- data/lib/zm/client/identity/identities_collection.rb +26 -0
- data/lib/zm/client/identity/identity.rb +75 -0
- data/lib/zm/client/identity.rb +5 -0
- data/lib/zm/client/license/license.rb +29 -0
- data/lib/zm/client/license/licenses_collection.rb +28 -0
- data/lib/zm/client/license.rb +4 -0
- data/lib/zm/client/message/message.rb +225 -0
- data/lib/zm/client/message/messages_builder.rb +31 -0
- data/lib/zm/client/message/messages_collection.rb +111 -0
- data/lib/zm/client/message.rb +5 -0
- data/lib/zm/client/mountpoint/mountpoint.rb +95 -0
- data/lib/zm/client/mountpoint/mountpoints_builder.rb +38 -0
- data/lib/zm/client/mountpoint/mountpoints_collection.rb +61 -0
- data/lib/zm/client/mountpoint.rb +5 -0
- data/lib/zm/client/mta_queue/mta_queue.rb +60 -0
- data/lib/zm/client/mta_queue/mta_queues_builder.rb +26 -0
- data/lib/zm/client/mta_queue/mta_queues_collection.rb +95 -0
- data/lib/zm/client/mta_queue.rb +5 -0
- data/lib/zm/client/mta_queue_item/mta_queue_item.rb +51 -0
- data/lib/zm/client/mta_queue_item/mta_queue_items_builder.rb +27 -0
- data/lib/zm/client/mta_queue_item/mta_queue_items_collection.rb +99 -0
- data/lib/zm/client/mta_queue_item.rb +5 -0
- data/lib/zm/client/resource/resource.rb +149 -0
- data/lib/zm/client/resource/resources_builder.rb +29 -0
- data/lib/zm/client/resource/resources_collection.rb +41 -0
- data/lib/zm/client/resource.rb +5 -0
- data/lib/zm/client/search_folder/search_folder.rb +63 -0
- data/lib/zm/client/search_folder/search_folders_builder.rb +26 -0
- data/lib/zm/client/search_folder/search_folders_collection.rb +28 -0
- data/lib/zm/client/search_folder.rb +5 -0
- data/lib/zm/client/server/server.rb +516 -0
- data/lib/zm/client/server/servers_builder.rb +26 -0
- data/lib/zm/client/server/servers_collection.rb +37 -0
- data/lib/zm/client/server.rb +5 -0
- data/lib/zm/client/share/share.rb +60 -0
- data/lib/zm/client/share/shares_builder.rb +23 -0
- data/lib/zm/client/share/shares_collection.rb +48 -0
- data/lib/zm/client/share.rb +5 -0
- data/lib/zm/client/signature/signature.rb +62 -0
- data/lib/zm/client/signature/signature_jsns_builder.rb +29 -0
- data/lib/zm/client/signature/signatures_builder.rb +26 -0
- data/lib/zm/client/signature/signatures_collection.rb +28 -0
- data/lib/zm/client/signature.rb +6 -0
- data/lib/zm/client/tag/tag.rb +45 -0
- data/lib/zm/client/tag/tags_builder.rb +25 -0
- data/lib/zm/client/tag/tags_collection.rb +26 -0
- data/lib/zm/client/tag.rb +5 -0
- data/lib/zm/client/task/task.rb +74 -0
- data/lib/zm/client/task/tasks_builder.rb +31 -0
- data/lib/zm/client/task/tasks_collection.rb +100 -0
- data/lib/zm/client/task.rb +5 -0
- data/lib/zm/client/upload/upload.rb +154 -0
- data/lib/zm/client/upload.rb +3 -0
- data/lib/zm/client/version.rb +18 -0
- data/lib/zm/client.rb +5 -0
- data/lib/zm/modules/common/account_common.rb +71 -0
- data/lib/zm/modules/common/cos_common.rb +463 -0
- data/lib/zm/modules/common/dl_common.rb +33 -0
- data/lib/zm/modules/common/identity_common.rb +19 -0
- data/lib/zm/modules/common/resource_common.rb +59 -0
- data/lib/zm/modules/common/signature_common.rb +16 -0
- data/lib/zm/modules/common/zimbra-attrs.json +1 -0
- data/lib/zm/utils/thread_pool.rb +72 -0
- data/lib/zm-ruby-client.rb +1 -0
- data/test/accounts.rb +62 -0
- data/test/cluster_config.rb +30 -0
- data/test/coses.rb +26 -0
- data/test/domains.rb +62 -0
- data/zm-ruby-client.gemspec +24 -0
- metadata +243 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account appointment
|
|
6
|
+
class Appointment < Base::AccountObject
|
|
7
|
+
|
|
8
|
+
INSTANCE_VARIABLE_KEYS = %i[id uid name l desc start_at dur end_at tn allDay organizer timezone calItemId apptId invId rev fb transp]
|
|
9
|
+
|
|
10
|
+
attr_accessor *INSTANCE_VARIABLE_KEYS
|
|
11
|
+
attr_writer :folder
|
|
12
|
+
attr_reader :json
|
|
13
|
+
attr_reader :recipients, :attendees, :body
|
|
14
|
+
|
|
15
|
+
alias description desc
|
|
16
|
+
alias parent_id l
|
|
17
|
+
|
|
18
|
+
# def initialize(parent, json = nil)
|
|
19
|
+
def initialize(parent)
|
|
20
|
+
@parent = parent
|
|
21
|
+
@recipients = Recipients.new
|
|
22
|
+
@body = BodyMail.new
|
|
23
|
+
@attendees = Attendees.new
|
|
24
|
+
@allDay = false
|
|
25
|
+
@timezone = 'Europe/Berlin'
|
|
26
|
+
yield(self) if block_given?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def concat
|
|
30
|
+
INSTANCE_VARIABLE_KEYS.map { |key| instance_variable_get(arrow_name(key)) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def folder
|
|
34
|
+
@folder ||= @parent.folders.all.find { |folder| folder.id == l }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def download(dest_file_path, fmt = 'ics')
|
|
38
|
+
# @parent.uploader.download_file(folder.absFolderPath, 'ics', ['appointment'], [id], dest_file_path)
|
|
39
|
+
uploader = Upload.new(@parent, RestAccountConnector.new)
|
|
40
|
+
uploader.download_file(folder.absFolderPath, fmt, ['appointment'], [id], dest_file_path)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def create!
|
|
44
|
+
jsns_builder = AppointmentJsnsBuilder.new(self)
|
|
45
|
+
rep = @parent.sacc.create_appointment(@parent.token, jsns_builder.to_jsns)
|
|
46
|
+
rep_h = rep[:Body][:CreateAppointmentResponse]
|
|
47
|
+
|
|
48
|
+
aji = AppointmentJsnsInitializer.new(@parent, rep_h)
|
|
49
|
+
aji.appointment = self
|
|
50
|
+
aji.update
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def modify!
|
|
54
|
+
jsns_builder = AppointmentJsnsBuilder.new(self)
|
|
55
|
+
@parent.sacc.modify_appointment(@parent.token, jsns_builder.to_update)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def reload!
|
|
59
|
+
rep = @parent.sacc.get_msg(@parent.token, @id)
|
|
60
|
+
entry = rep[:Body][:GetMsgResponse][:m].first
|
|
61
|
+
aji = AppointmentJsnsInitializer.new(@parent, entry)
|
|
62
|
+
aji.appointment = self
|
|
63
|
+
aji.create
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def delete!
|
|
67
|
+
jsns_builder = AppointmentJsnsBuilder.new(self)
|
|
68
|
+
@parent.sacc.cancel_appointment(@parent.token, jsns_builder.to_delete)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def free!
|
|
72
|
+
self.fb = 'F'
|
|
73
|
+
self.transp = 'O'
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def busy!
|
|
77
|
+
self.fb = 'B'
|
|
78
|
+
self.transp = 'T'
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def must_confirm!
|
|
82
|
+
self.fb = 'T'
|
|
83
|
+
self.transp = 'T'
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def out_of_office!
|
|
87
|
+
self.fb = 'O'
|
|
88
|
+
self.transp = 'O'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class Organizer
|
|
92
|
+
attr_accessor :email, :display_name
|
|
93
|
+
|
|
94
|
+
def initialize(email, display_name = nil)
|
|
95
|
+
@email = email
|
|
96
|
+
@display_name = display_name
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Collection attendees
|
|
101
|
+
class Attendees
|
|
102
|
+
def initialize
|
|
103
|
+
@attendees = []
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def map(&block)
|
|
107
|
+
@attendees.map(&block)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def add(attendee)
|
|
111
|
+
return unless attendee.is_a?(Attendee)
|
|
112
|
+
|
|
113
|
+
@attendees.push(attendee)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def del(attendee)
|
|
117
|
+
if attendee.is_a?(Attendee)
|
|
118
|
+
@attendees.delete(attendee)
|
|
119
|
+
elsif attendee.is_a?(String)
|
|
120
|
+
@attendees.delete_if { |at| at.email == attendee }
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def clear
|
|
125
|
+
@attendees.clear
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Class one recipient for email
|
|
130
|
+
class Attendee
|
|
131
|
+
attr_accessor :email, :display_name, :role, :ptst, :rsvp
|
|
132
|
+
|
|
133
|
+
def initialize(email, display_name = nil, role = 'REQ', ptst = 'NE', rsvp = 1)
|
|
134
|
+
@email = email
|
|
135
|
+
@display_name = display_name
|
|
136
|
+
@role = role
|
|
137
|
+
@ptst = ptst
|
|
138
|
+
@rsvp = rsvp
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account appointment
|
|
6
|
+
class AppointmentJsnsBuilder
|
|
7
|
+
|
|
8
|
+
def initialize(appointment)
|
|
9
|
+
@appointment = appointment
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def to_delete
|
|
13
|
+
{
|
|
14
|
+
comp: 0,
|
|
15
|
+
id: @appointment.id
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_jsns
|
|
20
|
+
{
|
|
21
|
+
m: {
|
|
22
|
+
l: @appointment.l,
|
|
23
|
+
su: @appointment.name,
|
|
24
|
+
e: recipients_to_jsns,
|
|
25
|
+
mp: body_to_jsns,
|
|
26
|
+
inv: {
|
|
27
|
+
comp: comp_to_jsns
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
alias to_create to_jsns
|
|
34
|
+
|
|
35
|
+
def to_update
|
|
36
|
+
jsns = to_jsns
|
|
37
|
+
jsns[:comp] = 0
|
|
38
|
+
jsns[:id] = @appointment.id
|
|
39
|
+
jsns[:m][:inv][:uid] = @appointment.uid
|
|
40
|
+
jsns
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def recipients_to_jsns
|
|
44
|
+
@appointment.recipients.map do |recipient|
|
|
45
|
+
{
|
|
46
|
+
t: recipient.field,
|
|
47
|
+
a: recipient.email,
|
|
48
|
+
p: recipient.display_name
|
|
49
|
+
}.reject { |_, v| v.nil? }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def body_to_jsns
|
|
54
|
+
[
|
|
55
|
+
{
|
|
56
|
+
ct: 'multipart/alternative',
|
|
57
|
+
mp: [body_text_jsns, body_html_jsns]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def body_text_jsns
|
|
63
|
+
{ ct: 'text/plain', content: { _content: @appointment.body.text } }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def body_html_jsns
|
|
67
|
+
{ ct: 'text/html', content: { _content: @appointment.body.html } }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def comp_to_jsns
|
|
71
|
+
[
|
|
72
|
+
{
|
|
73
|
+
allDay: @appointment.allDay,
|
|
74
|
+
at: attendees_to_jsns,
|
|
75
|
+
e: end_at_jsns,
|
|
76
|
+
s: start_at_jsns,
|
|
77
|
+
or: organizer_to_jsns,
|
|
78
|
+
name: @appointment.name,
|
|
79
|
+
fb: @appointment.fb,
|
|
80
|
+
transp: @appointment.transp
|
|
81
|
+
}.reject { |_, v| v.nil? }
|
|
82
|
+
]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def attendees_to_jsns
|
|
86
|
+
@appointment.attendees.map do |attendee|
|
|
87
|
+
{
|
|
88
|
+
a: attendee.email,
|
|
89
|
+
d: attendee.display_name,
|
|
90
|
+
role: attendee.role,
|
|
91
|
+
ptst: attendee.ptst,
|
|
92
|
+
rsvp: attendee.rsvp
|
|
93
|
+
}.reject { |_, v| v.nil? }
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def end_at_jsns
|
|
98
|
+
{
|
|
99
|
+
d: @appointment.end_at.strftime(time_format),
|
|
100
|
+
tz: @appointment.timezone
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def start_at_jsns
|
|
105
|
+
{
|
|
106
|
+
d: @appointment.start_at.strftime(time_format),
|
|
107
|
+
tz: @appointment.timezone
|
|
108
|
+
}
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def organizer_to_jsns
|
|
112
|
+
return nil if @appointment.organizer.nil?
|
|
113
|
+
|
|
114
|
+
{
|
|
115
|
+
a: @appointment.organizer.email,
|
|
116
|
+
d: @appointment.organizer.display_name
|
|
117
|
+
}.reject { |_, v| v.nil? }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def time_format
|
|
121
|
+
@time_format ||= @appointment.allDay ? '%Y%m%d' : '%Y%m%dT%H%M00'
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account appointment
|
|
6
|
+
class AppointmentJsnsInitializer
|
|
7
|
+
|
|
8
|
+
attr_accessor :appointment
|
|
9
|
+
|
|
10
|
+
def initialize(parent, json)
|
|
11
|
+
@parent = parent
|
|
12
|
+
@json = json
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def update
|
|
16
|
+
return false if @appointment.nil?
|
|
17
|
+
|
|
18
|
+
@appointment.calItemId = @json[:calItemId]
|
|
19
|
+
@appointment.apptId = @json[:apptId]
|
|
20
|
+
@appointment.invId = @json[:invId]
|
|
21
|
+
@appointment.id = @json[:invId]
|
|
22
|
+
@appointment.rev = @json[:rev]
|
|
23
|
+
|
|
24
|
+
true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def create
|
|
28
|
+
@appointment ||= Appointment.new(@parent)
|
|
29
|
+
|
|
30
|
+
@appointment.id = @json[:id]
|
|
31
|
+
@appointment.tn = @json[:tn]
|
|
32
|
+
@appointment.l = @json[:l].to_i
|
|
33
|
+
@appointment.uid = @json[:uid]
|
|
34
|
+
|
|
35
|
+
if inv.nil?
|
|
36
|
+
init_from_search
|
|
37
|
+
else
|
|
38
|
+
init_from_inv
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
@appointment
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def inv
|
|
45
|
+
@inv ||= @json[:inv]&.first
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def init_from_search
|
|
49
|
+
@appointment.organizer = Zm::Client::Appointment::Organizer.new(search_organizer_name) unless search_organizer_name.nil?
|
|
50
|
+
@appointment.name = @json[:name]
|
|
51
|
+
@appointment.id = @json[:invId]
|
|
52
|
+
@appointment.desc = @json[:fr]
|
|
53
|
+
@appointment.allDay = @json[:allDay] unless @json[:allDay].nil?
|
|
54
|
+
search_make_date
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def init_from_inv
|
|
58
|
+
@appointment.uid = comp[:uid]
|
|
59
|
+
@appointment.fb = comp[:fb]
|
|
60
|
+
@appointment.transp = comp[:transp]
|
|
61
|
+
@appointment.timezone = tz[:id]
|
|
62
|
+
@appointment.name = comp[:name]
|
|
63
|
+
@appointment.desc = comp[:desc].first[:_content] unless comp[:desc].nil?
|
|
64
|
+
@appointment.apptId = comp[:apptId]
|
|
65
|
+
@appointment.allDay = comp[:allDay] unless comp[:allDay].nil?
|
|
66
|
+
|
|
67
|
+
@appointment.organizer = Zm::Client::Appointment::Organizer.new(comp_organizer_name) unless comp_organizer_name.nil?
|
|
68
|
+
|
|
69
|
+
attendees.each do |attendee|
|
|
70
|
+
@appointment.attendees.add(Zm::Client::Appointment::Attendee.new(attendee[:a]))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
comp_make_date
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def search_make_date
|
|
77
|
+
return if @json[:inst].nil? || @json[:inst].first.empty? || @json[:dur].nil?
|
|
78
|
+
|
|
79
|
+
@appointment.start_at = Time.at(@json[:inst].first[:s] / 1000)
|
|
80
|
+
@appointment.end_at = Time.at((@json[:inst].first[:s] + @json[:dur]) / 1000)
|
|
81
|
+
@appointment.dur = @json[:dur] / 1000
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def comp_make_date
|
|
85
|
+
if comp_start_h[:u].nil?
|
|
86
|
+
@appointment.start_at = Time.parse(comp_start_h[:d])
|
|
87
|
+
@appointment.end_at = Time.parse(comp_end_h[:d])
|
|
88
|
+
else
|
|
89
|
+
@appointment.start_at = Time.at(comp_start_h[:u] / 1000)
|
|
90
|
+
@appointment.end_at = Time.at(comp_end_h[:u] / 1000)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def comp_start_h
|
|
95
|
+
@comp_start_h ||= comp[:s].first
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def comp_end_h
|
|
99
|
+
@comp_end_h ||= comp[:e].first
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def tz
|
|
103
|
+
@tz ||= inv[:tz]&.first || { id: 'Europe/Berlin' }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def comp
|
|
107
|
+
raise Zm::Client::ZmError, 'invalid appointment received' if inv[:comp].nil?
|
|
108
|
+
|
|
109
|
+
@comp ||= inv[:comp].first
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def comp_organizer_name
|
|
113
|
+
return nil if comp[:or].nil?
|
|
114
|
+
|
|
115
|
+
@comp_organizer_name ||= comp[:or][:a]
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def search_organizer_name
|
|
119
|
+
return nil if @json[:or].nil?
|
|
120
|
+
|
|
121
|
+
@search_organizer_name ||= @json[:or][:a]
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def attendees
|
|
125
|
+
@attendees ||= comp[:at] || []
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class factory [appointments]
|
|
6
|
+
class AppointmentsBuilder < Base::ObjectsBuilder
|
|
7
|
+
def initialize(parent, json)
|
|
8
|
+
@parent = parent
|
|
9
|
+
@json = json
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def make
|
|
13
|
+
root.map do |s|
|
|
14
|
+
# Appointment.new(@parent, s)
|
|
15
|
+
# Appointment.new(@parent)
|
|
16
|
+
AppointmentJsnsInitializer.new(@parent, s).create
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def ids
|
|
21
|
+
root.map { |s| s[:id] }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def root
|
|
25
|
+
root = @json[:Body][:SearchResponse][:appt]
|
|
26
|
+
return [] if root.nil?
|
|
27
|
+
|
|
28
|
+
root = [root] unless root.is_a?(Array)
|
|
29
|
+
root
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# collection of appointments
|
|
6
|
+
class AppointmentsCollection < Base::ObjectsCollection
|
|
7
|
+
attr_accessor :more
|
|
8
|
+
|
|
9
|
+
def initialize(parent)
|
|
10
|
+
@parent = parent
|
|
11
|
+
@more = true
|
|
12
|
+
reset_query_params
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def find(id)
|
|
16
|
+
rep = @parent.sacc.get_msg(@parent.token, id)
|
|
17
|
+
entry = rep[:Body][:GetMsgResponse][:m].first
|
|
18
|
+
AppointmentJsnsInitializer.new(@parent, entry).create
|
|
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
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'zm/client/appointment/appointment'
|
|
4
|
+
require 'zm/client/appointment/appointment_jsns_builder'
|
|
5
|
+
require 'zm/client/appointment/appointment_jsns_initializer'
|
|
6
|
+
require 'zm/client/appointment/appointments_builder'
|
|
7
|
+
require 'zm/client/appointment/appointments_collection'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
class Backup < Base::AdminObject
|
|
6
|
+
INSTANCE_VARIABLE_KEYS = %i[label type aborted start end minRedoSeq maxRedoSeq live accounts]
|
|
7
|
+
|
|
8
|
+
attr_reader *INSTANCE_VARIABLE_KEYS
|
|
9
|
+
|
|
10
|
+
alias name label
|
|
11
|
+
|
|
12
|
+
def server
|
|
13
|
+
parent
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_h
|
|
17
|
+
hashmap = Hash[INSTANCE_VARIABLE_KEYS.map { |key| [key, instance_variable_get(arrow_name(key))] }]
|
|
18
|
+
hashmap.delete_if { |_, v| v.nil? }
|
|
19
|
+
hashmap
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def to_s
|
|
23
|
+
to_h.to_s
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def start_at
|
|
27
|
+
@start_at ||= Time.at(@start / 1000)
|
|
28
|
+
rescue StandardError => e
|
|
29
|
+
nil
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def end_at
|
|
33
|
+
@end_at ||= Time.at(@end / 1000)
|
|
34
|
+
rescue StandardError => e
|
|
35
|
+
nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def full?
|
|
39
|
+
@type == Zm::Client::BackupTypes::FULL
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def incremental?
|
|
43
|
+
@type == Zm::Client::BackupTypes::INCREMENTAL
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def init_from_json(json)
|
|
47
|
+
@label = json[:label]
|
|
48
|
+
@type = json[:type]
|
|
49
|
+
@aborted = json[:aborted]
|
|
50
|
+
@start = json[:start].to_i
|
|
51
|
+
@end = json[:end].to_i
|
|
52
|
+
@minRedoSeq = json[:minRedoSeq]
|
|
53
|
+
@maxRedoSeq = json[:maxRedoSeq]
|
|
54
|
+
@live = json[:live]
|
|
55
|
+
@accounts = json[:accounts]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class factory [Backup]
|
|
6
|
+
class BackupsBuilder < Base::ObjectsBuilder
|
|
7
|
+
def make
|
|
8
|
+
records = []
|
|
9
|
+
return records if json_items.nil?
|
|
10
|
+
|
|
11
|
+
json_items.each do |entry|
|
|
12
|
+
backup = Backup.new(@parent)
|
|
13
|
+
backup.init_from_json(entry)
|
|
14
|
+
records << backup
|
|
15
|
+
end
|
|
16
|
+
records
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def json_items
|
|
22
|
+
@json_items ||= @json[:Body][json_key][:backup]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# Collection Backups
|
|
6
|
+
class BackupsCollection < Base::ObjectsCollection
|
|
7
|
+
def initialize(parent)
|
|
8
|
+
@parent = parent
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def make_query
|
|
14
|
+
sac.backup_query(@parent.id)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def build_response
|
|
18
|
+
BackupsBuilder.new(@parent, make_query).make
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
module Base
|
|
6
|
+
# Abstract Class Provisionning AccountObject
|
|
7
|
+
class AccountObject < Object
|
|
8
|
+
|
|
9
|
+
def soap_account_connector
|
|
10
|
+
@parent.soap_account_connector
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
alias sacc soap_account_connector
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|