物品查询
用于查询邮箱中物品列表的 API。
URL 确认
此 API 使用 service-api.playnanoo.com 域名。
API 信息
- URL:
https://service-api.playnanoo.com/inbox/v20220901/items - Method:
PUT - 需要认证: 是
DeviceInfo 继承
此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性会自动包含。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| table_code | string | 必填 | 表代码 |
响应数据
Res 类
| 字段 | 类型 | 说明 |
|---|---|---|
| items | SerializeInbox[] | 邮箱物品列表 |
SerializeInbox 结构
| 字段 | 类型 | 说明 |
|---|---|---|
| type | string | 物品类型 |
| item_key | string | 物品唯一键 |
| items | SerializeItems[] | 物品详情列表 |
| messages | SerializeItemMessages[] | 物品消息列表 |
| expire_sec | int | 过期时间(秒) |
SerializeItems 结构
| 字段 | 类型 | 说明 |
|---|---|---|
| item_code | string | 物品代码 |
| item_count | int | 物品数量 |
SerializeItemMessages 结构
| 字段 | 类型 | 说明 |
|---|---|---|
| language | string | 语言代码 |
| title | string | 消息标题 |
| content | string | 消息内容 |
Unity C# 实现
BaseResponse 类
所有 API 响应的基类。
public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}
字段说明:
ErrorCode:错误代码Message:错误信息WithdrawalKey:账号处于注销等待状态时,用于恢复的密钥(仅注销等待中的账号提供)BlockKey:账号被封禁时提供的密钥(仅被封禁的账号提供)
邮箱物品列表查询类
using System;
using System.Collections;
using UnityEngine.Networking;
public class InboxItems
{
static string url = "https://service-api.playnanoo.com/inbox/v20220901/items";
[Serializable]
public class Req : DeviceInfo
{
public string table_code;
public IEnumerator Send(
string table_code,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(table_code)) this.table_code = table_code;
// PUT 방식 호출
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
url,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public SerializeInbox[] items;
}
[Serializable]
public class SerializeInbox
{
public string type;
public string item_key;
public SerializeItems[] items;
public SerializeItemMessages[] messages;
public int expire_sec;
}
[Serializable]
public class SerializeItems
{
public string item_code;
public int item_count;
}
[Serializable]
public class SerializeItemMessages
{
public string language;
public string title;
public string content;
}
}
使用示例
public void GetInboxItems()
{
InboxItems.Req req = new InboxItems.Req();
StartCoroutine(req.Send(
table_code: "inbox_table_01",
onSuccess: res =>
{
Debug.Log("우편함 아이템 목록 조회 성공");
if (res.items != null)
{
foreach (var inbox in res.items)
{
Debug.Log($"아이템 키: {inbox.item_key}, 타입: {inbox.type}, 만료: {inbox.expire_sec}초");
if (inbox.items != null)
{
foreach (var item in inbox.items)
{
Debug.Log($" - {item.item_code}: {item.item_count}개");
}
}
if (inbox.messages != null)
{
foreach (var msg in inbox.messages)
{
Debug.Log($" 메시지[{msg.language}]: {msg.title} - {msg.content}");
}
}
}
}
},
onError: (error) =>
{
Debug.LogError($"우편함 아이템 목록 조회 실패: [{error.ErrorCode}] [{error.Message}]");
}
));
}
表代码
table_code 是在 PlayNANOO 控制台中创建的邮箱表的代码。