Created
June 18, 2016 00:35
-
-
Save CodingFu/752369f672efbf3acbb60580332d7a84 to your computer and use it in GitHub Desktop.
This file contains 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
var request = require('request'); | |
var pd = require('pretty-data').pd; | |
var xml2json = require('xml2json'); | |
function buildSoapEnvelope(methodName, requestData, opts) { | |
return ` | |
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> | |
<Body> | |
<${methodName} xmlns="http://clients.mindbodyonline.com/api/0_5"> | |
<Request> | |
<SourceCredentials> | |
<SourceName>Gigster</SourceName> | |
<Password>leoAHgn2/MpcvIKxTJoNidDbMcQ=</Password> | |
<SiteIDs> | |
<int>-99</int> | |
</SiteIDs> | |
</SourceCredentials> | |
${"<!-- Some other data -->"} | |
</Request> | |
</${methodName}> | |
</Body> | |
</Envelope>`; | |
} | |
request({ | |
uri: 'https://api.mindbodyonline.com/0_5/ClientService.asmx', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'text/xml;charset=UTF-8', | |
'SOAPAction': "\"http://clients.mindbodyonline.com/api/0_5/GetRequiredClientFields\"" | |
}, | |
body: buildSoapEnvelope('GetRequiredClientFields') | |
}, function(err, resp, body) { | |
console.log(pd.xml(body)); | |
console.log(pd.json(xml2json.toJson(body))); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment