Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform v2.0.0 API Update #32

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="7.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 20 additions & 0 deletions src/Enjin.Platform.Sdk/Enjin.Platform.Sdk.Beam/Event/BeamEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ namespace Enjin.Platform.Sdk.Beam;
[PublicAPI]
public static class BeamEvents
{
/// <summary>
/// The name of the event for when a beam batch transaction is created.
/// </summary>
public const string BeamBatchTransactionCreated = "platform:beam-batch-transaction-created";

/// <summary>
/// The name of the event for when a claim for a beam is in progress.
/// </summary>
Expand Down Expand Up @@ -42,4 +47,19 @@ public static class BeamEvents
/// The name of the event for when a beam is updated.
/// </summary>
public const string BeamUpdated = "platform:beam-updated";

/// <summary>
/// The name of the event for when beam claims have finished being created.
/// </summary>
public const string CreateBeamClaimsCompleted = "platform:create-beam-claims-completed";

/// <summary>
/// The name of the event for when tokens are added to a beam.
/// </summary>
public const string TokensAdded = "platform:tokens-added";

/// <summary>
/// The name of the event for when tokens are removed from a beam.
/// </summary>
public const string TokensRemoved = "platform:tokens-removed";
}
21 changes: 21 additions & 0 deletions src/Enjin.Platform.Sdk/Enjin.Platform.Sdk.Beam/Model/Beam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,25 @@ public class Beam
[JsonInclude]
[JsonPropertyName("qr")]
public BeamQr? Qr { get; private set; }

/// <summary>
/// The claim probability for each token.
/// </summary>
[JsonInclude]
[JsonPropertyName("probabilities")]
public BeamQr? Probabilities { get; private set; }

/// <summary>
/// The beam claims.
/// </summary>
[JsonInclude]
[JsonPropertyName("claims")]
public BeamQr? Claims { get; private set; }

/// <summary>
/// The number of claims remaining in this beam.
/// </summary>
[JsonInclude]
[JsonPropertyName("claimsRemaining")]
public BeamQr? ClaimsRemaining { get; private set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ public class BeamClaim
[JsonInclude]
[JsonPropertyName("tokenId")]
public string? TokenId { get; private set; }

/// <summary>
/// The claimable tokens quantity.
/// </summary>
[JsonInclude]
[JsonPropertyName("quantity")]
public string? Quantity { get; private set; }

/// <summary>
/// The beam details.
Expand Down Expand Up @@ -73,11 +80,39 @@ public class BeamClaim
[JsonInclude]
[JsonPropertyName("code")]
public string? Code { get; private set; }


/// <summary>
/// The claim identifier code.
/// </summary>
[JsonInclude]
[JsonPropertyName("identifierCode")]
public string? IdentifierCode { get; private set; }

/// <summary>
/// The QR URL for the claimable code.
/// </summary>
[JsonInclude]
[JsonPropertyName("qr")]
public BeamQr? Qr { get; private set; }

/// <summary>
/// An initial attribute to set for the token when minting on demand.
/// </summary>
[JsonInclude]
[JsonPropertyName("attributes")]
public BeamQr? Attributes { get; private set; }

/// <summary>
/// An blockchain transaction.
/// </summary>
[JsonInclude]
[JsonPropertyName("transaction")]
public BeamQr? Transaction { get; private set; }

/// <summary>
/// The idempotency key set for this transaction.
/// </summary>
[JsonInclude]
[JsonPropertyName("idempotencyKey")]
public BeamQr? IdempotencyKey { get; private set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ClaimToken()
/// </summary>
/// <param name="tokenIds">The token chain IDs.</param>
/// <returns>This parameter for chaining.</returns>
public ClaimToken SetTokenIds(params IntegerRange[]? tokenIds)
public ClaimToken SetTokenIds(params IntegerRangeString[]? tokenIds)
{
return SetParameter("tokenIds", tokenIds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public BeamClaimFragment WithTokenId(bool isIncluded = true)
{
return WithField("tokenId", isIncluded);
}

/// <summary>
/// Sets whether the <see cref="BeamClaim"/> is to be returned with its <see cref="BeamClaim.Quantity"/> property.
/// </summary>
/// <param name="isIncluded">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamClaimFragment WithQuantity(bool isIncluded = true)
{
return WithField("quantity", isIncluded);
}

/// <summary>
/// Sets the <see cref="Beam"/> fragment to be used for getting the <see cref="BeamClaim.Beam"/> property of
Expand Down Expand Up @@ -88,6 +98,16 @@ public BeamClaimFragment WithClaimStatus(bool isIncluded = true)
{
return WithField("claimStatus", isIncluded);
}

/// <summary>
/// Sets whether the <see cref="BeamClaim"/> is to be returned with its <see cref="BeamClaim.Type"/> property.
/// </summary>
/// <param name="isIncluded">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamClaimFragment WithBeamType(bool isIncluded = true)
{
return WithField("beamType", isIncluded);
}

/// <summary>
/// Sets whether the <see cref="BeamClaim"/> is to be returned with its <see cref="BeamClaim.Code"/> property.
Expand All @@ -98,6 +118,16 @@ public BeamClaimFragment WithCode(bool isIncluded = true)
{
return WithField("code", isIncluded);
}

/// <summary>
/// Sets whether the <see cref="BeamClaim"/> is to be returned with its <see cref="BeamClaim.IdentifierCode"/> property.
/// </summary>
/// <param name="isIncluded">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamClaimFragment WithIdentifierCode(bool isIncluded = true)
{
return WithField("identifierCode", isIncluded);
}

/// <summary>
/// Sets whether the <see cref="BeamClaim"/> is to be returned with its <see cref="BeamClaim.Qr"/> property.
Expand All @@ -108,4 +138,34 @@ public BeamClaimFragment WithQr(BeamQrFragment? fragment)
{
return WithField("qr", fragment);
}

/// <summary>
/// Sets whether the <see cref="BeamClaim"/> is to be returned with its <see cref="BeamClaim.Attributes"/> property.
/// </summary>
/// <param name="fragment">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamClaimFragment WithAttributes(AttributeFragment? fragment)
{
return WithField("attributes", fragment);
}

/// <summary>
/// Sets whether the <see cref="BeamClaim"/> is to be returned with its <see cref="BeamClaim.Code"/> property.
/// </summary>
/// <param name="fragment">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamClaimFragment WithTransaction(TransactionFragment? fragment)
{
return WithField("transaction", fragment);
}

/// <summary>
/// Sets whether the <see cref="BeamClaim"/> is to be returned with its <see cref="BeamClaim.IdempotencyKey"/> property.
/// </summary>
/// <param name="isIncluded">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamClaimFragment WithIdempotencyKey(bool isIncluded = true)
{
return WithField("idempotencyKey", isIncluded);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ public BeamFragment WithMessage(BeamScanFragment? fragment)
{
return WithField("message", fragment);
}

/// <summary>
/// Sets whether the <see cref="Beam"/> is to be returned with its <see cref="Beam.IsClaimable"/> property.
/// </summary>
/// <param name="isIncluded">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamFragment WithIsClaimable(bool isIncluded = true)
{
return WithField("isClaimable", isIncluded);
}

/// <summary>
/// Sets whether the <see cref="Beam"/> is to be returned with its <see cref="Beam.Flags"/> property.
Expand All @@ -128,4 +138,35 @@ public BeamFragment WithQr(BeamQrFragment? fragment)
{
return WithField("qr", fragment);
}

/// <summary>
/// Sets whether the <see cref="Beam"/> is to be returned with its <see cref="Beam.Probabilities"/> property.
/// </summary>
/// <param name="isIncluded">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamFragment WithProbabilities(bool isIncluded = true)
{
return WithField("probabilities", isIncluded);
}

/// <summary>
/// Sets the <see cref="BeamScan"/> fragment to be used for getting the <see cref="Beam.Claims"/> property of the
/// <see cref="Beam"/>.
/// </summary>
/// <param name="fragment">The <see cref="BeamQr"/> fragment.</param>
/// <returns>This fragment for chaining.</returns>
public BeamFragment WithClaims(BeamClaimConnectionFragment? fragment)
{
return WithField("claims", fragment);
}

/// <summary>
/// Sets whether the <see cref="Beam"/> is to be returned with its <see cref="Beam.ClaimsRemaining"/> property.
/// </summary>
/// <param name="isIncluded">Whether the field is included.</param>
/// <returns>This fragment for chaining.</returns>
public BeamFragment WithClaimsRemaining(bool isIncluded = true)
{
return WithField("claimsRemaining", isIncluded);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using JetBrains.Annotations;

namespace Enjin.Platform.Sdk.Beam;

/// <summary>
/// A request to act as a mutation for adding tokens to a beam.
/// </summary>
[PublicAPI]
public class AddTokens : GraphQlRequest<AddTokens>
{
/// <summary>
/// Initializes a new instance of the <see cref="AddTokens"/> class.
/// </summary>
public AddTokens() : base("AddTokens", GraphQlRequestType.Mutation)
{
}

/// <summary>
/// Sets the code of the beam.
/// </summary>
/// <param name="code">The code.</param>
/// <returns>This request for chaining.</returns>
public AddTokens SetCode(string? code)
{
return SetVariable("code", CoreTypes.String, code);
}

/// <summary>
/// Sets the token IDs to add.
/// </summary>
/// <param name="tokenIds">The token claims to add.</param>
/// <returns>This request for chaining.</returns>
public AddTokens SetTokens(params ClaimToken[]? tokenIds)
{
return SetVariable("tokens", BeamTypes.ClaimTokenArray, tokenIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public RemoveTokens SetCode(string? code)
/// </summary>
/// <param name="tokenIds">The token IDs.</param>
/// <returns>This request for chaining.</returns>
public RemoveTokens SetTokenIds(params IntegerRange[]? tokenIds)
public RemoveTokens SetTokenIds(params IntegerRangeString[]? tokenIds)
{
return SetVariable("tokenIds", CoreTypes.IntegerRangeStringArray, tokenIds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ public UpdateBeam SetFlags(params BeamFlagInputType[]? flags)
{
return SetVariable("flags", BeamTypes.BeamFlagInputTypeArray, flags);
}

/// <summary>
/// Sets the token IDs to add.
/// </summary>
/// <param name="tokenIds">The token claims to add.</param>
/// <returns>This request for chaining.</returns>
public UpdateBeam SetTokens(params ClaimToken[]? tokenIds)
{
return SetVariable("tokens", BeamTypes.ClaimTokenArray, tokenIds);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using JetBrains.Annotations;

namespace Enjin.Platform.Sdk.Beam;

/// <summary>
/// A request for querying pending claims.
/// </summary>
[PublicAPI]
public class GetPendingClaims : GraphQlRequest<GetPendingClaims, BeamClaimConnectionFragment>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetPendingClaims"/> class.
/// </summary>
public GetPendingClaims() : base("GetPendingClaims", GraphQlRequestType.Query)
{
}

/// <summary>
/// Sets the beam code.
/// </summary>
/// <param name="code">The beam code.</param>
/// <returns>This request for chaining.</returns>
public GetPendingClaims SetCode(string? code)
{
return SetVariable("code", CoreTypes.String, code);
}

/// <summary>
/// Sets the beam code.
/// </summary>
/// <param name="account">The account to get claims for.</param>
/// <returns>This request for chaining.</returns>
public GetPendingClaims SetAccount(string? account)
{
return SetVariable("account", CoreTypes.String, account);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,4 @@ public static THolder SetEnd<THolder>(this THolder caller, DateTime? end)
{
return caller.SetParameter("end", end);
}

/// <summary>
/// Sets whether the beam can be used only once.
/// </summary>
/// <param name="caller">The caller to set the parameter on.</param>
/// <param name="singleUse">Whether the beam can be used only once.</param>
/// <typeparam name="THolder">The caller type.</typeparam>
/// <returns>The caller for chaining.</returns>
[Obsolete]
public static THolder SetSingleUse<THolder>(this THolder caller, bool? singleUse)
where THolder : IHasBeamCommonFields<THolder>
{
return caller.SetParameter("singleUse", singleUse);
}
}
Loading
Loading