이전 시즌 기록 수정
이전 시즌 리더보드 기록의 추가 데이터를 수정하는 API입니다.
URL 확인
이 API는 service-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-api.playnanoo.com/leaderboard/v20240301/edit/prev - Method:
PUT - 인증 필요: 예
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| uid | string | 필수 | 테이블 코드 |
| record_id | string | 필수 | 기록 ID (플레이어 식별자) |
| extra_data | string | 필수 | 추가 데이터 (JSON 문자열) |
| rotation_count | int | 필수 | 시즌 번호 (조회할 이전 시즌) |
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| Status | 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 PlayerEditPrev
{
static string path = "https://service-api.playnanoo.com/leaderboard/v20240301/edit/prev";
[Serializable]
public class Req : DeviceInfo
{
public string uid;
public string record_id;
public string extra_data;
public int rotation_count;
public IEnumerator Send(string table_code, string recordId, string extraData, int rotaionCount, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(table_code)) this.uid = table_code;
if (!string.IsNullOrEmpty(recordId)) this.record_id = recordId;
if (!string.IsNullOrEmpty(extraData)) this.extra_data = extraData;
this.rotation_count = rotaionCount;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string Status;
}
}
사용 예제
public void EditPreviousSeasonData()
{
PlayerEditPrev.Req req = new PlayerEditPrev.Req();
// 추가 데이터를 JSON으로 직렬화
var extraData = new
{
season = 1,
reward_claimed = true,
notes = "Season 1 rewards collected"
};
string jsonExtra = JsonUtility.ToJson(extraData);
StartCoroutine(req.Send(
table_code: "my_leaderboard_table",
recordId: "player_001",
extraData: jsonExtra,
rotaionCount: 1, // 이전 시즌 번호
onSuccess: res =>
{
Debug.Log("이전 시즌 추가 데이터 수정 성공");
Debug.Log($"상태: {res.Status}");
},
onError: error =>
{
Debug.LogError($"이전 시즌 추가 데이터 수정 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
이전 시즌 수정
이 API는 이전 시즌의 점수는 변경하지 않고 extra_data만 수정합니다. rotation_count로 특정 시즌을 지정할 수 있습니다.
시즌 번호
rotation_count는 현재 시즌을 기준으로 이전 시즌을 나타냅니다. 예를 들어, rotation_count=1은 바로 이전 시즌을 의미합니다.