Syntax
GetClient()
Description
The GetClient operation is used toreturn all clients data needed including accounts list and child clients list,
needed to build your clients tree after logging on.
Request Parameters
This operation takes no parameters.
Response Elements
Name | Description |
Result |
In case of success, this operation returns an object of type Client that holds the following members:
Otherwise see Error codes. |
Sample
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>GetClient</title><script src="http://code.jquery.com/jquery-latest.js"></script></head><script >$(document).ready(function () {var urlStr = "http://webtrader.hybridsolutions.com/publicweb/webservice.svc";jQuery.support.cors = true;$("#progress").ajaxStart(function () { $(this).css("display", "block"); });$("#progress").ajaxComplete(function () { $(this).css("display", "none"); });function onSuccessResult(response) {response = eval('(' + response + ')')if (response.UserId == -1 || response.UserId == -207) {$("#resultData").html("Invalid username or password");}else if (response.UserId == -231) {$("#resultData").html("You must have at least one account");}else if (response == null || response == "" || response.UserId < 0) {$("#resultData").html("Error while login.Please try later");}else {$("#resultData").html("SuccessResult ... UserId is :" + response.UserId);}}$("#resultAction").ajaxError(function (result) { $(this).html('An error occured'); });function onErrorResult(result) {alert('Service call failed : ' + result.status + ' ' + result.statusText);}$("#btnLogin").click(function () {$.getJSON(urlStr + "/Login?username=" + $("#txtusername").val() + "&password=" + $("#txtpassword").val() + "&callback=?", onSuccessResult);});$("#btnAction").click(function () {$.getJSON(urlStr + "/GetClient?" + "callback=?", onSuccessResult);function onSuccessResult(dataResult) {dataResult = eval('(' + dataResult + ')');var acc = "";if (dataResult.ClientID > 0) {var clientType = "client";var AccountType = "Demo";var liqType = "margin";if (dataResult.ClientType == 1) { clientType = "Client"; acc += "Client Type: Client " }else if (dataResult.ClientType == 2) { clientType = "office"; acc += "Client Type: office " }else { clientType = "group"; acc += "Client Type: group " }acc += "<li align='left'> First name: " + dataResult.FirstName + "</li>";acc += "<li align='left'> Enable Interest: " + dataResult.EnableInterest + "</li>";acc += "<li align='left'> liquidation Point: " + dataResult.LiqPoint + "</li>";acc += "<li align='left'> Client ID: " + dataResult.ClientID + "</li>";if (dataResult.LiqType == 1 ) {liqType = " Equity ";}else {liqType = "Margin level ";}acc += "<li align='left'> Liquidate Type: " + liqType + "</li>";for (var i = 0; i < dataResult.Accounts.length; i++) {acc += "<li>Account Id :" + dataResult.Accounts[i].AccountID + "</a></li>";if (dataResult.Accounts[i].AccountType = 0 ){AccountType = "Demo Account ";}else if (dataResult.Accounts[i].AccountType = 1){AccountType = "Normal account ";}else {AccountType = "Coverage account ";}acc += "<li>Account Type : " + AccountType + "</a></li>";acc += "<li>Is Margin : " + dataResult.Accounts[i].IsMargin + "</a></li>";acc += "<li>Demo Account : " + dataResult.Accounts[i].DemoAccount + "</a></li>";acc += "<li>Lock Liquidate : " + dataResult.Accounts[i].LockLiquidate + "</a></li>"; }if (dataResult.ChildClients) {acc += "ChildClients are :";for (var x = 0; x < dataResult.ChildClients.length; x++) {for (var i = 0; i < dataResult.ChildClients[x].Accounts.length; i++) {acc += "<br>";acc += "<br>";acc += "<li>Account Id :" + dataResult.ChildClients[x].Accounts[i].AccountID + "</a></li>";if (dataResult.ChildClients[x].Accounts[i].AccountType = 0 ){AccountType = "Demo Account ";}else if (dataResult.ChildClients[x].Accounts[i].AccountType = 1){AccountType = "Normal account ";}else {AccountType = "Coverage account ";}acc += "<li>Account Type : " + AccountType + "</a></li>";acc += "<li>Is Margin : " + dataResult.ChildClients[x].Accounts[i].IsMargin + "</a></li>";acc += "<li>Demo Account : " + dataResult.ChildClients[x].Accounts[i].DemoAccount + "</a></li>";acc += "<li>Lock Liquidate : " + dataResult.ChildClients[x].Accounts[i].LockLiquidate + "</a></li>"; }}}acc += "</ul></li>";$("#resultAction").html(acc);}}});});</script><body><table border="1px"><tbody><tr><td>Username: <input type="text" id="txtusername" value=""/>Password: <input type="text" id="txtpassword" value=""/><button id="btnLogin"> Login </button></td></tr><tr><td><button id="btnAction"> GetClient </button></td></tr></tbody></table><div id="resultData"> </div><div id="resultAction"> </div><div style="display:none" id="progress">Loading ... </div></body></html>
See Also