Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created December 22, 2010 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubiii/751742 to your computer and use it in GitHub Desktop.
Save rubiii/751742 to your computer and use it in GitHub Desktop.
using savon to talk to the betfair soap api
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:bfex="http://www.betfair.com/publicapi/v5/BFExchangeService/"
xmlns:v5="http://www.betfair.com/publicapi/types/exchange/v5/">
<soapenv:Header/>
<soapenv:Body>
<bfex:getAllMarkets>
<bfex:request>
<header>
<clientStamp>stamp</clientStamp>
<sessionToken>token</sessionToken>
</header>
<locale>UK</locale>
<eventTypeIds>
<!--Zero or more repetitions:-->
<v5:int>1</v5:int>
</eventTypeIds>
<countries>
<!--Zero or more repetitions:-->
<v5:Country>UK</v5:Country>
</countries>
<fromDate>2010-01-10:10:10:00Z</fromDate>
<toDate>2010-11-10:10:10:00Z</toDate>
</bfex:request>
</bfex:getAllMarkets>
</soapenv:Body>
</soapenv:Envelope>
# solution for https://github.com/rubiii/savon/issues/68
client = Savon::Client.new do
wsdl.endpoint = "https://api.betfair.com/exchange/v5/BFExchangeService"
wsdl.namespace = "http://www.betfair.com/publicapi/v5/BFExchangeService/"
end
client.request :bfex, :get_all_markets do
soap.namespaces["xmlns:v5"] = "http://www.betfair.com/publicapi/types/exchange/v5/"
soap.body = {
"bfex:request" => {
:header => { :client_stamp => "stamp", :session_token => "token" },
:locale => "UK",
:event_type_ids => { "v5:int" => [1, 2] },
:countries => { "v5:Country" => ["DE", "UK"] },
:from_date => 1.year.ago,
:to_date => Time.now
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment