Tanvi
Member
- Joined
- Feb 24, 2022
- Messages
- 10
- Programming Experience
- 1-3
Hi Team,
I am new to C#, I got a C#.Net Library for an API, that needs to be compatible with VBA. The API source code has a base class with parameterized constructors and Methods. How do I wrap or access the objects from VBA? Below is the sample code. I need to create objects for smartapi and pass arguments from VBA. I came to know that we can achieve this using Factory class. Can you guide me on how we can do it with some basic example on below SMartAPi base class?
I am new to C#, I got a C#.Net Library for an API, that needs to be compatible with VBA. The API source code has a base class with parameterized constructors and Methods. How do I wrap or access the objects from VBA? Below is the sample code. I need to create objects for smartapi and pass arguments from VBA. I came to know that we can achieve this using Factory class. Can you guide me on how we can do it with some basic example on below SMartAPi base class?
C#:
public class SmartApi : ISmartApi
{
protected string USER = "USER", SourceID = "WEB", PrivateKey = "";
static string ClientPublicIP = "", ClientLocalIP = "", MACAddress = "";
//protected string APIURL = "https://openapisuat.angelbroking.com";
protected string APIURL = "https://apiconnect.angelbroking.com"; //prod endpoint
AngelToken Token { get; set; }
/*Constructors*/
public SmartApi(string _PrivateKey)
{
PrivateKey = _PrivateKey;
ClientPublicIP = Helpers.GetPublicIPAddress();
if (ClientPublicIP == "")
ClientPublicIP = Helpers.GetPublicIPAddress();
if (ClientPublicIP == "")
ClientPublicIP = "106.193.147.98";
ClientLocalIP = Helpers.GetLocalIPAddress();
if (ClientLocalIP == "")
ClientLocalIP = "127.0.0.1";
if (Helpers.GetMacAddress() != null)
MACAddress = Helpers.GetMacAddress().ToString();
else
MACAddress = "fe80::216e:6507:4b90:3719";
}
public SmartApi(string _PrivateKey, string _jwtToken = "", string _refreshToken = "")
{
PrivateKey = _PrivateKey;
this.Token = new AngelToken();
this.Token.jwtToken = _jwtToken;
this.Token.refreshToken = _refreshToken;
this.Token.feedToken = "";
ClientPublicIP = Helpers.GetPublicIPAddress();
if (ClientPublicIP == "")
ClientPublicIP = Helpers.GetPublicIPAddress();
if (ClientPublicIP == "")
ClientPublicIP = "106.193.147.98";
ClientLocalIP = Helpers.GetLocalIPAddress();
if (ClientLocalIP == "")
ClientLocalIP = "127.0.0.1";
if (Helpers.GetMacAddress() != null)
MACAddress = Helpers.GetMacAddress().ToString();
else
MACAddress = "fe80::216e:6507:4b90:3719";
}
//other methods below
}