Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する

By calling through code


To use Point Up through configuration as mentioned above, the corresponding Blocklet must support the capability of Point Up. Implementing this capability is straightforward; it only requires specific API calls using the Blocklet SDK. If you are developing your own Blocklet and wish to integrate Point Up’s rewards functionality into your Blocklet's business logic, the following documentation will be of great help.

Next, we will list the APIs that can be called by other Blocklet combinations in Point Up.

1. Add points for the specified user DID based on the specified rules.#

Example code for request:

const component = require('@blocklet/sdk/lib/component');

// ...

const { data } = await component.call({
name: 'z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA',
path: '/api/add-point-cc',
data: { ruleId: 'Add Point Rule ID', userDID: 'User DID' },
});

Successful return example:

{
id: 'xxxx',
type: 0,
points: x,
userDID: 'User DID',
ruleId: 'Add Point Rule ID',
preRecordId: '',
isUndone: false
}

You can use your logic to properly store the id along with other valuable information for later use.

2 Revoke a Points Redemption Based on Points Earning Records#

Example code for the request:

const component = require('@blocklet/sdk/lib/component');

// ...

const { data } = await component.call({
name: 'z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA',
path: '/api/undo-add-point-cc',
data: { ruleId: 'Add Point Rule ID', userDID: 'User DID', addPointRecordId: 'Add Point Record ID' }, // This addPointRecordId is saved from add-point-cc call
});

Example of successful return:

{
id: 'xxxx',
type: 2,
points: -x,
userDID: 'User DID',
ruleId: 'Add Point Rule ID',
preRecordId: 'xxxx',
isUndone: false
}

You can combine your logic to store the ID and other useful information for future use.

3 Consume points for the designated user DID based on specified rules#

Example code for requests:

const component = require('@blocklet/sdk/lib/component');

// ...

const { data } = await component.call({
name: 'z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA',
path: '/api/consume-point-cc',
data: { ruleId: 'Consume Point Rule ID', userDID: 'User DID' },
});

Successful return example:

{
id: 'xxxx',
type: 1,
points: x,
userDID: 'User DID',
ruleId: 'Consume Point Rule ID',
preRecordId: '',
isUndone: false
}

You can organize the ID along with other useful information for future reference.

4 Inquire about the details of a new points rule#

Example code for request:

const component = require('@blocklet/sdk/lib/component');

// ...

const { data } = await component.call({
name: 'z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA',
path: `/api/get-add-point-rule-info-cc/${id}`,
method: 'GET',
data: { },
});

Successful return example:

{
id: 'xxxx',
points: x,
isLimited: x,
periodicType: x,
maxTimes: x,
desc: 'desc',
title: 'title',
isDisabled: x,
addedBy: 'Creator DID',
tTranslation: 'Title translation',
}

5 Query the details of a points-based rule#

Sample code for request:

const component = require('@blocklet/sdk/lib/component');

// ...

const { data } = await component.call({
name: 'z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA',
path: `/api/get-consume-point-rule-info-cc/${id}`,
method: 'GET',
data: { },
});

Successful return example:

{
id: 'xxxx',
points: x,
desc: 'desc',
title: 'title',
isDisabled: x,
addedBy: 'Creator DID',
tTranslation: 'Title translation',
}

6 Query a Batch of Users' Points Overview#

Example code for request:

const component = require('@blocklet/sdk/lib/component');

// ...

const { data } = await component.call({
name: 'z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA',
path: '/api/batch-get-user-points-info-cc',
params: { userDID: 'xxx,xxx,xxx' },
method: 'GET',
});

Successful return example:

[
{
did: 'xxxx',
maxPoints: x,
unUsedPoints: x,
},
{
did: 'xxxx',
maxPoints: x,
unUsedPoints: x,
},
//...
]

7 Query the points profile of a user#

Example code for request:

const component = require('@blocklet/sdk/lib/component');

// ...

const { data } = await component.call({
name: 'z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA',
path: `/api/get-user-points-info-cc/${userDID}`,
data: { },
method: 'GET',
});

Successful Return Example:

{
did: 'xxxx',
maxPoints: x,
unUsedPoints: x,
}

8 Claim badges for the specified user DID#

Example code for request:

const component = require('@blocklet/sdk/lib/component');

// ...

const { data } = await component.call({
name: 'z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA',
path: '/api/add-badge-cc',
data: { ruleId: 'Badge Rule ID', userDID: 'User DID'},
method: 'POST',
});

Successful return example:

{
id: 'xxxx',
userDID: 'User DID',
ruleId: 'Badge Rule ID',
}
你获得 0 积分