Skip to content

Commit

Permalink
feat(indexer): add new IIndexerResponse<T> and `IPaginatedIndexerRe…
Browse files Browse the repository at this point in the history
…sponse<T>` interfaces
  • Loading branch information
jasonboukheir committed Mar 24, 2022
1 parent 958c176 commit 3b3abda
Show file tree
Hide file tree
Showing 420 changed files with 94 additions and 25 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct AccountResponse
: IEquatable<AccountResponse>
, IIndexerResponse
, IIndexerResponse<AccountInfo>
{
[AlgoApiField("account", null)]
public AccountInfo Account { get; set; }

[AlgoApiField("current-round", null)]
public ulong CurrentRound { get; set; }

AccountInfo IIndexerResponse<AccountInfo>.Result
{
get => Account;
set => Account = value;
}

public bool Equals(AccountResponse other)
{
return Account.Equals(other.Account)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct AccountsResponse
: IEquatable<AccountsResponse>
, IPaginatedResponse
, IPaginatedIndexerResponse<AccountInfo>
{
[AlgoApiField("accounts", null)]
public AccountInfo[] Accounts { get; set; }
Expand All @@ -17,6 +17,12 @@ public partial struct AccountsResponse
[AlgoApiField("next-token", null)]
public FixedString128Bytes NextToken { get; set; }

AccountInfo[] IPaginatedIndexerResponse<AccountInfo>.Results
{
get => Accounts;
set => Accounts = value;
}

public bool Equals(AccountsResponse other)
{
return ArrayComparer.Equals(Accounts, other.Accounts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct ApplicationResponse
: IEquatable<ApplicationResponse>
, IIndexerResponse
, IIndexerResponse<Application>
{
[AlgoApiField("application", null)]
public Application Application { get; set; }

[AlgoApiField("current-round", null)]
public ulong CurrentRound { get; set; }

Application IIndexerResponse<Application>.Result
{
get => Application;
set => Application = value;
}

public bool Equals(ApplicationResponse other)
{
return Application.Equals(other.Application)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct ApplicationsResponse
: IEquatable<ApplicationsResponse>
, IPaginatedResponse
, IPaginatedIndexerResponse<Application>
{
[AlgoApiField("applications", null)]
public Application[] Applications { get; set; }
Expand All @@ -17,6 +17,12 @@ public partial struct ApplicationsResponse
[AlgoApiField("next-token", null)]
public FixedString128Bytes NextToken { get; set; }

Application[] IPaginatedIndexerResponse<Application>.Results
{
get => Applications;
set => Applications = value;
}

public bool Equals(ApplicationsResponse other)
{
return ArrayComparer.Equals(Applications, other.Applications)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct AssetResponse
: IEquatable<AssetResponse>
, IIndexerResponse
, IIndexerResponse<Asset>
{
[AlgoApiField("asset", null)]
public Asset Asset { get; set; }

[AlgoApiField("current-round", null)]
public ulong CurrentRound { get; set; }

Asset IIndexerResponse<Asset>.Result
{
get => Asset;
set => Asset = value;
}

public bool Equals(AssetResponse other)
{
return Asset.Equals(other.Asset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct AssetsResponse
: IEquatable<AssetsResponse>
, IPaginatedResponse
, IPaginatedIndexerResponse<Asset>
{
[AlgoApiField("assets", null)]
public Asset[] Assets { get; set; }
Expand All @@ -17,6 +17,12 @@ public partial struct AssetsResponse
[AlgoApiField("next-token", null)]
public FixedString128Bytes NextToken { get; set; }

Asset[] IPaginatedIndexerResponse<Asset>.Results
{
get => Assets;
set => Assets = value;
}

public bool Equals(AssetsResponse other)
{
return ArrayComparer.Equals(Assets, other.Assets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct BalancesResponse
: IEquatable<BalancesResponse>
, IPaginatedResponse
, IPaginatedIndexerResponse<MiniAssetHolding>
{
[AlgoApiField("balances", null)]
public MiniAssetHolding[] Balances { get; set; }
Expand All @@ -17,6 +17,12 @@ public partial struct BalancesResponse
[AlgoApiField("next-token", null)]
public FixedString128Bytes NextToken { get; set; }

MiniAssetHolding[] IPaginatedIndexerResponse<MiniAssetHolding>.Results
{
get => Balances;
set => Balances = value;
}

public bool Equals(BalancesResponse other)
{
return ArrayComparer.Equals(Balances, other.Balances)
Expand Down
21 changes: 21 additions & 0 deletions Runtime/CareBoo.AlgoSdk/Api/Indexer/Models/IIndexerResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;

namespace AlgoSdk
{
public interface IIndexerResponse
{
/// <summary>
/// Round at which the results were computed.
/// </summary>
ulong CurrentRound { get; set; }
}

public interface IIndexerResponse<T> : IIndexerResponse
where T : IEquatable<T>
{
/// <summary>
/// The resulting data.
/// </summary>
T Result { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using System;
using Unity.Collections;

namespace AlgoSdk
{
public interface IIndexerResponse
public interface IPaginatedResponse : IIndexerResponse
{
/// <summary>
/// Round at which the results were computed.
/// Used for pagination, when making another request provide this token with the
/// next parameter.
/// </summary>
ulong CurrentRound { get; }
FixedString128Bytes NextToken { get; set; }
}

public interface IPaginatedResponse : IIndexerResponse
public interface IPaginatedIndexerResponse<T> : IPaginatedResponse
where T : IEquatable<T>
{

/// <summary>
/// Used for pagination, when making another request provide this token with the
/// next parameter.
/// The resulting data.
/// </summary>
FixedString128Bytes NextToken { get; }
T[] Results { get; set; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct TransactionResponse
: IEquatable<TransactionResponse>
, IIndexerResponse
, IIndexerResponse<Transaction>
{
[AlgoApiField("transaction", null)]
public Transaction Transaction { get; set; }

[AlgoApiField("current-round", null)]
public ulong CurrentRound { get; set; }

Transaction IIndexerResponse<Transaction>.Result
{
get => Transaction;
set => Transaction = value;
}

public bool Equals(TransactionResponse other)
{
return Transaction.Equals(other.Transaction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AlgoSdk
[AlgoApiObject]
public partial struct TransactionsResponse
: IEquatable<TransactionsResponse>
, IPaginatedResponse
, IPaginatedIndexerResponse<Transaction>
{
[AlgoApiField("current-round", null)]
public ulong CurrentRound { get; set; }
Expand All @@ -17,6 +17,12 @@ public partial struct TransactionsResponse
[AlgoApiField("transactions", null)]
public Transaction[] Transactions { get; set; }

Transaction[] IPaginatedIndexerResponse<Transaction>.Results
{
get => Transactions;
set => Transactions = value;
}

public bool Equals(TransactionsResponse other)
{
return CurrentRound.Equals(other.CurrentRound)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3b3abda

Please sign in to comment.