Sha256: 94879b094b4890b8de59d71b047d0bdd19f3a5ab31c93d2e8f9da6f9ea8c6565
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module Afipws class Client def initialize wsdl_url, env @client = Savon::Client.new do wsdl.document = wsdl_url http.auth.ssl.verify_mode = :none if env == :development # esto está porque el certificado del WSAA había vencido durante las pruebas end end def request action, body = nil response = raw_request(action, body).to_hash[:"#{action}_response"][:"#{action}_result"] if response[:errors] raise WSError, Array.wrap(response[:errors][:err]) else response end end def raw_request action, body = nil @client.request(namespace, action) { soap.body = add_ns_to_keys(body) } end def soap_actions @client.wsdl.soap_actions end def method_missing method_sym, *args request method_sym, *args end private def add_ns_to_keys body case body when Hash Hash[body.map { |k, v| ["#{namespace}:#{camelize(k)}", add_ns_to_keys(v)] }] when Array body.map { |x| add_ns_to_keys x } else body end end def namespace :wsdl end def camelize k k.is_a?(String) ? k : k.to_s.camelize end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
afipws-0.1.8 | lib/afipws/client.rb |