lib/moneta.rb in ugalic_moneta-0.0.1 vs lib/moneta.rb in ugalic_moneta-0.0.2
- old
+ new
@@ -7,11 +7,11 @@
key_file = params_hash[:key_file]
key_pwd = params_hash[:key_pwd]
cert_file = params_hash[:cert_file]
ca_cert_file = params_hash[:ca_cert_file]
wsdl_path = params_hash[:wsdl_file]
-
+ @namespace = params_hash[:namespace]
HTTPI::Adapter.use = :net_http
@client = Savon::Client.new do
wsdl.document = wsdl_path
http.auth.ssl.verify_mode = :none
@@ -30,44 +30,56 @@
"iis6-feature" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec porta libero eu neque hendrerit vel volutpat sapien aliquam. Aenean suscipit porta leo, in iaculis est ornare id. Vivamus dignissim vulputate sapien, sed euismod tellus ultrices ut. Pellentesque quam odio, varius vel tempus at, gravida nec mauris. Vestibulum sodales scelerisque nunc sit amet vulputate. Praesent iaculis ipsum vel leo luctus sodales."
}
end
end
- def login(pin=nil)
- savon_call(:log_in, {:pin => pin}).to_hash
+ def login(*args)
+ soap_body = args.first
+ savon_call(:log_in, soap_body).to_hash
rescue Exception => ex
{error_code: -1, error_description: ex.message}
end
- def token(amount, pin=nil)
- soap_body = {:amount => amount}
- soap_body[:pin] = pin unless pin.nil?
+ def token(*args)
+ soap_body = args.first
savon_call(:get_token, soap_body).to_hash #amount should be in format "x.xx CURRENCY"
rescue Exception => ex
{ error_code: -1, error_description: ex.message }
end
- def transaction_status(transaction_id, pin=nil)
- soap_body = {:transaction_id => transaction_id}
- soap_body[:pin] = pin unless pin.nil?
+ def transaction_status(*args)
+ soap_body = args.first
savon_call(:get_transaction_status, soap_body).to_hash
rescue Exception => ex
{error_code: -1, error_description: ex.message}
end
- def transaction_list(date, pin=nil)
- soap_body = {:date => date}
- soap_body[:pin] = pin unless pin.nil?
+ def transaction_list(*args)
+ soap_body = args.first
savon_call(:get_transaction_list, soap_body).to_hash
rescue Exception => ex
{error_code: -1, error_description: ex.message}
end
+ def reverse(*args)
+ soap_body = args.first
+ savon_call(:reverse, soap_body).to_hash
+ rescue Exception => ex
+ {error_code: -1, error_description: ex.message}
+ end
+
+ def cancel_transaction(*args)
+ soap_body = args.first
+ savon_call(:cancel_transaction, soap_body).to_hash
+ rescue Exception => ex
+ {error_code: -1, error_description: ex.message}
+ end
+
private
def savon_call(method, body)
- envelope = @client.request :soap, method, :xmlns => 'http://www.mpay.si/mgw/ekanali/public/2007/03/29' do
- soap.body = body
+ envelope = @client.request :soap, method, :xmlns => @namespace do
+ soap.body = body unless body.empty?
end
end
end
end
\ No newline at end of file