From 62356f9ea386eed3d9caed1fe21122d21b2bfcb5 Mon Sep 17 00:00:00 2001 From: Fabrice Clari Date: Wed, 10 Sep 2014 16:09:10 +0200 Subject: [PATCH] handle getting events for multiple users in a single request --- lib/ews/soap/ews_soap_free_busy_response.rb | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/ews/soap/ews_soap_free_busy_response.rb b/lib/ews/soap/ews_soap_free_busy_response.rb index 5d69909c..f6201f44 100644 --- a/lib/ews/soap/ews_soap_free_busy_response.rb +++ b/lib/ews/soap/ews_soap_free_busy_response.rb @@ -37,10 +37,30 @@ def body envelope[1][:body][:elems] end + # def get_user_availability_response + # body.first[:get_user_availability_response][:elems].first[:free_busy_response_array][:elems].first[:free_busy_response][:elems] + # end + def get_user_availability_response - body.first[:get_user_availability_response][:elems].first[:free_busy_response_array][:elems].first[:free_busy_response][:elems] + # This method handles multiple calender when an array of mulitple users is passed through cli.get_user_availability + events = [] + body.first[:get_user_availability_response][:elems].first[:free_busy_response_array][:elems].each_with_index do |e, i| + e[:free_busy_response][:elems][1][:free_busy_view][:elems][1][:calendar_event_array][:elems].each do |c| + + if c[:calendar_event][:elems].select { |element| element.is_a?(Hash) && element.has_key?(:user_position)}.length == 0 + c[:calendar_event][:elems] << { :user_position => i } + end + events << c + end + end + + result = body.first[:get_user_availability_response][:elems].first[:free_busy_response_array][:elems].first[:free_busy_response][:elems] + result[1][:free_busy_view][:elems][1][:calendar_event_array][:elems] = events + + result end + def response body end