using System;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using System.Net;
using MoralisUnity.SolanaApi.Client;
using MoralisUnity.SolanaApi.Interfaces;
using MoralisUnity.SolanaApi.Models;
namespace MoralisUnity.SolanaApi.Api
{
public class AccountApi : IAccountApi
{
///
/// Initializes a new instance of the class.
///
/// an instance of ApiClient (optional)
///
public AccountApi(ApiClient apiClient = null)
{
if (apiClient == null) // use the default one in Configuration
this.ApiClient = Configuration.DefaultApiClient;
else
this.ApiClient = apiClient;
}
///
/// Initializes a new instance of the class.
///
///
public AccountApi(String basePath)
{
this.ApiClient = new ApiClient(basePath);
}
///
/// Sets the base path of the API client.
///
/// The base path
/// The base path
public void SetBasePath(String basePath)
{
this.ApiClient.BasePath = basePath;
}
///
/// Gets the base path of the API client.
///
/// The base path
/// The base path
public String GetBasePath(String basePath)
{
return this.ApiClient.BasePath;
}
///
/// Gets or sets the API client.
///
/// An instance of the ApiClient
public ApiClient ApiClient { get; set; }
public async UniTask Balance(NetworkTypes network, string address)
{
// Verify the required parameter 'pairAddress' is set
if (address == null) throw new ApiException(400, "Missing required parameter 'address' when calling Balance");
var headerParams = new Dictionary();
var path = "/account/{network}/{address}/balance";
path = path.Replace("{" + "network" + "}", ApiClient.ParameterToString(network.ToString()));
path = path.Replace("{" + "address" + "}", ApiClient.ParameterToString(address));
// Authentication setting, if any
String[] authSettings = new String[] { "ApiKeyAuth" };
Tuple, string> response = await ApiClient.CallApi(path, Method.GET, null, null, headerParams, null, null, authSettings);
if (((int)response.Item1) >= 400)
throw new ApiException((int)response.Item1, "Error calling Balance: " + response.Item3, response.Item3);
else if (((int)response.Item1) == 0)
throw new ApiException((int)response.Item1, "Error calling Balance: " + response.Item3, response.Item3);
return ((CloudFunctionResult)ApiClient.Deserialize(response.Item3, typeof(CloudFunctionResult), response.Item2)).Result;
}
public async UniTask> GetSplTokens(NetworkTypes network, string address)
{
// Verify the required parameter 'pairAddress' is set
if (address == null) throw new ApiException(400, "Missing required parameter 'address' when calling GetSplTokens");
var headerParams = new Dictionary();
var path = "/account/{network}/{address}/tokens";
path = path.Replace("{" + "network" + "}", ApiClient.ParameterToString(network.ToString()));
path = path.Replace("{" + "address" + "}", ApiClient.ParameterToString(address));
// Authentication setting, if any
String[] authSettings = new String[] { "ApiKeyAuth" };
Tuple, string> response = await ApiClient.CallApi(path, Method.GET, null, null, headerParams, null, null, authSettings);
if (((int)response.Item1) >= 400)
throw new ApiException((int)response.Item1, "Error calling GetSplTokens: " + response.Item3, response.Item3);
else if (((int)response.Item1) == 0)
throw new ApiException((int)response.Item1, "Error calling GetSplTokens: " + response.Item3, response.Item3);
return ((CloudFunctionResult>)ApiClient.Deserialize(response.Item3, typeof(CloudFunctionResult>), response.Item2)).Result;
}
public async UniTask> GetNFTs(NetworkTypes network, string address)
{
// Verify the required parameter 'pairAddress' is set
if (address == null) throw new ApiException(400, "Missing required parameter 'address' when calling GetNFTs");
var headerParams = new Dictionary();
var path = "/account/{network}/{address}/nft";
path = path.Replace("{" + "network" + "}", ApiClient.ParameterToString(network.ToString()));
path = path.Replace("{" + "address" + "}", ApiClient.ParameterToString(address));
// Authentication setting, if any
String[] authSettings = new String[] { "ApiKeyAuth" };
Tuple, string> response = await ApiClient.CallApi(path, Method.GET, null, null, headerParams, null, null, authSettings);
if (((int)response.Item1) >= 400)
throw new ApiException((int)response.Item1, "Error calling GetNFTs: " + response.Item3, response.Item3);
else if (((int)response.Item1) == 0)
throw new ApiException((int)response.Item1, "Error calling GetNFTs: " + response.Item3, response.Item3);
return ((CloudFunctionResult>)ApiClient.Deserialize(response.Item3, typeof(CloudFunctionResult>), response.Item2)).Result;
}
public async UniTask GetPortfolio(NetworkTypes network, string address)
{
// Verify the required parameter 'pairAddress' is set
if (address == null) throw new ApiException(400, "Missing required parameter 'address' when calling GetPortfolio");
var headerParams = new Dictionary();
var path = "/account/{network}/{address}/portfolio";
path = path.Replace("{" + "network" + "}", ApiClient.ParameterToString(network.ToString()));
path = path.Replace("{" + "address" + "}", ApiClient.ParameterToString(address));
// Authentication setting, if any
String[] authSettings = new String[] { "ApiKeyAuth" };
Tuple, string> response = await ApiClient.CallApi(path, Method.GET, null, null, headerParams, null, null, authSettings);
if (((int)response.Item1) >= 400)
throw new ApiException((int)response.Item1, "Error calling GetPortfolio: " + response.Item3, response.Item3);
else if (((int)response.Item1) == 0)
throw new ApiException((int)response.Item1, "Error calling GetPortfolio: " + response.Item3, response.Item3);
return ((CloudFunctionResult)ApiClient.Deserialize(response.Item3, typeof(CloudFunctionResult), response.Item2)).Result;
}
}
}