Class: Symgate::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/symgate/client.rb

Overview

A generic client for the Symgate API. See the WSDL for full documentation

Direct Known Subclasses

Auth::Client, Metadata::Client, Wordlist::Client

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Constructs a new client with the provided options


13
14
15
16
17
18
19
20
21
# File 'lib/symgate/client.rb', line 13

def initialize(opts = {})
  @wsdl = 'https://ws.widgitonline.com/schema/symboliser.wsdl'
  @endpoint = 'https://ws.widgitonline.com/'
  @savon_opts = {}
  opts.each { |k, v| instance_variable_set("@#{k}", v) }

  validate_client_options
  create_savon_client
end

Instance Attribute Details

#accountObject

Returns the value of attribute account


9
10
11
# File 'lib/symgate/client.rb', line 9

def 
  @account
end

#endpointObject

Returns the value of attribute endpoint


9
10
11
# File 'lib/symgate/client.rb', line 9

def endpoint
  @endpoint
end

#keyObject

Returns the value of attribute key


9
10
11
# File 'lib/symgate/client.rb', line 9

def key
  @key
end

#passwordObject

Returns the value of attribute password


9
10
11
# File 'lib/symgate/client.rb', line 9

def password
  @password
end

#savon_clientObject (readonly)

Returns the value of attribute savon_client


10
11
12
# File 'lib/symgate/client.rb', line 10

def savon_client
  @savon_client
end

#savon_optsObject

Returns the value of attribute savon_opts


9
10
11
# File 'lib/symgate/client.rb', line 9

def savon_opts
  @savon_opts
end

#tokenObject

Returns the value of attribute token


9
10
11
# File 'lib/symgate/client.rb', line 9

def token
  @token
end

#userObject

Returns the value of attribute user


9
10
11
# File 'lib/symgate/client.rb', line 9

def user
  @user
end

#wsdlObject

Returns the value of attribute wsdl


9
10
11
# File 'lib/symgate/client.rb', line 9

def wsdl
  @wsdl
end

Class Method Details

.savon_array(hash, key, classname = nil) ⇒ Object

returns an array from 0 or more items when an array is expected. (savon returns a single value for things that can be a sequence of multiple objects) expects a hash, and a key for the array within that hash. if classname is specified, the method will return an array of objects initialised by the hash contents


28
29
30
31
32
33
34
# File 'lib/symgate/client.rb', line 28

def self.savon_array(hash, key, classname = nil)
  if hash && hash.include?(key)
    [hash[key]].flatten
  else
    []
  end.map { |v| classname ? classname.from_soap(v) : v }
end