우편함 다중 아이템 소비
우편함에서 여러 아이템을 한 번에 소비하는 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"