Module: Viewpoint::EWS::SOAP::ExchangeTimeZones

Includes:
Viewpoint::EWS::SOAP
Included in:
ExchangeWebService
Defined in:
lib/ews/soap/exchange_time_zones.rb

Constant Summary

Constants included from Viewpoint::EWS::SOAP

ActiveDirectory, ActiveDirectoryContacts, Contacts, ContactsActiveDirectory, HARD_DELETE, MOVE_TO_DELETED_ITEMS, NAMESPACES, NS_EWS_MESSAGES, NS_EWS_TYPES, NS_SOAP, SOFT_DELETE, VERSION_2007, VERSION_2007_SP1, VERSION_2010, VERSION_2010_SP1, VERSION_2010_SP2, VERSION_2013, VERSION_NONE

Instance Method Summary collapse

Methods included from Viewpoint::EWS::SOAP

#initialize

Instance Method Details

#get_time_zones(full = false, ids = nil) ⇒ Array

TODO:

Implement TimeZoneDefinition with sub elements Periods, TransitionsGroups and Transitions

Request list of server known time zones

Examples:

Retrieving server zime zones

ews_client = Viewpoint::EWSClient.new # ...
zones = ews_client.ews.get_time_zones

Parameters:

  • full (Boolean) (defaults to: false)

    Request full time zone definition? Returns only name and id if false.

  • ids (Array) (defaults to: nil)

    Returns only the specified time zones instead of all if present

Returns:

  • (Array)

    Array of Objects responding to #id() and #name()



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ews/soap/exchange_time_zones.rb', line 14

def get_time_zones(full = false, ids = nil)
  req = build_soap! do |type, builder|
    unless type == :header
      builder.get_server_time_zones!(full: full, ids: ids)
    end
  end
  result = do_soap_request req, response_class: EwsSoapResponse

  if result.success?
    zones = []
    result.response_messages.each do |message|
      elements = message[:get_server_time_zones_response_message][:elems][:time_zone_definitions][:elems]
      elements.each do |definition|
        data = {
            id: definition[:time_zone_definition][:attribs][:id],
            name: definition[:time_zone_definition][:attribs][:name]
        }
        zones << OpenStruct.new(data)
      end
    end
    zones
  else
    raise EwsError, "Could not get time zones"
  end
end

#set_time_zone_context(id) ⇒ Object

Sets the time zone context header

Examples:

Set time zone context for connection

ews_client = Viewpoint::EWSClient.new # ...
ews_client.set_time_zone 'AUS Central Standard Time'
# subsequent request will send the TimeZoneContext header

Parameters:

  • id (String)

    Identifier of a Microsoft well known time zone

See Also:



47
48
49
50
51
52
53
# File 'lib/ews/soap/exchange_time_zones.rb', line 47

def set_time_zone_context(id)
  if id
    @time_zone_context = {id: id}
  else
    @time_zone_context = nil
  end
end