Skip to content

Commit

Permalink
Added filter data
Browse files Browse the repository at this point in the history
  • Loading branch information
mranoncoder committed Dec 8, 2022
1 parent dc0b1c8 commit 8a83084
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 51 deletions.
55 changes: 34 additions & 21 deletions Runtime/GetCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public class GetCollections : MonoBehaviour
private string _sortBy = "Input Sort By = name";
[SerializeField]
private string _sortDir = "Input Asc or Desc";
[SerializeField]
private string jsonString = "Filters";

[Header("Optional: Filter and fetch items with specified property")]
[Header("Optional: Filter and fetch items with specified property")]

[SerializeField]
[Tooltip("Filter from a documents by any properties")]
Expand Down Expand Up @@ -99,29 +101,40 @@ public static GetCollections Initialize(bool destroyAtEnd = true)
/// <param name="sortDir"> sort direction</param>
public GetCollections SetParameters(string perPage = "20", string page = "1", string sortBy = "name", string sortDir = "asc")
{

if(perPage!=null)
if (perPage!=null)
this.jsonString = "?perPage=" + perPage;
this._perPage = perPage;
if(page!=null)
this._page = page;
if(sortBy!=null)
this._sortBy = sortBy;
if(sortDir!=null)
this._sortDir = sortDir;


return this;
this.jsonString = "&page=" + page;
this._page = page;
if (sortBy!=null)
this.jsonString = "&sortBy=" + sortBy;
this._sortBy = sortBy;
if (sortDir != null)
this.jsonString = "&sortDir=" + sortDir;
this._sortDir = sortDir;

return this;
}

/// <summary>
/// Set Filter by to return NFTs only from the given contract address/collection.
/// Set Filter.
/// </summary>
///<param name="name"> as string.</param>
public GetCollections AlturaOptions(string isVerified)
public GetCollections filter(string isVerified = null, string holders= null, string chainId = null, string name = null, string address = null, string website = null)
{
this._isVerified = isVerified;
return this;
}
if (isVerified != null)
this.jsonString = "&isVerified=" + isVerified;
if (holders != null)
this.jsonString = "&holders=" + holders;
if (chainId != null)
this.jsonString = "&chainId=" + chainId;
if (name != null)
this.jsonString = "&name=" + name;
if (address != null)
this.jsonString = "&address=" + address;
if (website != null)
this.jsonString = "&website=" + website;
return this;
}


public GetCollections OnComplete(UnityAction<Collection_model> action)
Expand Down Expand Up @@ -158,8 +171,8 @@ public Collection_model Run()

string BuildUrl()
{

WEB_URL = RequestUriInit + "?perPage=" + _perPage + "&page=" + _page + "&sortBy=" + _sortBy + "&sortDir=" + _sortDir + "&isVerified=" + _isVerified;
WEB_URL = RequestUriInit + "?" + jsonString;
if(debugErrorLog)
Debug.Log("Querying Details of User: " );

Expand All @@ -170,7 +183,7 @@ IEnumerator CallAPIProcess()
{
//Make request
UnityWebRequest request = UnityWebRequest.Get(WEB_URL);
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("source", AlturaUser.GetSource());
string url = "https://api.alturanft.com/api/sdk/unity/";
WWWForm form = new WWWForm();
Expand Down
62 changes: 45 additions & 17 deletions Runtime/GetItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public enum Chains
[DrawIf("chain", Chains.binance , DrawIfAttribute.DisablingType.DontDrawInverse)]
private string _sortDir = "Input Asc or Desc";
[SerializeField]
private string jsonString = "Filters";
[SerializeField]
[DrawIf("chain", Chains.binance , DrawIfAttribute.DisablingType.DontDrawInverse)]
private string _slim = "false";

Expand Down Expand Up @@ -107,16 +109,6 @@ public static GetItems Initialize(bool destroyAtEnd = true)
return _this;
}

/// <summary>
/// Set Filter by to return NFTs only from the given contract address/collection.
/// </summary>
///<param name="collection_address"> as string.</param>
public GetItems AlturaOptions(string collection_address)
{
this.collection_address = collection_address;
return this;
}

/// <summary>
/// Set Parameters to retrieve User From.
/// </summary>
Expand All @@ -127,20 +119,56 @@ public GetItems AlturaOptions(string collection_address)
/// <param name="slim"> bool</param>
public GetItems SetParameters(string perPage = "20", string page = "1", string sortBy = "name", string sortDir = "asc", string slim = "true")
{
if(perPage!=null)
if (perPage!=null)
this.jsonString = "&perPage=" + perPage;
this._perPage = perPage;
if(page!=null)
this._page = page;
if(sortBy!=null)
this._sortBy = sortBy;
if(sortDir!=null)
this._sortDir = sortDir;
this.jsonString = "&page=" + page;
this._page = page;
if (sortBy!=null)
this.jsonString = "&sortBy=" + sortBy;
this._sortBy = sortBy;
if (sortDir != null)
this.jsonString = "&sortDir=" + sortDir;
this._sortDir = sortDir;
if(slim!=null)
this.jsonString = "&slim=" + slim;
this._slim = slim;


return this;
}
/// <summary>
/// Set Filter.
/// </summary>
/// <param name="name"> name of collection</param>
/// <param name="collectionAddress"> collection Address</param>
/// <param name="chainId"> chainId</param>
/// <param name="creatorAddress"> creator Address</param>
/// <param name="holders"> amount of holders</param>
/// <param name="isVerified"> is Verified</param>
/// <param name="supply"> supply</param>
public GetItems filter(string name = null,string collection_address = null, string chainId= null, string creatorAddress = null,
string holders = null, string isVerified= null, string supply = null)
{
if (name != null)
this.jsonString = "&name=" + name;
if (collection_address != null)
this.jsonString = "&collection_address=" + collection_address;
if (chainId != null)
this.jsonString = "&chainId=" + chainId;
if (creatorAddress != null)
this.jsonString = "&creatorAddress=" + creatorAddress;

if (holders != null)
this.jsonString = "&holders=" + holders;
if (isVerified != null)
this.jsonString = "&isVerified=" + isVerified;
if (supply != null)
this.jsonString = "&supply=" + supply;

return this;
}

public GetItems OnComplete(UnityAction<Items_model> action)
{
Expand Down Expand Up @@ -176,7 +204,7 @@ public Items_model Run()
string BuildUrl()
{

WEB_URL = "https://api.alturanft.com/api/v2/item" + "?perPage=" + _perPage + "&page=" + _page + "&sortBy=" + _sortBy + "&sortDir=" + _sortDir + "&slim=" + _slim + "&collectionAddress=" + collection_address;
WEB_URL = "https://api.alturanft.com/api/v2/item?" + jsonString;


if(debugErrorLog)
Expand Down
39 changes: 29 additions & 10 deletions Runtime/GetUsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class GetUsers : MonoBehaviour
private string _sortBy = "Input Sort By = name";
[SerializeField]
private string _sortDir = "Input Asc or Desc";

[SerializeField]
private string jsonString = "Filters";
private string RequestUriInit = "https://api.alturanft.com/api/v2/user";
private string WEB_URL;
private string _apiKey;
Expand Down Expand Up @@ -93,18 +94,36 @@ public static GetUsers Initialize(bool destroyAtEnd = true)
/// <param name="sortDir"> sort direction</param>
public GetUsers SetParameters(string perPage = "20", string page = "1", string sortBy = "name", string sortDir = "asc")
{

if(perPage!=null)
if (perPage!=null)
this.jsonString = "&perPage=" + perPage;
this._perPage = perPage;
if(page!=null)
this._page = page;
if(sortBy!=null)
this._sortBy = sortBy;
if(sortDir!=null)
this._sortDir = sortDir;
this.jsonString = "&page=" + page;
this._page = page;
if (sortBy!=null)
this.jsonString = "&sortBy=" + sortBy;
this._sortBy = sortBy;
if (sortDir != null)
this.jsonString = "&sortDir=" + sortDir;
this._sortDir = sortDir;
return this;
}

/// <summary>
/// Set Filter.
/// </summary>
/// <param name="address"> address of the user</param>
/// <param name="name"> user name</param>
/// <param name="bio"> user bio</param>
public GetUsers filter(string address = null, string name= null, string bio = null)
{
if (address != null)
this.jsonString = "&address=" + address;
if (name != null)
this.jsonString = "&name=" + name;
if (bio != null)
this.jsonString = "&bio=" + bio;
return this;
}
public GetUsers OnComplete(UnityAction<User_model> action)
{
this.OnCompleteAction = action;
Expand Down Expand Up @@ -138,7 +157,7 @@ public User_model Run()

string BuildUrl()
{
WEB_URL = RequestUriInit + "?perPage=" + _perPage + "&page=" + _page + "&sortBy=" + _sortBy + "&sortDir=" + _sortDir;
WEB_URL = RequestUriInit + "?" +jsonString;
if(debugErrorLog)
Debug.Log("Querying Details of User: " );

Expand Down
31 changes: 28 additions & 3 deletions Runtime/GetUsersItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class GetUsersItems : MonoBehaviour

[SerializeField]
private string address = "Input Account Address To Fetch NFT's from";

[SerializeField]
private string jsonString = "Filters";
private string WEB_URL;
private string _apiKey;
private bool destroyAtEnd = false;
Expand Down Expand Up @@ -88,7 +89,31 @@ public GetUsersItems SetAddress(string account_address)
this.address = account_address;
return this;
}

/// <summary>
/// Set Filter.
/// </summary>
/// <param name="name"> name of collection</param>
/// <param name="collectionAddress"> collection Address</param>
/// <param name="chainId"> chainId</param>
/// <param name="creatorAddress"> creator Address</param>
/// <param name="fileType"> file Type</param>
/// <param name="isVerified"> is Verified</param>
public GetUsersItems filter(string name = null,string collectionAddress = null, string chainId= null, string creatorAddress = null,string fileType= null,string isVerified = null)
{
if (name != null)
this.jsonString = "&name=" + name;
if (collectionAddress != null)
this.jsonString = "&collectionAddress=" + collectionAddress;
if (chainId != null)
this.jsonString = "&chainId=" + chainId;
if (creatorAddress != null)
this.jsonString = "&creatorAddress=" + creatorAddress;
if (fileType != null)
this.jsonString = "&fileType=" + fileType;
if (isVerified != null)
this.jsonString = "&isVerified=" + isVerified;
return this;
}


public GetUsersItems OnComplete(UnityAction<Items_model> action)
Expand Down Expand Up @@ -126,7 +151,7 @@ public Items_model Run()
string BuildUrl()
{

WEB_URL = "https://api.alturanft.com/api/v2/user/items/" + address;
WEB_URL = "https://api.alturanft.com/api/v2/user/items/" + address +"?" +jsonString;


if (debugErrorLog)
Expand Down

0 comments on commit 8a83084

Please sign in to comment.