class Stockboy::Providers::SOAP
Fetch data from a SOAP
endpoint
Backed by Savon gem, see savon for full configuration options: extra options are passed through.
Public Class Methods
new(opts={}, &block)
click to toggle source
Initialize a new SOAP
provider
Calls superclass method
Stockboy::Provider::new
# File lib/stockboy/providers/soap.rb, line 156 def initialize(opts={}, &block) super @response_format = opts[:response_format] || :hash DSL.new(self).instance_eval(&block) if block_given? end
Public Instance Methods
client() { |client| ... }
click to toggle source
Connection object to the configured SOAP
endpoint
@return [Savon::Client]
# File lib/stockboy/providers/soap.rb, line 166 def client @client ||= Savon.client(client_options) @client.globals.open_timeout(open_timeout) if open_timeout @client.globals.read_timeout(read_timeout) if read_timeout yield @client if block_given? @client end
Private Instance Methods
client_options()
click to toggle source
# File lib/stockboy/providers/soap.rb, line 176 def client_options opts = if wsdl {wsdl: wsdl} elsif endpoint {endpoint: endpoint} end opts[:open_timeout] = open_timeout if open_timeout opts[:read_timeout] = read_timeout if read_timeout opts[:logger] = logger opts[:log] = logger.debug? opts[:convert_response_tags_to] = ->(tag) { string_pool(tag) } opts[:namespace] = namespace if namespace opts[:namespaces] = namespaces if namespaces opts[:namespace_identifier] = namespace_id if namespace_id opts[:env_namespace] = env_namespace if env_namespace opts[:headers] = headers if headers opts[:wsse_auth] = wsse_auth if wsse_auth opts end
fetch_data()
click to toggle source
# File lib/stockboy/providers/soap.rb, line 201 def fetch_data with_string_pool do response = client.call( @request, message: message, message_tag: message_tag, soap_action: soap_action, soap_header: soap_header, attributes: attributes ) @data = case response_format when :xml response.xml else response.body end end end
validate()
click to toggle source
# File lib/stockboy/providers/soap.rb, line 196 def validate errors << "endpoint or wsdl must be specified" if endpoint.blank? unless wsdl errors.blank? end