Class: Ratis::Request
- Inherits:
-
Object
- Object
- Ratis::Request
- Extended by:
- Savon::Model
- Defined in:
- lib/ratis/request.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config = nil) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(config = nil) ⇒ Request
Returns a new instance of Request.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ratis/request.rb', line 7 def initialize(config = nil) config = Ratis.config if config.nil? raise Errors::ConfigError('It appears that Ratis.configure has not been called') unless config.valid? self.class.client do wsdl.endpoint = Ratis.config.endpoint wsdl.namespace = Ratis.config.namespace http.proxy = Ratis.config.proxy unless Ratis.config.proxy.blank? http.open_timeout = Ratis.config.timeout unless Ratis.config.timeout.blank? end rescue ArgumentError => e raise ArgumentError.new 'Invalid ATIS SOAP server configuration: ' + e. end |
Class Method Details
.get(action, params = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ratis/request.rb', line 21 def self.get(action, params = {}) begin raise Errors::ConfigError, 'It appears that Ratis.configure has not been called or properly setup' unless Ratis.config.valid? # ClassMethods from Savon::Model # Necessary since calling Ratis.configure doesn't allow changing of values set during Savon initialization # Savon memoizes the client config endpoint(Ratis.config.endpoint) namespace(Ratis.config.namespace) response = client.request action, :soap_action => "#{Ratis.config.namespace}##{action}", :xmlns => Ratis.config.namespace do soap.body = params unless params.blank? end # version = response.to_hash["#{action.downcase}_response".to_sym][:version] response rescue Errno::ECONNREFUSED => e raise Errno::ECONNREFUSED.new 'Refused request to ATIS SOAP server' rescue Savon::SOAP::Fault => e raise Errors::SoapError.new e rescue Timeout::Error => e raise "TIMEOUT!" end end |