邮箱多物品消耗
用于从邮箱中一次消耗多个物品的 API。
URL 确认
此 API 使用 service-api.playnanoo.com 域名。
API 信息
- URL:
https://service-api.playnanoo.com/inbox/v20220901/consume/multi - Method:
PUT - 需要认证: 是
DeviceInfo 继承
此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性会自动包含。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| item_keys | string | 必填 | 要消耗的物品键(逗号分隔的字符串,例:"key1,key2,key3") |
响应数据
Res 类
| 字段 | 类型 | 说明 |
|---|---|---|
| items | SerializeItems[] | 已消耗的物品列表 |
SerializeItems 结构
| 字段 | 类型 | 说明 |
|---|---|---|
| item_code | string | 物品代码 |
| item_count | int | 物品数量 |
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 InboxConsumeMultiItem
{
static string url = "https://service-api.playnanoo.com/inbox/v20220901/consume/multi";
[Serializable]
public class Req : DeviceInfo
{
//string item_keys = key[0],key[1],key[2];
public string item_keys;
public IEnumerator Send(
string item_keys,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (item_keys != null) this.item_keys = item_keys;
// PUT 방식 호출
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;
}
}
使用示例
public void ConsumeMultipleInboxItems()
{
InboxConsumeMultiItem.Req req = new InboxConsumeMultiItem.Req();
// 아이템 키를 쉼표로 구분된 문자열로 생성
string itemKeys = "item_key_12345,item_key_67890,item_key_abcde";
StartCoroutine(req.Send(
item_keys: itemKeys,
onSuccess: res =>
{
Debug.Log("우편함 다중 아이템 소비 성공");
if (res.items != null)
{
foreach (var item in res.items)
{
Debug.Log($"아이템: {item.item_code}, 개수: {item.item_count}");
}
}
},
onError: (error) =>
{
Debug.LogError($"우편함 다중 아이템 소비 실패: [{error.ErrorCode}] [{error.Message}]");
}
));
}
物品键格式
item_keys 是以逗号(,)分隔的字符串格式。例:"key1,key2,key3"