string AddQueryAndAutorize(MethodsType method, Dictionary <string, string> query = null, object objectBody = null) { if (autorization == Autorization.NONE) { client.AddQuery(query); } else if (autorization == Autorization.MARKET) { if (!session.IsMarketAutorized) { throw new UnautorizedClientException("Client is unautorized, use SetAutorizationData() method for autorize client, " + "method required public api key."); } client.AddQuery(query); client.AddOwnHeaderToRequest("X-MBX-APIKEY", session.PublicKey); } else if (autorization == Autorization.TRADING) { if (!session.IsTradingAutorized) { throw new UnautorizedClientException("Client is unautorized, use SetAutorizationData() method for autorize client, " + "method required public and private api key."); } client.AddOwnHeaderToRequest("X-MBX-APIKEY", session.PublicKey); string totalParmas = string.Empty; if (query != null) { totalParmas += client.AddQuery(query); } string body = string.Empty; if (objectBody != null) { body = ObjectToQueryConverter.Convert(objectBody); if (method != MethodsType.POST) { totalParmas += client.AddStringToEndOfQuery("&" + body); } else { totalParmas += body; } } else { if (method == MethodsType.POST) { body = "null"; totalParmas += body; } } if (query != null) { client.AddStringToEndOfQuery("&signature=" + HashManager.HashHMACHex(session.PrivateKey, totalParmas.Substring(1))); } else { client.AddStringToEndOfQuery("?signature=" + HashManager.HashHMACHex(session.PrivateKey, totalParmas.Substring(1))); } if (method == MethodsType.POST) { return(body); } } return(""); }