SysAwardUserItemToUser
Client cloud code only Sys API to allow item(s) to be awarded to the applicable user without collecting the purchase amount. If includeDef is true, response includes associated itemDef with language fields limited to the current or default language.
| Service | Operation |
|---|---|
| userItems | SYS_AWARD_USER_ITEM_TO_USER |
Method Parameters
| Parameter | Description |
|---|---|
| profileId | The profile id of the user being awarded the user item. |
| defId | The unique id of the item definition to award. |
| quantity | The quantity of the item to award. |
| includeDef | If true, the associated item definition will be included in the response. |
| optionsJson | Optional support for specifying 'blockIfExceedItemMaxStackable' indicating how to process the award if the defId is for a stackable item with a max stackable quantity and the specified quantity to award is too high. If true and the quantity is too high, the call is blocked and an error is returned. If false (default) and quantity is too high, the quantity is adjusted to the allowed maximum and the quantity not awarded is reported in response key 'itemsNotAwarded' - unless the adjusted quantity would be 0, in which case the call is blocked and an error is returned. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
var profileId = "user-profile-id";
var defId = "sword001";
var quantity = 1;
var includeDef = True;
var optionsJson = {
"blockIfExceedItemMaxStackable": false
};
var userItemsProxy = bridge.getUseritemsServiceProxy();
var postResult = userItemsProxy.sysAwardUserItemToUser(profileId, defId, quantity, includeDef, optionsJson);
{
"service":"userItems",
"operation":"SYS_AWARD_USER_ITEM_TO_USER",
"data":{
"profileId":"user-profile-id",
"defId":"sword001",
"quantity":1,
"includeDef":true,
"optionsJson":{
"blockIfExceedItemMaxStackable":false
}
}
}
JSON Response
{
"data": {
"quantity": 1,
"items": {
"ad2a0f81-1efc-4c76-a8f4-608c6efb488d": {
"itemId": "ad2a0f81-1efc-4c76-a8f4-608c6efb488d",
"defId": "aa",
"type": "ITEM",
"quantity": 1,
"itemData": {},
"giftedTo": null,
"giftedFrom": null,
"createdAt": 1764002065367,
"updatedAt": 1764002065367,
"version": 1,
"usesLeft": null,
"coolDownStart": -1,
"recoveryStart": -1,
"maxUses": null,
"coolDownUntil": -1,
"recoveryUntil": -1,
"itemDef": {
"defId": "aa",
"name": "apple",
"desc": null,
"type": "ITEM",
"category": "fruit",
"tags": null,
"buyPriceDisabled": false,
"buyPrice": {},
"sellPrice": {},
"image": "https://api.braincloudservers.com/files/portal/g/23782/metadata/itemDefinitions/aa.png",
"resourceGroup": null,
"resourceTag": null,
"meta": {},
"pState": "PUBLISHED",
"publishedAt": 1603486352114,
"stackable": false,
"maxStackable": null,
"tradable": false,
"blockchain": false,
"consumable": false,
"uses": null,
"coolDownSecs": 0,
"recoverySecs": 0,
"activatable": false,
"statusName": null,
"activeSecs": null,
"maxActiveSecs": null,
"statusBehaviour": null
}
}
}
},
"status": 200
}