Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created April 6, 2011 11:06
Show Gist options
  • Save rubiii/905477 to your computer and use it in GitHub Desktop.
Save rubiii/905477 to your computer and use it in GitHub Desktop.
Savon InterFAX example: Information about the last 10 inbound faxes
# more examples at:
# https://gist.github.com/903337
require "rubygems"
# $ gem install savon (works with v0.9.1 and higher)
require "savon"
# convert hash key symbols to camelcase
Gyoku.convert_symbols_to(:camelcase)
# create a client using the InterFAX WSDL
client = Savon::Client.new("http://ws.interfax.net/inbound.asmx?WSDL")
# execute a request to the :get_list action
response = client.request(:int, :get_list) do
soap.body = {
:username => "your username",
:password => "your password",
:l_type => "AllMessages",
:max_items => 10
}
end
# translate the response to an Array and get the result
items = response.to_array(:get_list_response, :obj_message_item, :message_item)
# print the message ID of each item
items.each { |item| p item[:message_id] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment