This class allows you to get the unopened lootboxes of users and to open lootboxes and claim prizes.

To get the obtained prizes of a user, you can use the getObtainedProducts method in the marketplace module.

Methods

  • Claims the prizes of an already opened lootbox.

    This method can only be called after the lootbox has been opened using the openLootbox method.

    Parameters

    • userId: string

      The user ID of the user to claim the prizes for.

    • transactionGroupId: string

      The transaction group ID of the reserved prizes (returned by the openLootbox method).

    Returns Promise<undefined>

    RequestError if the user does not exist (unknownUserError), if the lootbox does not exist (unknownLootboxError), or if the lootbox is not open yet (unknownLootboxError).

  • Returns a list of unopened lootboxes for a user.

    Use the openLootbox method to open a lootbox and see the prizes. In order to actually claim the prizes, use the claimPrizes method.

    Parameters

    • userId: string

      The user ID of the user to get the lootboxes for.

    Returns Promise<{
        lootbox: {
            opened: boolean;
            rewardId: string;
            rewardType: "Lootbox";
        };
        transactionGroupId: string;
        transactionNr: number;
    }[]>

    RequestError if the user does not exist (unknownUserError).

  • Opens a lootbox for a user to see the prizes.

    Once opened, the prizes are reserved for the user. However, they are only available to the user after the prizes have been claimed. This allows a more fine-grained control of when the prizes are distributed.

    Parameters

    • userId: string

      The user ID of the user to open the lootbox for.

    • transactionGroupId: string

      The transaction group ID of the lootbox to open (returned by the getLootboxes method).

    • transactionNr: number

      The transaction number of the lootbox to open (returned by the getLootboxes method).

    Returns Promise<{
        prize: {
            amount: number;
            rewardId: string;
            rewardType: "FanPointsReward";
        } | {
            description: string;
            imageUrls: string[];
            partner: {
                branding: {
                    logoColorUrl: undefined | string;
                };
                name: string;
                partnerId: string;
            };
            productCategory: ProductCategory;
            rewardId: string;
            rewardType: "Product";
            title: string;
        };
        transactionGroupId: string;
        transactionNr: number;
    }[]>

    RequestError if the user does not exist (unknownUserError), if the lootbox does not exist (unknownLootboxError), or if the lootbox is already open (alreadyOpenedLootboxError).