# Inventory

## Get inventory item

<mark style="color:green;">`GET`</mark> `/v3/inventory`

**Headers**

| Name                                            | Value            |
| ----------------------------------------------- | ---------------- |
| X-Api-Key<mark style="color:red;">\*</mark>     | `API Key`        |
| Authorization<mark style="color:red;">\*</mark> | `Bearer <token>` |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Inventory retrieved from database",
    "data": [
        {
            "inventory_id": "01HJ02C1TWCPEMHEWGQNZQ5TKK",
            "game_internal_id": "ship_y471_maikaze",
            "komo_item_name": "Y471 HSF Maikaze",
            "is_transferable": 0
        },
        {
            "inventory_id": "01HJ02PS54E5K1MHKK5DSAWWKF",
            "game_internal_id": "ship_y471_maikaze",
            "komo_item_name": "Y471 HSF Maikaze",
            "is_transferable": 0
        },
        {
            "inventory_id": "01HH4AAHAK8X7861JFJA5R67C9",
            "game_internal_id": "ship_y083_sarushima",
            "komo_item_name": "Y083 LCS Sarushima",
            "is_transferable": 0
        },
        {
            "inventory_id": "01J7ZMW9Q8Y20ZNN7HYQJF0VWP",
            "game_internal_id": "ship_kri_antasena",
            "komo_item_name": "KRI Antasena",
            "is_transferable": 0
        },
        {
            "inventory_id": "01HHKXM99KSD9H0B7JBH57S70Z",
            "game_internal_id": "ship_y467_harekaze",
            "komo_item_name": "Y467 HSF Harekaze",
            "is_transferable": 0
        },
        {
            "inventory_id": "01J8F2RJYZ238YF7CR5KTB5J49",
            "game_internal_id": "battle_pass_12.5",
            "komo_item_name": "Battle Pass Season 12.5",
            "is_transferable": 1
        },
        {
            "inventory_id": "01J8F2RJYZ238YF7CR5KTB5J4A",
            "game_internal_id": "battle_pass_12.5",
            "komo_item_name": "Battle Pass Season 12.5",
            "is_transferable": 0
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Disable Inventory Transfer

<mark style="color:green;">`POST`</mark> `/v3/inventory/disable-transfer`

**Headers**

| Name          | Value            |
| ------------- | ---------------- |
| X-API-Key     | `API Key`        |
| Authorization | `Bearer <token>` |

**Body**

| Name           | Type   | Description  |
| -------------- | ------ | ------------ |
| `inventory_id` | string | Inventory ID |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Inventory updated"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": "error",
    "messages": {
        "updateFailed": "Failed to update inventory"
    }
}
```

{% endtab %}
{% endtabs %}

## Remove item from inventory

<mark style="color:green;">`POST`</mark> `/v3/inventory/remove`

**Headers**

| Name                                            | Value            |
| ----------------------------------------------- | ---------------- |
| X-Api-Key<mark style="color:red;">\*</mark>     | API Key          |
| Authorization<mark style="color:red;">\*</mark> | `Bearer <token>` |

**Body**

| Name                                             | Type   | Description  |
| ------------------------------------------------ | ------ | ------------ |
| `inventory_id`<mark style="color:red;">\*</mark> | string | Inventory ID |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Inventory removed"
}
```

{% endtab %}

{% tab title="400 (invalid ID)" %}

```json
{
    "status": "error",
    "messages": {
        "inventory_id": "The selected inventory id is invalid."
    }
}
```

{% endtab %}

{% tab title="400 (invalid owner)" %}

```json
{
    "status": "error",
    "messages": {
        "invalidOwner": "Invalid inventory owner"
    }
}
```

{% endtab %}

{% tab title="400 (invalid game)" %}

```json
{
    "status": "error",
    "messages": {
        "invalidGame": "This game is not authorized to remove this item"
    }
}
```

{% endtab %}
{% endtabs %}

## Inject mystery box ticket

<mark style="color:green;">`POST`</mark> `/v3/inventory/inject/mystery-box-ticket`

**Headers**

| Name                                            | Value            |
| ----------------------------------------------- | ---------------- |
| X-API-Key<mark style="color:red;">\*</mark>     | `API Key`        |
| Authorization<mark style="color:red;">\*</mark> | `Bearer <token>` |

**Body**

| Name                                    | Type   | Description               |
| --------------------------------------- | ------ | ------------------------- |
| `qty`<mark style="color:red;">\*</mark> | string | amount of ticket injected |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Mystery box ticket added"
}
```

{% endtab %}
{% endtabs %}

## Inject in-game items

<mark style="color:green;">`POST`</mark> `/v3/inventory/inject/in-game-item`

{% hint style="warning" %}
Before injecting to inventory, make sure the item is available on database alphagames `game_items` table
{% endhint %}

**Headers**

| Name                                            | Value            |
| ----------------------------------------------- | ---------------- |
| X-Api-Key<mark style="color:red;">\*</mark>     | `API Key`        |
| Authorization<mark style="color:red;">\*</mark> | `Bearer <token>` |

**Body**

| Name                                          | Type   | Description                                                   |
| --------------------------------------------- | ------ | ------------------------------------------------------------- |
| `item_list`<mark style="color:red;">\*</mark> | string | Stringified json of game\_internal\_id and qty. Example below |

**Example Payload**

{% code overflow="wrap" %}

```json
{
    "item_list": "[{\"game_internal_id\":\"life_30_minutes\",\"qty\":2},{\"game_internal_id\":\"other_internal_id\",\"qty\":3}]"
}
```

{% endcode %}

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "Item injected successfully"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": "error",
    "messages": {
        "itemNotExists": "Item with game_internal_id other_internal_id is not exist"
    }
}
```

{% endtab %}
{% endtabs %}

## Inject alfa voucher (from reward pool)

<mark style="color:green;">`POST`</mark> `/v3/inventory/inject/voucher`

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name   | Type   | Description      |
| ------ | ------ | ---------------- |
| `name` | string | Name of the user |
| `age`  | number | Age of the user  |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "messages": "All voucher injected successfully"
}
```

{% endtab %}

{% tab title="400 (voucher stock below margin)" %}

```json
{
    "status": "error",
    "messages": {
        "stockBelowMargin": "Voucher stock for 25000 is below allowed margin."
    }
}
```

{% endtab %}

{% tab title="400 (invalid json data)" %}

```json
// qty is not integer or below 1
{
    "status": "error",
    "messages": {
        "invalidQty": "Invalid qty"
    }
}

// voucher_value is not available on database
{
    "status": "error",
    "messages": {
        "invalidVoucherValue": "Invalid voucher_value"
    }
}
```

{% endtab %}
{% endtabs %}
