发放物品
用于通过邮箱发送物品的 API。
URL 确认
此 API 使用 service-api.playnanoo.com 域名。
API 信息
- URL:
https://service-api.playnanoo.com/inbox/v20220901/send - Method:
PUT - 需要认证: 是
DeviceInfo 继承
此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性会自动包含。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| table_code | string | 必填 | 表代码 |
| items | string | 必填 | 发送的物品数据(JSON 字符串) |
| period | int | 必填 | 有效期(天) |
响应数据
Res 类
| 字段 | 类型 | 说明 |
|---|---|---|
| status | 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;
using UnityEngine.Networking;
public class InboxSendItem
{
static string url = "https://service-api.playnanoo.com/inbox/v20220901/send";
[Serializable]
public class Req : DeviceInfo
{
public string table_code;
// string items = JsonUtility.ToJson(SerializePost items)
public string items;
public int period;
public IEnumerator Send(
string table_code,
string items,
int period,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(table_code)) this.table_code = table_code;
if (!string.IsNullOrEmpty(items)) this.items = items;
this.period = period;
// PUT 방식 호출
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
url,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string status;
}
[Serializable]
public class SerializePost
{
public SerializeItems[] items;
public SerializeItemMessages[] messages;
}
[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 class InboxConfigure
{
public static readonly string PN_LANG_CODE_DEFAULT = "default";
public static readonly string PN_LANG_CODE_AF = "AF";
public static readonly string PN_LANG_CODE_AR = "AR";
public static readonly string PN_LANG_CODE_EU = "EU";
public static readonly string PN_LANG_CODE_BE = "BE";
public static readonly string PN_LANG_CODE_BG = "BG";
public static readonly string PN_LANG_CODE_CA = "CA";
public static readonly string PN_LANG_CODE_CN = "zh-CN";
public static readonly string PN_LANG_CODE_TW = "zh-TW";
public static readonly string PN_LANG_CODE_CS = "CS";
public static readonly string PN_LANG_CODE_DA = "DA";
public static readonly string PN_LANG_CODE_NL = "NL";
public static readonly string PN_LANG_CODE_EN = "EN";
public static readonly string PN_LANG_CODE_ET = "ET";
public static readonly string PN_LANG_CODE_FO = "FO";
public static readonly string PN_LANG_CODE_FI = "FI";
public static readonly string PN_LANG_CODE_FR = "FR";
public static readonly string PN_LANG_CODE_DE = "DE";
public static readonly string PN_LANG_CODE_EL = "EL";
public static readonly string PN_LANG_CODE_IW = "IW";
public static readonly string PN_LANG_CODE_HU = "HU";
public static readonly string PN_LANG_CODE_IS = "IS";
public static readonly string PN_LANG_CODE_IN = "IN";
public static readonly string PN_LANG_CODE_IT = "IT";
public static readonly string PN_LANG_CODE_JA = "JA";
public static readonly string PN_LANG_CODE_KO = "KO";
public static readonly string PN_LANG_CODE_LV = "LV";
public static readonly string PN_LANG_CODE_LT = "LT";
public static readonly string PN_LANG_CODE_NO = "NO";
public static readonly string PN_LANG_CODE_PL = "PN";
public static readonly string PN_LANG_CODE_PT = "PT";
public static readonly string PN_LANG_CODE_RO = "RO";
public static readonly string PN_LANG_CODE_RU = "RU";
public static readonly string PN_LANG_CODE_SH = "SH";
public static readonly string PN_LANG_CODE_SK = "SK";
public static readonly string PN_LANG_CODE_SL = "SL";
public static readonly string PN_LANG_CODE_ES = "ES";
public static readonly string PN_LANG_CODE_SV = "SV";
public static readonly string PN_LANG_CODE_TH = "TH";
public static readonly string PN_LANG_CODE_TR = "TR";
public static readonly string PN_LANG_CODE_UK = "UK";
public static readonly string PN_LANG_CODE_VI = "VI";
}
}
使用示例
public void SendInboxItem()
{
InboxSendItem.Req req = new InboxSendItem.Req();
// 아이템 데이터 구성
InboxSendItem.SerializePost postData = new InboxSendItem.SerializePost
{
items = new InboxSendItem.SerializeItems[]
{
new InboxSendItem.SerializeItems { item_code = "gold", item_count = 1000 },
new InboxSendItem.SerializeItems { item_code = "diamond", item_count = 50 }
},
messages = new InboxSendItem.SerializeItemMessages[]
{
new InboxSendItem.SerializeItemMessages
{
language = InboxSendItem.InboxConfigure.PN_LANG_CODE_KO,
title = "보상",
content = "이벤트 보상입니다."
},
new InboxSendItem.SerializeItemMessages
{
language = InboxSendItem.InboxConfigure.PN_LANG_CODE_EN,
title = "Reward",
content = "Event reward."
}
}
};
// JSON 문자열로 변환
string itemsJson = JsonUtility.ToJson(postData);
StartCoroutine(req.Send(
table_code: "inbox_table_01",
items: itemsJson,
period: 7, // 7일 (일 단위)
onSuccess: res =>
{
Debug.Log($"우편함 아이템 전송 성공: {res.status}");
},
onError: (error) =>
{
Debug.LogError($"우편함 아이템 전송 실패: [{error.ErrorCode}] [{error.Message}]");
}
));
}
有效期
period 以天为单位指定。例如设置 7 天时输入 7。
语言代码
可以使用 InboxConfigure 类中定义的语言代码来设置多语言消息。