InventoryGrantRequest inventory.grant-request@1
Generated at from
openvibe-contracts v0.127.0 and
openvibe-sdk v0.37.0.
- Version
- 1.0.0
- Owner
- inventory
- Visibility
- public
- Status
- active
- Compatibility
- backward
- Decision
- ADR-054
- Schema
https://openvibe.network/contracts/inventory/grant-request.v1.json
An issuer grants one instance of a definition it issued to a person (inventory.item.grant). Idempotent per idempotency_key: a repeat answers the instance already granted. A capped definition that is sold out answers 409 inventory.supply_exhausted.
Fields
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
definition_id | string | yes |
| |
subject | string | yes |
| |
idempotency_key | string | yes |
| |
origin | enum |
| ||
reason | string | Shown in the ledger: what the person did (a quest, an event, a milestone). |
| |
attributes | object |
Examples
From the contract's own test fixtures: valid ones validate, rejected ones must fail.
Valid: quest
{
"definition_id": "itd_01JZ00000000000000000001TD",
"subject": "usr_01JZ0000000000000000000AAA",
"idempotency_key": "quest-0000-0001",
"origin": "earned",
"reason": "Completed the first-stream quest"
}Rejected: bought-origin
{
"definition_id": "itd_01JZ00000000000000000001TD",
"subject": "usr_01JZ0000000000000000000AAA",
"idempotency_key": "k-12345678",
"origin": "bought"
}Rejected: short-key
{
"definition_id": "itd_01JZ00000000000000000001TD",
"subject": "usr_01JZ0000000000000000000AAA",
"idempotency_key": "k"
}Validate
const contracts = require('openvibe-contracts');
contracts.validate('inventory.grant-request@1', value); // { valid, errors: [{ path, message }] }