아이템 조회
우편함에 있는 아이템 목록을 조회하는 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 콘솔에서 생성한 우편함 테이블의 코드입니다.