Created
April 10, 2013 21:05
-
-
Save arieliten/5358425 to your computer and use it in GitHub Desktop.
Script to test Cutopia's API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
gem 'savon', '=1.1.0' | |
require 'savon' | |
WSDL_URL = "https://testenv.w-w-i-s.com/hb/51/api.asmx?wsdl" | |
HMAC = 'string' | |
CLIENT_ID = 'AHHRV' | |
MAIN_HEADER = { | |
'Credentials' => { | |
'HMac' => HMAC, | |
'ClientID' => CLIENT_ID, | |
'UserName' => 'ariel1234', | |
'Password' => 'worldwide1' | |
} | |
} | |
puts "Testing connection to endpoint API: '#{WSDL_URL}' ..." | |
client = Savon.client do |wsdl, http| | |
wsdl.document = WSDL_URL | |
http.auth.ssl.verify_mode = :none | |
end | |
# Showing operations | |
operations = client.wsdl.soap_actions | |
puts "The operations available to call on this endpoint are:" | |
operations.each do |op| | |
puts "\t+ #{op}" | |
end | |
# === Get Accounts === | |
# <soap:Envelope xmlns="http://www.w-w-i-s.com/hb/51" | |
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
# xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
# xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" > | |
# <soap:Header> | |
# <Credentials> | |
# <HMac>string</HMac> | |
# <ClientID>AHHRV</ClientID> | |
# <UserName>ariel1234</UserName> | |
# <Password>worldwide1</Password> | |
# <!--<SessionKey>3ucvciuejbtf1yeu4fpsnfuj</SessionKey>--> | |
# </Credentials> | |
# </soap:Header> | |
# <soap:Body> | |
# <GetAccounts> | |
# <accttype>All</accttype> | |
# <skiprefresh>false</skiprefresh> | |
# </GetAccounts> | |
# </soap:Body> | |
# </soap:Envelope> | |
body = { | |
'GetAccounts' => { | |
'accttype' => "All", | |
'skiprefresh' => 'false' | |
} | |
} | |
response = client.request :soap, :get_accounts do | |
soap.header = MAIN_HEADER | |
soap.body = body | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment