Skip to main content

Missions Module

The Missions Module provides functionality to retrieve information about player missions, mission bundles, and Easter eggs. It also allows players to claim Easter egg rewards. This module is part of the Gamanza Engage Web Client SDK and is automatically instantiated when the SDK is initialized.

Accessing the Module

The MissionsModule is initialized internally by the SDK and should not be instantiated directly. It's accessible through the main SDK instance.

// Example of accessing the CrmModule through the SDK
const { Missions } = GamanzaEngageWebClientSDK.getInstance();

Public Methods

getPlayerMissionsInProgress

Retrieves the list of active missions in progress for the current authenticated player.

getPlayerMissionsInProgress(): Promise<MissionType[]>

Description:
This method fetches a list of all active missions that are currently in progress for the authenticated player. It uses a caching mechanism to optimize performance - first checking if data is available in the cache before making an API call. If the API call fails, it attempts to return stale data from the cache.

Parameters:
None

Returns:
A Promise that resolves to an array of MissionType objects with the following properties:

PropertyTypeDescription
_idstringInternal identifier
namestringDisplay name of the mission
descriptionstringDescription of the mission
tagsSlimTagType[]Array of tags associated with the mission
objectivesObjectiveMissionTypes[]Array of mission objectives
validityTimeValidityTimeType | ValidityTimePeriodType | ValidityTimeSpecificDateTypeTime validity constraints for the mission
statusMissionStatusEnumCurrent status of the mission
rewardCategoriesMissionRewardCategoryType[]Array of reward categories for the mission
rewardClaimStatusMissionClaimStatusTypeStatus of reward claims
missionBundleStateMissionProgressTypeProgress state of the mission bundle
bundleInternalDetailsInternalDetailTypeInternal details of the bundle
bundleExternalDetailsTranslationType[]External details of the bundle
enabledbooleanWhether the mission is enabled
versionnumberVersion of the mission
stateMissionProgressTypeProgress state of the mission
missionBundleIdstringID of the mission bundle
bundleStateIdstringID of the bundle state
missionIdstringID of the mission
endDatestringEnd date of the mission
startDatestringStart date of the mission
missionBundleSettingsanySettings for the mission bundle
originalMissionBundleIdstringOriginal ID of the mission bundle
playerIdstringID of the player
repetitionCountnumberNumber of repetitions
repetitionEnabledbooleanWhether repetition is enabled

Example:

// Get all active missions in progress
const missions = await sdk.Missions.getPlayerMissionsInProgress();
console.log(missions);
// [
// {
// _id: "123",
// name: "Daily Login",
// description: "Log in every day for a week",
// status: "active",
// // ... other properties
// },
// // ... more missions
// ]

getPlayerBundlesActive

Retrieves the list of active bundles for the current authenticated player.

getPlayerBundlesActive(): Promise<MissionBundleListByTimeFrameType | null>

Description:
This method fetches a list of all active mission bundles for the authenticated player, organized by time frame. It uses a caching mechanism to optimize performance - first checking if data is available in the cache before making an API call. If the API call fails, it attempts to return stale data from the cache.

Parameters:
None

Returns:
A Promise that resolves to a MissionBundleListByTimeFrameType object or null if no active bundles are found. The object has the following properties:

PropertyTypeDescription
dailyMissionHistoryBundleDetailsType[]Array of daily mission bundles
weeklyMissionHistoryBundleDetailsType[]Array of weekly mission bundles
montlyMissionHistoryBundleDetailsType[]Array of monthly mission bundles
lifetimeMissionHistoryBundleDetailsType[]Array of lifetime mission bundles
rangeMissionHistoryBundleDetailsType[]Array of range-based mission bundles

Each MissionHistoryBundleDetailsType object contains:

PropertyTypeDescription
playerIdstringID of the player
_idstringInternal identifier (optional)
originalIdstringOriginal identifier
timeFrameStateobjectTime frame state information
eligibilityunknownEligibility information
internalDetailsInternalDetailTypeInternal details of the bundle
externalDetailsTranslationType[]External details of the bundle
settingsBundleSettingsTypeSettings for the bundle
statusMissionStatusEnumStatus of the bundle
stateMissionProgressTypeProgress state of the bundle
missionsInOrderbooleanWhether missions must be completed in order
missionIdsMissionType[]Array of missions in the bundle
createdAtstringCreation date
updatedAtstringLast update date
startDatestringStart date
endDatestringEnd date
smallImagestringURL to small image
largeImagestringURL to large image
easterEggsEasterEggsType[]Array of Easter eggs in the bundle
endedOrCompletedDatestringDate when the bundle ended or was completed

Example:

// Get all active mission bundles
const bundles = await sdk.Missions.getPlayerBundlesActive();
console.log(bundles);
// {
// daily: [
// {
// _id: "123",
// originalId: "456",
// externalDetails: [{ language: "en", name: "Daily Missions", description: "Complete these missions every day" }],
// // ... other properties
// }
// ],
// weekly: [...],
// montly: [...],
// lifetime: [...],
// range: [...]
// }

getPlayerEasterEggsActive

Retrieves the list of active Easter Eggs for the authenticated player.

getPlayerEasterEggsActive(): Promise<MissionBundleEasterEggType[]>

Description:
This method fetches a list of all active Easter Eggs for the authenticated player. Easter Eggs are special rewards that can be claimed when certain conditions are met. It uses a caching mechanism to optimize performance - first checking if data is available in the cache before making an API call. If the API call fails, it attempts to return stale data from the cache.

Parameters:
None

Returns:
A Promise that resolves to an array of MissionBundleEasterEggType objects with the following properties:

PropertyTypeDescription
_idstringInternal identifier
easterEggsEasterEggsType[]Array of Easter eggs
eligibilityunknownEligibility information
externalDetailsTranslationType[]External details
internalDetailsInternalDetailTypeInternal details
originalIdstringOriginal identifier
playerIdstringID of the player
smallImagestringURL to small image
stateMissionProgressTypeProgress state
statusMissionStatusEnumStatus

Example:

// Get all active Easter Eggs
const easterEggs = await sdk.Missions.getPlayerEasterEggsActive();
console.log(easterEggs);
// [
// {
// _id: "123",
// originalId: "456",
// easterEggs: [
// {
// condition: {
// easterEggId: "egg1",
// onRepetition: 3,
// amountOfMissions: 5,
// secretAreaCode: "SECRET123",
// status: "claimable",
// animation: "confetti"
// },
// // ... other properties
// }
// ],
// // ... other properties
// },
// // ... more Easter Eggs
// ]

getPlayerBundlesExpired

Retrieves the list of expired bundles for the current authenticated player.

getPlayerBundlesExpired(): Promise<MissionBundleListByTimeFrameType | null>

Description:
This method fetches a list of all expired mission bundles for the authenticated player, organized by time frame. It uses a caching mechanism to optimize performance - first checking if data is available in the cache before making an API call. If the API call fails, it attempts to return stale data from the cache.

Parameters:
None

Returns:
A Promise that resolves to a MissionBundleListByTimeFrameType object or null if no expired bundles are found. The structure is the same as the return type for getPlayerBundlesActive().

Example:

// Get all expired mission bundles
const expiredBundles = await sdk.Missions.getPlayerBundlesExpired();
console.log(expiredBundles);
// {
// daily: [
// {
// _id: "123",
// originalId: "456",
// externalDetails: [{ language: "en", name: "Daily Missions", description: "Complete these missions every day" }],
// status: "ended",
// // ... other properties
// }
// ],
// weekly: [...],
// montly: [...],
// lifetime: [...],
// range: [...]
// }

getPlayerMissionsExpired

Retrieves the list of expired missions for the current authenticated player.

getPlayerMissionsExpired(): Promise<MissionExpired[]>

Description:
This method fetches a list of all expired missions for the authenticated player. It uses a caching mechanism to optimize performance - first checking if data is available in the cache before making an API call. If the API call fails, it attempts to return stale data from the cache.

Parameters:
None

Returns:
A Promise that resolves to an array of MissionExpired objects. This extends the MissionType with an additional property:

PropertyTypeDescription
validityTimeStateValidityTimeType | ValidityTimePeriodType | ValidityTimeSpecificDateTypeTime validity state information

All other properties are the same as in MissionType.

Example:

// Get all expired missions
const expiredMissions = await sdk.Missions.getPlayerMissionsExpired();
console.log(expiredMissions);
// [
// {
// _id: "123",
// name: "Daily Login",
// description: "Log in every day for a week",
// status: "ended",
// validityTimeState: {
// timeType: "period",
// periodType: "day",
// periodValue: 7
// },
// // ... other properties
// },
// // ... more missions
// ]

getPlayerMissionsActiveBoosters

Retrieves the list of active missions boosters available for the current authenticated player.

getPlayerMissionsActiveBoosters(): Promise<ActiveBoosterEventData[]>

Description:
This method fetches a list of all active mission boosters for the authenticated player. Boosters can enhance mission progress or rewards.

Parameters:
None

Returns:
A Promise that resolves to an array of ActiveBoosterEventData objects.

Example:

// Get all active mission boosters
const boosters = await sdk.Missions.getPlayerMissionsActiveBoosters();
console.log(boosters);
// [
// {
// // ActiveBoosterEventData properties
// },
// // ... more boosters
// ]

playerClaimMissionsEasterEggs

Requests the claim process for a mission Easter egg for the current authenticated player.

playerClaimMissionsEasterEggs(payload: MissionsClaimEasterEggsPayload): Promise<SimpleResponse<EasterEggClaimResponse>>

Description:
This method initiates the claim process for a mission Easter egg. Easter Eggs are special rewards that can be claimed when certain conditions are met.

Parameters:
payload - An object of type MissionsClaimEasterEggsPayload with the following properties:

PropertyTypeRequiredDescription
easterEggIdstringYesID of the Easter egg to claim
bundleIdstringYesID of the bundle containing the Easter egg

Returns:
A Promise that resolves to a SimpleResponse<EasterEggClaimResponse> object with the following structure:

PropertyTypeDescription
okbooleanWhether the operation was successful
dataEasterEggClaimResponse | nullResponse data if successful, null otherwise
errorobject | undefinedError information if the operation failed

The EasterEggClaimResponse object contains:

PropertyTypeDescription
easterEggEasterEggsMissionBundle | nullEaster egg information if available, null if no rewards to claim
messagestringResponse message
statusCodenumberHTTP status code

Example:

// Claim an Easter egg
const claimResponse = await sdk.Missions.playerClaimMissionsEasterEggs({
easterEggId: "egg123",
bundleId: "bundle456"
});

if (claimResponse.ok) {
console.log("Easter egg claimed successfully:", claimResponse.data);
} else {
console.error("Failed to claim Easter egg:", claimResponse.error);
}

MissionType

interface MissionType {
_id: string;
name: string;
description: string;
tags: SlimTagType[];
objectives: ObjectiveMissionTypes[];
validityTime: ValidityTimeType | ValidityTimePeriodType | ValidityTimeSpecificDateType;
status: MissionStatusEnum;
rewardCategories: MissionRewardCategoryType[];
rewardClaimStatus?: MissionClaimStatusType;
missionBundleState?: MissionProgressType;
bundleInternalDetails: InternalDetailType;
bundleExternalDetails: TranslationType[];
enabled: boolean;
version: number;
state?: MissionProgressType;
missionBundleId?: string;
bundleStateId?: string;
missionId?: string;
endDate?: string;
startDate?: string;
missionBundleSettings: any;
originalMissionBundleId: string;
playerId: string;
repetitionCount?: number;
repetitionEnabled: boolean;
}

MissionProgressType

type MissionProgressType = {
total: number;
completed: number;
progress: number;
};

MissionStatusEnum

enum MissionStatusEnum {
ACTIVE = 'active',
INACTIVE = 'inactive',
PENDING = 'pending',
PAUSED = 'paused',
COMPLETED = 'completed',
ENDED = 'ended',
}

MissionExpired

type MissionExpired = MissionType & {
validityTimeState: ValidityTimeType | ValidityTimePeriodType | ValidityTimeSpecificDateType;
};

MissionBundleListByTimeFrameType

type MissionBundleListByTimeFrameType = {
daily: MissionHistoryBundleDetailsType[];
montly: MissionHistoryBundleDetailsType[];
weekly: MissionHistoryBundleDetailsType[];
lifetime: MissionHistoryBundleDetailsType[];
range: MissionHistoryBundleDetailsType[];
};

MissionHistoryBundleDetailsType

type MissionHistoryBundleDetailsType = {
playerId: string;
_id?: string;
originalId: string;
timeFrameState?: {
timeFrameType: TimeFrameEnum;
};
eligibility: unknown;
internalDetails: InternalDetailType;
externalDetails: TranslationType[];
settings?: BundleSettingsType;
status?: MissionStatusEnum;
state?: MissionProgressType;
missionsInOrder?: boolean;
missionIds?: MissionType[];
createdAt?: string;
updatedAt?: string;
startDate?: string;
endDate?: string;
smallImage?: string;
largeImage?: string;
easterEggs?: EasterEggsType[];
endedOrCompletedDate?: string;
};

MissionBundleEasterEggType

type MissionBundleEasterEggType = Pick<
MissionHistoryBundleDetailsType,
| '_id'
| 'easterEggs'
| 'eligibility'
| 'externalDetails'
| 'internalDetails'
| 'originalId'
| 'playerId'
| 'smallImage'
| 'state'
| 'status'
>;

MissionsClaimEasterEggsPayload

type MissionsClaimEasterEggsPayload = {
easterEggId: string;
bundleId: string;
};

EasterEggClaimResponse

interface EasterEggClaimResponse {
/**
* Returns null if the Easter egg not has rewards to claim
*/
easterEgg: EasterEggsMissionBundle | null;
message: string;
statusCode: number;
}

EasterEggsMissionBundle

interface EasterEggsMissionBundle {
condition: EasterEggConditionMissionBundle;
categories: RewardCategoryEasterEggs[];
}

EasterEggConditionMissionBundle

interface EasterEggConditionMissionBundle {
easterEggId: string;
onRepetition: number;
amountOfMissions: number;
secretAreaCode: string;
status: EasterEggsStatus;
animation: string;
}

EasterEggsStatus

enum EasterEggsStatus {
Pending = 'pending',
Claimable = 'claimable',
Claim = 'claimed',
}

ObjectiveMissionTypes

type ObjectiveMissionTypes =
| BaseObjectiveMissionType
| ObjectiveMissionCompletedTransactionType
| ObjectiveMissionWagerAndWinType
| ObjectiveMissionReferAFriendType
| ObjectiveMissionOptInAndAccountVerificationType
| ObjectiveMissionLevelUpType;

MissionEventTypeEnum

enum MissionEventTypeEnum {
COMPLETED_DEPOSIT = 'completed_deposit',
COMPLETED_WITHDRAWAL = 'completed_withdrawal',
WAGER = 'wager',
WIN = 'win',
REFER_A_FRIEND = 'refer_a_friend',
LOGIN = 'login',
ACTIVATE_ACCOUNT = 'activate_account',
ACCOUNT_VERIFICATION = 'account_verification',
SELF_ASSESSMENT_TEST = 'self_assessment_test',
OPT_IN = 'opt_in',
LEVEL_UP = 'level_up',
SPORT_WIN = 'sport_win',
SPORT_WAGER = 'sport_wager',
}