/// <summary> /// Login to the Lmax Trader platform. The appropriate handler will be called back /// on success or failure. The loginCallback should be the main entry point into /// your trading application. From that point you should add listeners to the /// session, subscribe to resources that you're interested in, e.g. OrderBooks /// and call Start on the <see cref="ISession"/>. /// </summary> /// <param name="loginRequest"> /// A <see cref="LoginRequest"/> that contains your login credentials. /// </param> /// <param name="loginCallback"> /// A <see cref="OnLogin"/> callback, fired when you are successfully logged in. /// </param> /// <param name="failureCallback"> /// A <see cref="OnFailure"/> callback, fired when there is a login failure. /// </param> public void Login(LoginRequest loginRequest, OnLogin loginCallback, OnFailure failureCallback) { LoginResponseHandler handler = new LoginResponseHandler(); try { string sessionId; Response response = _httpInvoker.Invoke(_baseUri, loginRequest, _xmlParser, handler, out sessionId); if (response.IsOk) { if (handler.IsOk) { loginCallback(new Session(handler.AccountDetails, _baseUri, _httpInvoker, _xmlParser, sessionId, true)); } else { failureCallback(new FailureResponse(false, handler.FailureType, handler.Message, null)); } } else { failureCallback(new FailureResponse(true, "HttpStatus: " + response.Status + ", for: " + _baseUri + loginRequest.Uri)); } } catch (Exception e) { failureCallback(new FailureResponse(e, "URI: " + _baseUri + loginRequest.Uri)); } }
public bool Register(ServiceModel service, IEnumerable <ApiModel> apis) { ApiCollectionModel model = new ApiCollectionModel { Service = service, Apis = apis }; var json = JsonConvert.SerializeObject(model); var url = StaticConfigs.ServiceCenterDomain + "/Register/Register"; var result = _httpInvoker.Invoke(url, json); return(true); }
public string Invoke(string apiCode, string body) { var api = _apiFinder.Find(apiCode); var service = _serviceFinder.Find(api.ServiceId); ApiContext context = new ApiContext { ApiDescription = api, ServiceDescription = service, Body = body }; return(_httpInvoker.Invoke(context.RequestUrl, body)); }