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 NftApi : INftApi
{
///
/// Initializes a new instance of the class.
///
/// an instance of ApiClient (optional)
///
public NftApi(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 NftApi(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 GetNFTMetadata(NetworkTypes network, string address)
{
// Verify the required parameter 'pairAddress' is set
if (address == null) throw new ApiException(400, "Missing required parameter 'address' when calling GetNFTMetadata");
var headerParams = new Dictionary();
var path = "/nft/{network}/{address}/metadata";
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 GetNFTMetadata: " + response.Item3, response.Item3);
else if (((int)response.Item1) == 0)
throw new ApiException((int)response.Item1, "Error calling GetNFTMetadata: " + response.Item3, response.Item3);
return ((CloudFunctionResult)ApiClient.Deserialize(response.Item3, typeof(CloudFunctionResult), response.Item2)).Result;
}
}
}