Class: Groupwise::PostOfficeAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/groupwise/post_office_agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, username, app_name, app_key) ⇒ PostOfficeAgent

Returns a new instance of PostOfficeAgent.



5
6
7
8
9
# File 'lib/groupwise/post_office_agent.rb', line 5

def initialize(endpoint, username, app_name, app_key)
  @endpoint, @username, @app_name, @app_key = endpoint, username, app_name, app_key
  @client = Savon.client(wsdl: wsdl, endpoint: endpoint)
  
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/groupwise/post_office_agent.rb', line 3

def client
  @client
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



3
4
5
# File 'lib/groupwise/post_office_agent.rb', line 3

def endpoint
  @endpoint
end

Instance Method Details

#free_busy(email_addresses, wait_time = 0, start_time = nil, end_time = nil) ⇒ Object



31
32
33
34
35
# File 'lib/groupwise/post_office_agent.rb', line 31

def free_busy(email_addresses, wait_time = 0, start_time = nil, end_time = nil)
  message = { free_busy_session_id: free_busy_session(email_addresses, start_time, end_time) }
  sleep wait_time
  response = authenticated_request(:get_free_busy, message)[:free_busy_info]
end

#logoutObject



25
26
27
28
29
# File 'lib/groupwise/post_office_agent.rb', line 25

def logout
  response = authenticated_request(:logout)
  @session = nil if response[:status][:code] == '0'
  return response
end

#versionObject



11
12
13
14
15
16
# File 'lib/groupwise/post_office_agent.rb', line 11

def version
  @version ||= begin
    body = HTTPI.get(HTTPI::Request.new(endpoint)).body
    version = body.match(/(?<=POA )([^\n\r]*)/).captures.first
  end
end

#wsdlObject



18
19
20
21
22
23
# File 'lib/groupwise/post_office_agent.rb', line 18

def wsdl
  @wsdl ||= begin
    wsdl_version = Groupwise.wsdl_version(version)
    File.expand_path("../../../contrib/novell/GW#{wsdl_version}/groupwise.wsdl", __FILE__)
  end
end