Class: Exchanger::GetUserAvailability::Request
- Inherits:
-
Operation::Request
- Object
- Operation::Request
- Exchanger::GetUserAvailability::Request
- Defined in:
- lib/exchanger/operations/get_user_availability.rb
Instance Attribute Summary collapse
-
#email_address ⇒ Object
Returns the value of attribute email_address.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#time_zone ⇒ Object
Returns the value of attribute time_zone.
Attributes inherited from Operation::Request
Instance Method Summary collapse
-
#reset ⇒ Object
Reset request options to defaults.
- #time_zone_period ⇒ Object
- #to_xml ⇒ Object
Methods inherited from Operation::Request
#action, #headers, #initialize
Constructor Details
This class inherits a constructor from Exchanger::Operation::Request
Instance Attribute Details
#email_address ⇒ Object
Returns the value of attribute email_address.
7 8 9 |
# File 'lib/exchanger/operations/get_user_availability.rb', line 7 def email_address @email_address end |
#end_time ⇒ Object
Returns the value of attribute end_time.
7 8 9 |
# File 'lib/exchanger/operations/get_user_availability.rb', line 7 def end_time @end_time end |
#start_time ⇒ Object
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/exchanger/operations/get_user_availability.rb', line 7 def start_time @start_time end |
#time_zone ⇒ Object
Returns the value of attribute time_zone.
7 8 9 |
# File 'lib/exchanger/operations/get_user_availability.rb', line 7 def time_zone @time_zone end |
Instance Method Details
#reset ⇒ Object
Reset request options to defaults.
10 11 12 13 14 15 |
# File 'lib/exchanger/operations/get_user_availability.rb', line 10 def reset @time_zone = 'Europe/London' @email_address = '[email protected]' @start_time = Date.today.to_time + 1 @end_time = (Date.today + 1).to_time - 1 end |
#time_zone_period ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/exchanger/operations/get_user_availability.rb', line 17 def time_zone_period begin current_tz = TZInfo::Timezone.get(time_zone).current_period rescue => e raise Exchanger::Operation::ResponseError.new(e, 500) end end |
#to_xml ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/exchanger/operations/get_user_availability.rb', line 25 def to_xml current_tz = time_zone_period minutes_of_utc_offset = current_tz.utc_offset/60 # Get the base offset of the timezone from UTC in minutes minutes_of_std_offset = current_tz.std_offset/60 # Get the daylight savings offset from standard time in minutes start_date_time = start_time.strftime("%Y-%m-%dT%H:%M:%S") end_date_time = end_time.strftime("%Y-%m-%dT%H:%M:%S") Nokogiri::XML::Builder.new do |xml| xml.send("soap:Envelope", "xmlns:xsi" => NS["xsi"], "xmlns:xsd" => NS["xsd"], "xmlns:soap" => NS["soap"], "xmlns:t" => NS["t"], "xmlns:m" => NS["m"]) do xml.send("soap:Body") do xml.send("m:GetUserAvailabilityRequest") do xml.send("t:TimeZone") do xml.send("t:Bias", (minutes_of_utc_offset * -1)) # if daylight savings time is active for current time zone # How to find correct standard time and daylight saving time configuration if current_tz.dst? xml.send("t:StandardTime") do xml.send("t:Bias", 0) xml.send("t:Time", "04:00:00") xml.send("t:DayOrder", 5) xml.send("t:Month", 10) xml.send("t:DayOfWeek", "Sunday") end xml.send("t:DaylightTime") do xml.send("t:Bias", (minutes_of_std_offset * -1)) xml.send("t:Time", "03:00:00") xml.send("t:DayOrder", 5) xml.send("t:Month", 3) xml.send("t:DayOfWeek", "Sunday") end end end xml.send("m:MailboxDataArray") do xml.send("t:MailboxData") do xml.send("t:Email") do xml.send("t:Address", email_address) end xml.send("t:AttendeeType", "Required") xml.send("t:ExcludeConflicts", "false") end end xml.send("t:FreeBusyViewOptions") do xml.send("t:TimeWindow") do xml.send("t:StartTime", start_date_time) xml.send("t:EndTime", end_date_time) end xml.send("t:MergedFreeBusyIntervalInMinutes", 60) xml.send("t:RequestedView", "DetailedMerged") end end end end end end |