예제 #1
0
        public async System.Threading.Tasks.Task <BalanceResponse> GetBalanceAsync()
        {
            String url      = $"{Host}/getBalance";
            String postData = $"{{\"clientKey\":\"{ClientKey}\"}}";

            Http.Request request = new Http.Request()
            {
                Url         = url,
                Method      = "POST",
                PostData    = postData,
                ContentType = "application/json"
            };

            Http.Response response = await Client.ExecuteAsync(request);

            if (response.StatusCode == 200)
            {
                BalanceResponse balanceResponse = BalanceResponse.ParseFromJson(response.Body);
                return(balanceResponse);
            }
            else
            {
                throw new Exception(response.ToString());
            }
        }
예제 #2
0
        public double?GetBalance()
        {
            var jsonPostData = new JObject();

            jsonPostData["clientKey"] = ClientKey;

            dynamic postResult = JsonPostRequest(ApiMethod.GetBalance, jsonPostData);

            if (postResult == null || postResult.Equals(false))
            {
                DebugHelper.Out("API error", DebugHelper.Type.Error);

                return(null);
            }

            var balanceResponse = new BalanceResponse(postResult);

            if (!balanceResponse.ErrorId.Equals(0))
            {
                ErrorMessage = balanceResponse.ErrorDescription;

                DebugHelper.Out(
                    "API error " + balanceResponse.ErrorId + ": " + balanceResponse.ErrorDescription,
                    DebugHelper.Type.Error
                    );

                return(null);
            }

            return(balanceResponse.Balance);
        }
예제 #3
0
        public double?GetBalance()
        {
            var jsonPostData = new JObject
            {
                ["clientKey"] = ClientKey
            };

            dynamic postResult = JsonPostRequest(ApiMethod.GetBalance, jsonPostData);

            if (postResult?.Equals(false) != false)
            {
                DebugHelper.Out(DebugHelper.Severity.Error, "API error");

                return(null);
            }

            var balanceResponse = new BalanceResponse(postResult);

            if (!balanceResponse.ErrorId.Equals(0))
            {
                ErrorMessage = balanceResponse.ErrorDescription;

                DebugHelper.Out(
                    DebugHelper.Severity.Error
                    ,
                    "API error " + balanceResponse.ErrorId + ": " + balanceResponse.ErrorDescription);

                return(null);
            }

            return(balanceResponse.Balance);
        }