본문으로 건너뛰기

아이템 사용

우편함에서 단일 아이템을 소비하는 API입니다.

URL 확인

이 API는 service-api.playnanoo.com 도메인을 사용합니다.

API 정보

  • URL: https://service-api.playnanoo.com/inbox/v20220901/consume/item
  • Method: PUT
  • 인증 필요: 예
DeviceInfo 상속

이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.

요청 파라미터

파라미터타입필수설명
item_keystring필수소비할 아이템 키

응답 데이터

Res 클래스

필드타입설명
itemsSerializeItems[]소비된 아이템 목록

SerializeItems 구조

필드타입설명
item_codestring아이템 코드
item_countint아이템 개수

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 InboxConsumeItem
{
static string url = "https://service-api.playnanoo.com/inbox/v20220901/consume/item";

[Serializable]
public class Req : DeviceInfo
{
public string item_key;

public IEnumerator Send(
string item_key,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(item_key)) this.item_key = item_key;

// 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 ConsumeInboxItem()
{
InboxConsumeItem.Req req = new InboxConsumeItem.Req();

StartCoroutine(req.Send(
item_key: "item_key_12345",
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_key는 우편함 아이템 목록 조회 API에서 반환된 아이템의 고유 키입니다.