이전 시즌 범위 조회
이전 시즌 리더보드의 특정 범위 순위를 조회하는 API입니다.
URL 확인
이 API는 service-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-api.playnanoo.com/leaderboard/v20240301/range/prev - Method:
PUT - 인증 필요: 예
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| uid | string | 필수 | 테이블 코드 |
| rotation_count | int | 필수 | 시즌 번호 (조회할 이전 시즌) |
| range_start | int | 필수 | 시작 순위 (1부터 시작) |
| range_end | int | 필수 | 종료 순위 |
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| Items | List<RangeItemModel> | 순위 목록 |
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 System.Collections.Generic;
using UnityEngine.Networking;
public class RangePrev
{
static string path = "https://service-api.playnanoo.com/leaderboard/v20240301/range/prev";
[Serializable]
public class Req : DeviceInfo
{
public string uid;
public int rotation_count;
public int range_start;
public int range_end;
public IEnumerator Send(string table_code, int rotaionCount, int rangeStart, int rangeEnd, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(table_code)) this.uid = table_code;
this.rotation_count = rotaionCount;
this.range_start = rangeStart;
this.range_end = rangeEnd;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public List<RangeItemModel> Items;
}
[Serializable]
public class RangeItemModel
{
public int Rank;
public int RotationCount;
public string RecordId;
public int Score;
public string ExtraData;
}
}
사용 예제
public void GetPreviousSeasonRange()
{
RangePrev.Req req = new RangePrev.Req();
StartCoroutine(req.Send(
table_code: "my_leaderboard_table",
rotaionCount: 1, // 이전 시즌 번호
rangeStart: 1, // 1위부터
rangeEnd: 10, // 10위까지
onSuccess: res =>
{
Debug.Log("이전 시즌 순위 조회 성공");
Debug.Log($"조회된 기록 수: {res.Items.Count}");
foreach (var item in res.Items)
{
Debug.Log($"순위: {item.Rank}");
Debug.Log($"플레이어 ID: {item.RecordId}");
Debug.Log($"점수: {item.Score}");
Debug.Log($"시즌: {item.RotationCount}");
if (!string.IsNullOrEmpty(item.ExtraData))
{
Debug.Log($"추가 데이터: {item.ExtraData}");
}
}
},
onError: error =>
{
Debug.LogError($"이전 시즌 순위 조회 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
이전 시즌 범위 조회
rotation_count로 특정 이전 시즌을 지정하고, range_start와 range_end로 순위 범위를 지정할 수 있습니다.
시즌별 순위
이전 시즌의 순위 데이터는 읽기 전용이며, 시즌별로 구분하여 저장됩니다. 각 시즌의 상위 랭커를 조회하여 시즌 보상을 지급하는 등의 용도로 활용할 수 있습니다.