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



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

def initialize(opts = {})
  @wsdl = 'https://ws.widgitonline.com/schema/symboliser.wsdl'
  @endpoint = 'https://ws.widgitonline.com/'
  @savon_opts = {}
  @data_required_error_retries = 3
  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

#data_required_error_retriesObject

Returns the value of attribute data_required_error_retries.



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

def data_required_error_retries
  @data_required_error_retries
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.



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

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



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

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