Class: Zimbra::AppointmentService
Defined Under Namespace
Classes: Builder, Parser
Instance Method Summary
collapse
#on_create_document, #on_response_document
#envelope_namespace, #request_content_type, #uri
#request_namespaces, #response_namespaces
#http_error?, #http_not_found?, #on_after_create_http_request, #on_http_error, #report_error, #soap_fault_not_found?
Instance Method Details
#cancel(appointment, invite_id) ⇒ Object
226
227
228
229
230
|
# File 'lib/zimbra/appointment.rb', line 226
def cancel(appointment, invite_id)
xml = invoke("n2:CancelAppointmentRequest") do |message|
Builder.cancel(message, appointment.id, invite_id)
end
end
|
#create(appointment) ⇒ Object
210
211
212
213
214
215
216
217
218
|
# File 'lib/zimbra/appointment.rb', line 210
def create(appointment)
xml = invoke("n2:CreateAppointmentRequest") do |message|
Builder.create(message, appointment)
end
response_hash = Zimbra::Hash.from_xml(xml.document.to_s)
id = response_hash[:Envelope][:Body][:CreateAppointmentResponse][:attributes][:apptId] rescue nil
invite_id = response_hash[:Envelope][:Body][:CreateAppointmentResponse][:attributes][:invId].gsub(/#{id}\-/, '').to_i rescue nil
{ :id => id, :invite_id => invite_id }
end
|
#find(appointment_id) ⇒ Object
202
203
204
205
206
207
208
|
# File 'lib/zimbra/appointment.rb', line 202
def find(appointment_id)
xml = invoke("n2:GetAppointmentRequest") do |message|
Builder.find_by_id(message, appointment_id)
end
return nil unless xml
Parser.appointment_response(xml/"//n2:appt")
end
|
#find_all_by_calendar_id(calendar_id) ⇒ Object
173
174
175
176
177
178
|
# File 'lib/zimbra/appointment.rb', line 173
def find_all_by_calendar_id(calendar_id)
xml = invoke("n2:SearchRequest") do |message|
Builder.find_all_with_query(message, "inid:#{calendar_id}")
end
Parser.get_search_response(xml)
end
|
#find_all_by_calendar_id_since(calendar_id, since_date) ⇒ Object
195
196
197
198
199
200
|
# File 'lib/zimbra/appointment.rb', line 195
def find_all_by_calendar_id_since(calendar_id, since_date)
xml = invoke("n2:SearchRequest") do |message|
Builder.find_all_with_query(message, "inid:#{calendar_id} AND date:>#{since_date.to_i}")
end
Parser.get_search_response(xml)
end
|
#find_all_instances_of_an_appointment(appointment) ⇒ Object
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/zimbra/appointment.rb', line 180
def find_all_instances_of_an_appointment(appointment)
xml = invoke("n2:SearchRequest") do |message|
message.set_attr 'query', "date:#{appointment.date.to_i * 1000}"
message.set_attr 'types', 'appointment'
message.set_attr 'calExpandInstStart', '1'
message.set_attr 'calExpandInstEnd', (Time.now + (86400 * 365 * 10)).to_i * 1000
end
response_hash = Zimbra::Hash.from_xml(xml.document.to_s)
response_hash = response_hash[:Envelope][:Body][:SearchResponse]
appointments = response_hash[:appt].is_a?(Array) ? response_hash[:appt] : [response_hash[:appt]]
appt_hash = appointments.find { |appt| appt[:attributes][:id] == appointment.id }
instances = appt_hash[:inst].is_a?(Array) ? appt_hash[:inst] : [appt_hash[:inst]]
instances.collect { |inst| Time.at(inst[:attributes][:s] / 1000) }
end
|
#update(appointment, invite_id) ⇒ Object
220
221
222
223
224
|
# File 'lib/zimbra/appointment.rb', line 220
def update(appointment, invite_id)
xml = invoke("n2:ModifyAppointmentRequest") do |message|
Builder.update(message, appointment, invite_id)
end
end
|