0% found this document useful (0 votes)
185 views

API BCA With CSharp - Check Balance

This document describes a private method called CheckBalance that retrieves a user's account balance information from an API using C#. The method first gets an authentication token, generates a timestamp and signature for the request, makes a GET request to the specified relative URL endpoint with these headers, deserializes the JSON response into a BalanceInformationResponse object and returns it. If any exceptions occur, they are written to the console and null is returned.

Uploaded by

Roni Stiawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views

API BCA With CSharp - Check Balance

This document describes a private method called CheckBalance that retrieves a user's account balance information from an API using C#. The method first gets an authentication token, generates a timestamp and signature for the request, makes a GET request to the specified relative URL endpoint with these headers, deserializes the JSON response into a BalanceInformationResponse object and returns it. If any exceptions occur, they are written to the console and null is returned.

Uploaded by

Roni Stiawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

API BCA with C#

Check Balance

private
BalanceInformationRes
ponse
_CheckBalance(string
relativeUrlEncoded){
var token = _GetToken();
if(token == null) return null;

var timestamp = DateTime.Now.ToString("yyyy-MM-


ddTHH:mm:ss.fffzzz");

var client = new


RestClient($"{this._Host}{relativeUrlEncoded}");

var signature = _GenerateRequestSignature("GET",


relativeUrlEncoded, timestamp);

var request = _CreateRequestHeader(Method.GET,


timestamp, signature);

try {
IRestResponse response =
client.Execute(request);

var balanceInfo =
JsonConvert.DeserializeObject<BalanceInformationResponse>(respo
nse?.Content);

return balanceInfo;
}
catch(Exception e){
Console.WriteLine(e);
}

return null;
}

You might also like