Class: Viewpoint::EWS::SOAP::ExchangeWebService

Inherits:
Object
  • Object
show all
Includes:
Viewpoint::EWS, Viewpoint::EWS::SOAP, ExchangeAvailability, ExchangeDataServices, ExchangeNotification, ExchangeSynchronization, ExchangeUserConfiguration
Defined in:
lib/ews/soap/exchange_web_service.rb

Constant Summary

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 Attribute Summary (collapse)

Attributes included from Viewpoint::EWS

#logger

Instance Method Summary (collapse)

Methods included from ExchangeSynchronization

#sync_folder_hierarchy, #sync_folder_items

Methods included from ExchangeUserConfiguration

#get_user_configuration

Methods included from ExchangeAvailability

#get_user_oof_settings, #set_user_oof_settings

Methods included from ExchangeNotification

#get_events, #pull_subscribe_folder, #push_subscribe_folder, #subscribe, #unsubscribe

Methods included from ExchangeDataServices

#convert_id, #copy_folder, #copy_item, #create_attachment, #create_folder, #create_item, #delete_folder, #delete_item, #empty_folder, #expand_dl, #find_folder, #find_item, #get_attachment, #get_folder, #get_item, #move_folder, #move_item, #resolve_names, #send_item, #update_folder, #update_item

Methods included from Viewpoint::EWS

root_logger

Constructor Details

- (ExchangeWebService) initialize(connection, opts = {})

A new instance of ExchangeWebService

Parameters:

  • connection (Viewpoint::EWS::Connection)

    the connection object

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

    additional options to the web service

Options Hash (opts):

  • :server_version (String)

    what version to target with the requests. Must be one of the contants VERSION_2007, VERSION_2007_SP1, VERSION_2010, VERSION_2010_SP1, VERSION_2010_SP2, or VERSION_NONE. The default is VERSION_2010.



37
38
39
40
41
42
43
# File 'lib/ews/soap/exchange_web_service.rb', line 37

def initialize(connection, opts = {})
  super()
  @connection = connection
  @server_version = opts[:server_version] ? opts[:server_version] : VERSION_2010
  @auto_deepen    = true
  @no_auto_deepen_behavior = :raise
end

Instance Attribute Details

- (Object) auto_deepen

Returns the value of attribute auto_deepen



29
30
31
# File 'lib/ews/soap/exchange_web_service.rb', line 29

def auto_deepen
  @auto_deepen
end

- (Object) connection

Returns the value of attribute connection



29
30
31
# File 'lib/ews/soap/exchange_web_service.rb', line 29

def connection
  @connection
end

- (Object) no_auto_deepen_behavior

Returns the value of attribute no_auto_deepen_behavior



29
30
31
# File 'lib/ews/soap/exchange_web_service.rb', line 29

def no_auto_deepen_behavior
  @no_auto_deepen_behavior
end

- (Object) server_version

Returns the value of attribute server_version



29
30
31
# File 'lib/ews/soap/exchange_web_service.rb', line 29

def server_version
  @server_version
end

Instance Method Details

- (Object) add_delegate(owner, delegate, permissions)

Adds one or more delegates to a principal's mailbox and sets specific access permissions.

Parameters:

  • owner (String)

    The user that is delegating permissions

  • delegate (String)

    The user that is being given delegate permission

  • permissions (Hash)

    A hash of permissions that will be delegated. This Hash will eventually be passed to add_hierarchy! in the builder so it is in that format.

See Also:



83
84
85
86
87
88
89
90
91
# File 'lib/ews/soap/exchange_web_service.rb', line 83

def add_delegate(owner, delegate, permissions)
  action = "#{SOAP_ACTION_PREFIX}/AddDelegate"
  resp = invoke("#{NS_EWS_MESSAGES}:AddDelegate", action) do |root|
    build!(root) do
      add_delegate!(owner, delegate, permissions)
    end
  end
  parse_soap_response(resp)
end

- (Object) create_managed_folder



53
54
55
56
57
58
59
# File 'lib/ews/soap/exchange_web_service.rb', line 53

def create_managed_folder
  action = "#{SOAP_ACTION_PREFIX}/CreateManagedFolder"
  resp = invoke("#{NS_EWS_MESSAGES}:CreateManagedFolder", action) do |create_managed_folder|
    build_create_managed_folder!(create_managed_folder)
  end
  parse_create_managed_folder(resp)
end

- (Object) delete_attachment



45
46
47
48
49
50
51
# File 'lib/ews/soap/exchange_web_service.rb', line 45

def delete_attachment
  action = "#{SOAP_ACTION_PREFIX}/DeleteAttachment"
  resp = invoke("#{NS_EWS_MESSAGES}:DeleteAttachment", action) do |delete_attachment|
    build_delete_attachment!(delete_attachment)
  end
  parse_delete_attachment(resp)
end

- (Object) do_soap_request(soapmsg, opts = {})

TODO:

make this work for Viewpoint (imported from SPWS)

Send the SOAP request to the endpoint and parse it.

Parameters:

  • soapmsg (String)

    an XML formatted string

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

    misc options

Options Hash (opts):

  • :raw_response (Boolean)

    if true do not parse and return the raw response string.



173
174
175
176
177
178
179
180
181
# File 'lib/ews/soap/exchange_web_service.rb', line 173

def do_soap_request(soapmsg, opts = {})
  @log.debug <<-EOF.gsub(/^ {8}/, '')
    Sending SOAP Request:
    ----------------
    #{soapmsg}
    ----------------
  EOF
  connection.dispatch(self, soapmsg, opts)
end

- (Object) get_delegate(owner)

Retrieves the delegate settings for a specific mailbox.

Parameters:

  • owner (String)

    The user that is delegating permissions

See Also:



65
66
67
68
69
70
71
72
73
74
# File 'lib/ews/soap/exchange_web_service.rb', line 65

def get_delegate(owner)
  action = "#{SOAP_ACTION_PREFIX}/GetDelegate"
  resp = invoke("#{NS_EWS_MESSAGES}:GetDelegate", action) do |root|
    root.set_attr('IncludePermissions', 'true')
    build!(root) do
      mailbox!(root, {:email_address => {:text => owner}})
    end
  end
  parse_soap_response(resp)
end

- (Object) get_user_availability(opts)

TODO:

Finish out :suggestions_view_options

Provides detailed information about the availability of a set of users, rooms, and resources within a specified time window.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :time_zone (Hash)

    The TimeZone data Example: => 'UTC offset in minutes', :standard_time => {:bias => 480, :time => '02:00:00',

    :day_order => 5, :month => 10, :day_of_week => 'Sunday',

    :daylight_time => {same options as :standard_time}}

  • :mailbox_data (Array<Hash>)

    Data for the mailbox to query Example: [=> 'Organizer|Required|Optional|Room|Resource', :email =>{:name => 'name', :address => 'email', :routing_type => 'SMTP', :exclude_conflicts => true|false }]

  • :free_busy_view_options (Hash)

    Example: => {:start_time => DateTime,:end_time => DateTime, :merged_free_busy_interval_in_minutes => minute_int, :requested_view => None|MergedOnly|FreeBusy|FreeBusyMerged|Detailed

    |DetailedMerged} (optional)
  • :suggestions_view_options (Hash) — default: optional

See Also:



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/ews/soap/exchange_web_service.rb', line 145

def get_user_availability(opts)
  opts = opts.clone
  req = build_soap! do |type, builder|
    if(type == :header)
    else
    builder.nbuild.GetUserAvailabilityRequest {|x|
      x.parent.default_namespace = @default_ns
      builder.time_zone!(opts[:time_zone])
      builder.nbuild.MailboxDataArray {
      opts[:mailbox_data].each do |mbd|
        builder.mailbox_data!(mbd)
      end
      }
      builder.free_busy_view_options!(opts[:free_busy_view_options])
      builder.suggestions_view_options!(opts[:suggestions_view_options])
    }
    end
  end

  do_soap_request(req, response_class: EwsSoapFreeBusyResponse)
end

- (Object) parse_soap_response(soapmsg, opts = {})

Parameters:

  • response (String)

    the SOAP response string

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

    misc options to send to the parser

Options Hash (opts):

  • :response_class (Class)

    the response class

Raises:



186
187
188
189
190
# File 'lib/ews/soap/exchange_web_service.rb', line 186

def parse_soap_response(soapmsg, opts = {})
  raise EwsError, "Can't parse an empty response. Please check your endpoint." if(soapmsg.nil?)
  opts[:response_class] ||= EwsSoapResponse
  EwsParser.new(soapmsg).parse(opts)
end

- (Object) remove_delegate(owner, delegate)

Removes one or more delegates from a user's mailbox.

Parameters:

  • owner (String)

    The user that is delegating permissions

  • delegate (String)

    The user that is being given delegate permission

See Also:



98
99
100
101
102
103
104
105
106
# File 'lib/ews/soap/exchange_web_service.rb', line 98

def remove_delegate(owner, delegate)
  action = "#{SOAP_ACTION_PREFIX}/RemoveDelegate"
  resp = invoke("#{NS_EWS_MESSAGES}:RemoveDelegate", action) do |root|
    build!(root) do
      remove_delegate!(owner, delegate)
    end
  end
  parse_soap_response(resp)
end

- (Object) update_delegate(owner, delegate, permissions)

Updates delegate permissions on a principal's mailbox

Parameters:

  • owner (String)

    The user that is delegating permissions

  • delegate (String)

    The user that is being given delegate permission

  • permissions (Hash)

    A hash of permissions that will be delegated. This Hash will eventually be passed to add_hierarchy! in the builder so it is in that format.

See Also:



115
116
117
118
119
120
121
122
123
# File 'lib/ews/soap/exchange_web_service.rb', line 115

def update_delegate(owner, delegate, permissions)
  action = "#{SOAP_ACTION_PREFIX}/UpdateDelegate"
  resp = invoke("#{NS_EWS_MESSAGES}:UpdateDelegate", action) do |root|
    build!(root) do
      add_delegate!(owner, delegate, permissions)
    end
  end
  parse_soap_response(resp)
end