Consume Item
API to consume a single item from the inbox.
URL Confirmation
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/inbox/v20220901/consume/item - Method:
PUT - Authentication Required: Yes
DeviceInfo Inheritance
The Req class of this API inherits from DeviceInfo. All properties of DeviceInfo are automatically included.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| item_key | string | Yes | Item key to consume |
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| items | SerializeItems[] | List of consumed items |
SerializeItems Structure
| Field | Type | Description |
|---|---|---|
| item_code | string | Item code |
| item_count | int | Item count |
Unity C# Implementation
BaseResponse Class
Base class for all API responses.
public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}
Field descriptions:
ErrorCode: Error codeMessage: Error messageWithdrawalKey: Key required for recovery if account is in withdrawal grace period (provided only for accounts in withdrawal grace period)BlockKey: Key provided for blocked accounts (provided only for blocked accounts)
Inbox Item Consume Class
using System;
using System.Collections;
using UnityEngine.Networking;
public class InboxConsumeItem
{
static string url = "https://service-api.playnanoo.com/inbox/v20220901/consume/item";
[Serializable]
public class Req : DeviceInfo
{
public string item_key;
public IEnumerator Send(
string item_key,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(item_key)) this.item_key = item_key;
// PUT method call
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
url,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public SerializeItems[] items;
}
[Serializable]
public class SerializeItems
{
public string item_code;
public int item_count;
}
}
Usage Example
public void ConsumeInboxItem()
{
InboxConsumeItem.Req req = new InboxConsumeItem.Req();
StartCoroutine(req.Send(
item_key: "item_key_12345",
onSuccess: res =>
{
Debug.Log("Inbox item consumption successful");
if (res.items != null)
{
foreach (var item in res.items)
{
Debug.Log($"Item: {item.item_code}, Count: {item.item_count}");
}
}
},
onError: (error) =>
{
Debug.LogError($"Inbox item consumption failed: [{error.ErrorCode}] [{error.Message}]");
}
));
}
Item Key
item_key is the unique key of the item returned from the inbox item list query API.