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:
Property | Type | Description |
---|---|---|
_id | string | Internal identifier |
name | string | Display name of the mission |
description | string | Description of the mission |
tags | SlimTagType[] | Array of tags associated with the mission |
objectives | ObjectiveMissionTypes[] | Array of mission objectives |
validityTime | ValidityTimeType | ValidityTimePeriodType | ValidityTimeSpecificDateType | Time validity constraints for the mission |
status | MissionStatusEnum | Current status of the mission |
rewardCategories | MissionRewardCategoryType[] | Array of reward categories for the mission |
rewardClaimStatus | MissionClaimStatusType | Status of reward claims |
missionBundleState | MissionProgressType | Progress state of the mission bundle |
bundleInternalDetails | InternalDetailType | Internal details of the bundle |
bundleExternalDetails | TranslationType[] | External details of the bundle |
enabled | boolean | Whether the mission is enabled |
version | number | Version of the mission |
state | MissionProgressType | Progress state of the mission |
missionBundleId | string | ID of the mission bundle |
bundleStateId | string | ID of the bundle state |
missionId | string | ID of the mission |
endDate | string | End date of the mission |
startDate | string | Start date of the mission |
missionBundleSettings | any | Settings for the mission bundle |
originalMissionBundleId | string | Original ID of the mission bundle |
playerId | string | ID of the player |
repetitionCount | number | Number of repetitions |
repetitionEnabled | boolean | Whether 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:
Property | Type | Description |
---|---|---|
daily | MissionHistoryBundleDetailsType[] | Array of daily mission bundles |
weekly | MissionHistoryBundleDetailsType[] | Array of weekly mission bundles |
montly | MissionHistoryBundleDetailsType[] | Array of monthly mission bundles |
lifetime | MissionHistoryBundleDetailsType[] | Array of lifetime mission bundles |
range | MissionHistoryBundleDetailsType[] | Array of range-based mission bundles |
Each MissionHistoryBundleDetailsType
object contains:
Property | Type | Description |
---|---|---|
playerId | string | ID of the player |
_id | string | Internal identifier (optional) |
originalId | string | Original identifier |
timeFrameState | object | Time frame state information |
eligibility | unknown | Eligibility information |
internalDetails | InternalDetailType | Internal details of the bundle |
externalDetails | TranslationType[] | External details of the bundle |
settings | BundleSettingsType | Settings for the bundle |
status | MissionStatusEnum | Status of the bundle |
state | MissionProgressType | Progress state of the bundle |
missionsInOrder | boolean | Whether missions must be completed in order |
missionIds | MissionType[] | Array of missions in the bundle |
createdAt | string | Creation date |
updatedAt | string | Last update date |
startDate | string | Start date |
endDate | string | End date |
smallImage | string | URL to small image |
largeImage | string | URL to large image |
easterEggs | EasterEggsType[] | Array of Easter eggs in the bundle |
endedOrCompletedDate | string | Date 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:
Property | Type | Description |
---|---|---|
_id | string | Internal identifier |
easterEggs | EasterEggsType[] | Array of Easter eggs |
eligibility | unknown | Eligibility information |
externalDetails | TranslationType[] | External details |
internalDetails | InternalDetailType | Internal details |
originalId | string | Original identifier |
playerId | string | ID of the player |
smallImage | string | URL to small image |
state | MissionProgressType | Progress state |
status | MissionStatusEnum | Status |
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:
Property | Type | Description |
---|---|---|
validityTimeState | ValidityTimeType | ValidityTimePeriodType | ValidityTimeSpecificDateType | Time 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:
Property | Type | Required | Description |
---|---|---|---|
easterEggId | string | Yes | ID of the Easter egg to claim |
bundleId | string | Yes | ID of the bundle containing the Easter egg |
Returns:
A Promise that resolves to a SimpleResponse<EasterEggClaimResponse>
object with the following structure:
Property | Type | Description |
---|---|---|
ok | boolean | Whether the operation was successful |
data | EasterEggClaimResponse | null | Response data if successful, null otherwise |
error | object | undefined | Error information if the operation failed |
The EasterEggClaimResponse
object contains:
Property | Type | Description |
---|---|---|
easterEgg | EasterEggsMissionBundle | null | Easter egg information if available, null if no rewards to claim |
message | string | Response message |
statusCode | number | HTTP 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);
}
Related Interfaces
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',
}