Class: Viewpoint::EWSClient

Overview

This class is the glue between the Models and the Web Service.

Constant Summary

Constants included from StringUtils

StringUtils::DURATION_RE

Constants included from EWS

Viewpoint::EWS::ConnectingSID

Constants included from Viewpoint::EWS::FolderAccessors

Viewpoint::EWS::FolderAccessors::FOLDER_TYPE_MAP

Instance Attribute Summary collapse

Attributes included from EWS

#logger

Instance Method Summary collapse

Methods included from StringUtils

included

Methods included from Viewpoint::EWS::MeetingAccessors

#accept_meeting, #decline_meeting, #tentatively_accept_meeting

Methods included from EWS

#remove_impersonation, root_logger, #set_impersonation

Methods included from Viewpoint::EWS::ConvertAccessors

#convert_id

Methods included from Viewpoint::EWS::RoomlistAccessors

#get_room_lists, #roomlist_email, #roomlist_name

Methods included from Viewpoint::EWS::RoomAccessors

#get_rooms, #room_email, #room_name

Methods included from Viewpoint::EWS::CalendarAccessors

#event_busy_type, #event_end_time, #event_start_time

Methods included from Viewpoint::EWS::PushSubscriptionAccessors

#parse_send_notification

Methods included from Viewpoint::EWS::MailboxAccessors

#get_user_availability, #search_contacts

Methods included from Viewpoint::EWS::MessageAccessors

#draft_message, #send_message

Methods included from Viewpoint::EWS::ItemAccessors

#copy_items, #export_items, #find_items, #get_item, #get_items, #move_items

Methods included from Viewpoint::EWS::FolderAccessors

#folders, #get_folder, #get_folder_by_name, #make_folder, #sync_folders

Constructor Details

#initialize(endpoint, username, password, opts = {}) ⇒ EWSClient

Initialize the EWSClient instance.

Parameters:

  • endpoint (String)

    The EWS endpoint we will be connecting to

  • user (String)

    The user to authenticate as. If you are using NTLM or Negotiate authentication you do not need to pass this parameter.

  • pass (String)

    The user password. If you are using NTLM or Negotiate authentication you do not need to pass this parameter.

  • opts (Hash) (defaults to: {})

    Various options to pass to the backends

Options Hash (opts):

  • :server_version (String)

    The Exchange server version to target. See the VERSION_* constants in Viewpoint::EWS::SOAP::ExchangeWebService.

  • :http_class (Object)

    specify an alternate HTTP connection class.

  • :http_opts (Hash)

    options to pass to the connection


42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ews/ews_client.rb', line 42

def initialize(endpoint, username, password, opts = {})
  # dup all. @see ticket https://github.com/zenchild/Viewpoint/issues/68
  @endpoint = endpoint.dup
  @username = username.dup
  password  = password.dup
  opts      = opts.dup
  http_klass = opts[:http_class] || Viewpoint::EWS::Connection
  con = http_klass.new(endpoint, opts[:http_opts] || {})
  con.set_auth @username, password
  @ews = SOAP::ExchangeWebService.new(con, opts)
end

Instance Attribute Details

#endpointObject (readonly)

The instance of Viewpoint::EWS::SOAP::ExchangeWebService


28
29
30
# File 'lib/ews/ews_client.rb', line 28

def endpoint
  @endpoint
end

#ewsObject (readonly)

The instance of Viewpoint::EWS::SOAP::ExchangeWebService


28
29
30
# File 'lib/ews/ews_client.rb', line 28

def ews
  @ews
end

#usernameObject (readonly)

The instance of Viewpoint::EWS::SOAP::ExchangeWebService


28
29
30
# File 'lib/ews/ews_client.rb', line 28

def username
  @username
end

Instance Method Details

#auto_deepen=(deepen) ⇒ Object


68
69
70
# File 'lib/ews/ews_client.rb', line 68

def auto_deepen=(deepen)
  set_auto_deepen deepen
end

#set_auto_deepen(deepen, behavior = :raise) ⇒ Object

Parameters:

  • deepen (Boolean)

    true to autodeepen, false otherwise

  • behavior (Symbol) (defaults to: :raise)

    :raise, :nil When setting autodeepen to false you can choose what the behavior is when an attribute does not exist. The default is to raise a EwsMinimalObjectError.


58
59
60
61
62
63
64
65
66
# File 'lib/ews/ews_client.rb', line 58

def set_auto_deepen(deepen, behavior = :raise)
  if deepen
    ews.auto_deepen = true
  else
    behavior = [:raise, :nil].include?(behavior) ? behavior : :raise
    ews.no_auto_deepen_behavior = behavior
    ews.auto_deepen = false
  end
end

#set_time_zone(microsoft_time_zone_id) ⇒ Object

Note:

A list of time zones known by the server can be requested via Viewpoint::EWS::SOAP::ExchangeTimeZones#get_time_zones

Specify a default time zone context for all time attributes

Parameters:

  • id (String)

    Identifier of a Microsoft well known time zone (e.g: 'UTC', 'W. Europe Standard Time')


75
76
77
# File 'lib/ews/ews_client.rb', line 75

def set_time_zone(microsoft_time_zone_id)
  ews.set_time_zone_context microsoft_time_zone_id
end