Exemple API - RUBY (Comptage des mail non lu)

Un petit exemple d’utilisation de l’API en Ruby.

# ruby 1.9.3p392 
# gem install savon

require 'savon'
 
client = Savon.client(wsdl: "http://soap.domain.tld:/soap/proxy?wsdl")

response = client.call(:login, message: {arg0: 'admin0@global.virt', arg1: 'password/apikey', arg2: 'ruby'})
token = response.body:login_response]:return].to_hash

response = client.call(:sudo, message: {arg0: token, arg1: 'jdoe@domain.tld'} )
user = response.body:sudo_response]:return].to_hash

nbmails = client.call(:get_unread_mail_count, message: {arg0: user} )
puts "Unread emails : #{nbmails.body:get_unread_mail_count_response]:return]}"  

client.call(:logout, message: {arg0: token})
puts "Logout"