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

Inherits:
Object
  • Object
show all
Includes:
Viewpoint::EWS, Viewpoint::EWS::SOAP, ExchangeAvailability, ExchangeDataServices, ExchangeNotification, ExchangeSynchronization, ExchangeTimeZones, ExchangeUserConfiguration, StringUtils
Defined in:
lib/ews/soap/exchange_web_service.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_2013_SP1, VERSION_NONE

Constants included from StringUtils

StringUtils::DURATION_RE

Constants included from Viewpoint::EWS

ConnectingSID

Instance Attribute Summary collapse

Attributes included from Viewpoint::EWS

#logger

Instance Method Summary collapse

Methods included from ExchangeTimeZones

#get_time_zones, #set_time_zone_context

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, #export_items, #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 StringUtils

included

Methods included from Viewpoint::EWS

#remove_impersonation, root_logger, #set_impersonation

Constructor Details

#initialize(connection, opts = {}) ⇒ ExchangeWebService

Returns 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.



39
40
41
42
43
44
45
46
47
# File 'lib/ews/soap/exchange_web_service.rb', line 39

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
  @impersonation_type = ""
  @impersonation_address = ""
end

Instance Attribute Details

#auto_deepenObject

Returns the value of attribute auto_deepen.



31
32
33
# File 'lib/ews/soap/exchange_web_service.rb', line 31

def auto_deepen
  @auto_deepen
end

#connectionObject

Returns the value of attribute connection.



31
32
33
# File 'lib/ews/soap/exchange_web_service.rb', line 31

def connection
  @connection
end

#impersonation_addressObject

Returns the value of attribute impersonation_address.



31
32
33
# File 'lib/ews/soap/exchange_web_service.rb', line 31

def impersonation_address
  @impersonation_address
end

#impersonation_typeObject

Returns the value of attribute impersonation_type.



31
32
33
# File 'lib/ews/soap/exchange_web_service.rb', line 31

def impersonation_type
  @impersonation_type
end

#no_auto_deepen_behaviorObject

Returns the value of attribute no_auto_deepen_behavior.



31
32
33
# File 'lib/ews/soap/exchange_web_service.rb', line 31

def no_auto_deepen_behavior
  @no_auto_deepen_behavior
end

#server_versionObject

Returns the value of attribute server_version.



31
32
33
# File 'lib/ews/soap/exchange_web_service.rb', line 31

def server_version
  @server_version
end

Instance Method Details

#add_delegate(owner, delegate, permissions) ⇒ Object

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:



87
88
89
90
91
92
93
94
95
# File 'lib/ews/soap/exchange_web_service.rb', line 87

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

#create_managed_folderObject



57
58
59
60
61
62
63
# File 'lib/ews/soap/exchange_web_service.rb', line 57

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

#delete_attachmentObject



49
50
51
52
53
54
55
# File 'lib/ews/soap/exchange_web_service.rb', line 49

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

#do_soap_request(soapmsg, opts = {}) ⇒ Object

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.



205
206
207
208
209
210
211
212
213
# File 'lib/ews/soap/exchange_web_service.rb', line 205

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

#get_delegate(owner) ⇒ Object

Retrieves the delegate settings for a specific mailbox.

Parameters:

  • owner (String)

    The user that is delegating permissions

See Also:



69
70
71
72
73
74
75
76
77
78
# File 'lib/ews/soap/exchange_web_service.rb', line 69

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

#get_room_listsObject

Gets the room lists that are available within the Exchange organization.



189
190
191
192
193
194
195
196
197
# File 'lib/ews/soap/exchange_web_service.rb', line 189

def get_room_lists
  req = build_soap! do |type, builder|
    if(type == :header)
    else
      builder.room_lists!
    end
  end
  do_soap_request(req, response_class: EwsSoapRoomlistResponse)
end

#get_rooms(roomDistributionList) ⇒ Object

Gets the rooms that are in the specified room distribution list

Parameters:

  • roomDistributionList (string)

See Also:



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

def get_rooms(roomDistributionList)
  req = build_soap! do |type, builder|
    if(type == :header)
    else
      builder.nbuild.GetRooms {|x|
        x.parent.default_namespace = @default_ns
        builder.room_list!(roomDistributionList)
      }
    end
  end
  do_soap_request(req, response_class: EwsSoapRoomResponse)
end

#get_user_availability(opts) ⇒ Object

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:



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/ews/soap/exchange_web_service.rb', line 149

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

#parse_soap_response(soapmsg, opts = {}) ⇒ Object

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:



218
219
220
221
222
# File 'lib/ews/soap/exchange_web_service.rb', line 218

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

#remove_delegate(owner, delegate) ⇒ Object

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:



102
103
104
105
106
107
108
109
110
# File 'lib/ews/soap/exchange_web_service.rb', line 102

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

#update_delegate(owner, delegate, permissions) ⇒ Object

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:



119
120
121
122
123
124
125
126
127
# File 'lib/ews/soap/exchange_web_service.rb', line 119

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