본문으로 건너뛰기

아이템 지급

우편함으로 아이템을 전송하는 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_codestring필수테이블 코드
itemsstring필수전송할 아이템 데이터 (JSON 문자열)
periodint필수유효 기간 (일 단위)

응답 데이터

Res 클래스

필드타입설명
statusstring처리 상태

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 클래스에 정의된 언어 코드를 사용하여 다국어 메시지를 설정할 수 있습니다.