Module: ProjectorPWS::Legacy

Defined in:
lib/projector_pws/legacy.rb

Overview

Legacy Module: Provides access to Legacy Web Services

Constant Summary collapse

WSDL =

Service Definition

'https://secure.projectorpsa.com/OpsProjectorWebSvc/OpsProjectorSvc.asmx?wsdl'
URL_PATH =

URL Path

'OpsProjectorWebSvc/OpsProjectorSvc.asmx'
BASE_URL =

Base URL

'https://secure.projectorpsa.com'

Class Method Summary collapse

Class Method Details

.export_resources(url, username, password, account_code = nil) ⇒ Object

Export Resources



54
55
56
# File 'lib/projector_pws/legacy.rb', line 54

def self.export_resources url, username, password,  = nil
  with_auth(username, password, , url) { |c, params| c.call(:export_resources, params.merge(message: { request: { 'Parameters' => {} } })).body[:export_resources_response][:export_resources_result][:data][:resources][:resource] }
end

.get_url(username, password, account_code = nil) ⇒ Object

Get URL for Account



49
50
51
# File 'lib/projector_pws/legacy.rb', line 49

def self.get_url username, password,  = nil
  with_auth(username, password, ) { |c, params| c.call(:get_web_service_url, params).body[:get_web_service_url_response][:get_web_service_url_result][:web_service_url] }
end

.open(url = BASE_URL) ⇒ Object

Open Client



29
30
31
32
33
# File 'lib/projector_pws/legacy.rb', line 29

def self.open url = BASE_URL
  c = Savon.client soap_version: 2, wsdl: WSDL, endpoint: service_url(url), env_namespace: :soap
  return yield c if block_given?
  c
end

.service_url(base_url) ⇒ Object

Generate Service URL



59
60
61
# File 'lib/projector_pws/legacy.rb', line 59

def self.service_url base_url
  "#{base_url}/#{URL_PATH}"
end

.with_auth(username, password, account_code = nil, url = BASE_URL) ⇒ Object

Pass with Authenticate



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/projector_pws/legacy.rb', line 36

def self.with_auth username, password,  = nil, url = BASE_URL

  # Prepare Creds
  creds = {}
  creds['tns:AccountName'] =  if 
  creds['tns:EmailAddress'] = username
  creds['tns:Password'] = password

  # Open API
  open(url) { |c| yield c, { message: {}, soap_header: { 'tns:OpsAuthenticationHeader' => creds } } }
end