module OracleOWS::Common

common methods to include in all classes

Attributes

namespaces[R]

# @return [OracleOws::Base] base class object holds connection parameters attr_accessor :base @return [Hash] XML namesspaces as hash {#namespaces=} writer method adds more namespaces to the hash

password[RW]

@return [String] url => base URL for the API endpoint @return [String] username => login to use like ENV @return [String] password => password to use like ENV @return [Hash] namespaces => a hash of XML namespaces for SOAP header

Example:
!{
  'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
  'xmlns:cor' => 'http://webservices.micros.com/og/4.3/Core/'
}
url[RW]

@return [String] url => base URL for the API endpoint @return [String] username => login to use like ENV @return [String] password => password to use like ENV @return [Hash] namespaces => a hash of XML namespaces for SOAP header

Example:
!{
  'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
  'xmlns:cor' => 'http://webservices.micros.com/og/4.3/Core/'
}
username[RW]

@return [String] url => base URL for the API endpoint @return [String] username => login to use like ENV @return [String] password => password to use like ENV @return [Hash] namespaces => a hash of XML namespaces for SOAP header

Example:
!{
  'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
  'xmlns:cor' => 'http://webservices.micros.com/og/4.3/Core/'
}

Public Instance Methods

namespaces=(hash = {}) click to toggle source

Merges existing namespaces hash with additional values

@param [Hash] hash of XML namespaces to be used additionally

@return [Hash] hash of all namespaces merged together

# File lib/oracle_ows/common.rb, line 35
def namespaces=(hash = {})
  hash = {} unless hash.is_a? Hash

  @namespaces ||= {}
  @namespaces.merge!(hash)
end

Private Instance Methods

soap_client() click to toggle source

soap client object to make API calls

@return [Savon::Client] client object ready to make calls

# File lib/oracle_ows/common.rb, line 49
def soap_client
  # authentication
  credentials = { 'cor:UserName' => username, 'cor:UserPassword' => password }
  # required SOAP header
  soap_header = { 'cor:OGHeader' => { 'cor:Authentication' => { 'cor:UserCredentials' => credentials } } }
  # logging options
  log_options = { log_level: :debug, log: true, pretty_print_xml: true }
  # class name of caller object
  klass_name = self.class.name.split('::').last
  # WSDL endpoint is derived from ClassName
  options = { wsdl: "#{url}/#{klass_name}.asmx?WSDL", namespaces: namespaces, soap_header: soap_header }
  # SOAP client
  Savon.client(options.merge(log_options))
end