👾Code

Core

The main usable public Interface is located in the class CryptoAvatars.cs

Constructor:

You will need an apiKey from Cryptoavatars.io to perform the Http Requests

public CryptoAvatars(string apiKey){
            const string urlServer = "https://api.cryptoavatars.io/v1/";
            this.httpService = new HttpService(apiKey, urlServer);
}

Methods

// Basic User Login for Cryptoavatars.io

public IEnumerator UserLogin(string email, string password, Action<Structs.LoginResponseDto> onLoginResult);

// Gets all avatars filtered by Avatar name - Mainly used for searchbars

public IEnumerator GetAvatarsByName(string collectionNameSelected, string licenseType, string pageUrl, string name, Action<Structs.NftsArray> onAvatarsResult);

// Gets all avatars filtering by CollectionName

public IEnumerator GetAvatarsByCollectionName(string collectionName, string licenseType, string pageUrl, Action<Structs.NftsArray> onAvatarsResult);

// Gets avatars using the credentials of an already logged user filtering by CollectionName

public IEnumerator GetUserAvatarsByCollectionName(string collectionName, string owner, string pageUrl, Action<Structs.NftsArray> onAvatarsResult);

// Gets the Avatar preview as a Texture2D

public IEnumerator GetAvatarPreviewImage(string inageUrl, Action<Texture2D> onImage);

// Gets the Avatar as a GameObject

public IEnumerator GetAvatarVRMModel(string urlVrm, Action<GameObject> onModelResult);

// Retrieves all the collections

public IEnumerator GetNFTsCollections(Action<Structs.NftsCollectionsArray> onCollectionsResult, string pageUrl);

The API calls are made using a wrapper class HttpService.cs as an abstraction for UnityWebRequest class and adding new utilities

Constructor

public HttpService(string apiKey, string baseUri)
{
        this.apiKey = apiKey;
        this.baseUri = baseUri;
}

Methods

public IEnumerator Post<T>(string resource, T body, System.Action callbackResult);

public IEnumerator Get(string resource, System.Action callbackResult);

// Retrieves a Texture2D from an URL

public IEnumerator DownloadImage(string url, System.Action<Texture2D> callbackResult);

// Retrieves the VRM and creates all the folder structure required

public IEnumerator Download3DModel(string url, System.Action<string> callbackResult);

public IEnumerator HttpMethod(UnityWebRequest request, System.Action<string> callbackResult);

Last updated