Class: AfipWsfe::Client
- Inherits:
-
Object
- Object
- AfipWsfe::Client
- Defined in:
- lib/afip_wsfe/client.rb
Instance Method Summary collapse
- #call_endpoint(endpoint, savon_method, params = {}) ⇒ Object
-
#initialize(authenticate = true) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(authenticate = true) ⇒ Client
Returns a new instance of Client.
3 4 5 6 |
# File 'lib/afip_wsfe/client.rb', line 3 def initialize(authenticate=true) AfipWsfe.environment ||= :test @auth = authenticate ? AfipWsfe.auth_hash : {} end |
Instance Method Details
#call_endpoint(endpoint, savon_method, params = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/afip_wsfe/client.rb', line 8 def call_endpoint(endpoint, savon_method, params={}) return_key = endpoint == :wsaa ? :"#{savon_method}_return" : :"#{savon_method}_result" result = Savon.client( log: AfipWsfe.log?, log_level: AfipWsfe.log_level || :debug, wsdl: "#{AfipWsfe::URLS[AfipWsfe.environment][endpoint]}?wsdl", convert_request_keys_to: :camelcase ).call(savon_method, message: params.merge(@auth)) response = result.body[:"#{savon_method}_response"][return_key] response = Hash.from_xml response if endpoint == :wsaa [result.success?, response] end |