Class: PlatformLib::BusinessService

Inherits:
Object
  • Object
show all
Defined in:
lib/platform_lib/business_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ BusinessService

Returns a new instance of BusinessService.



8
9
10
11
12
13
14
# File 'lib/platform_lib/business_service.rb', line 8

def initialize(username, password)
  @username = username
  @password = password
  @auth_token = nil

  @services = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/platform_lib/business_service.rb', line 16

def method_missing(method_name, *args)
  if method_name =~ /^(.*)_service$/
    service_by_name($1)
  else
    super
  end
end

Instance Method Details

#sign_outObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/platform_lib/business_service.rb', line 24

def sign_out
  return if @auth_token.nil?
  
  url = AUTH_URL_FORMAT.sub(/ACTION/, 'signOut')
  url << "&_token=#{@auth_token}"
  uri = URI.parse(url)

  response = WebHelper::get(uri, :user => @username, :pass => @password)
  @auth_token = nil
  @services.clear
end