데이터 조회
원격 구성 값을 조회하는 API입니다.
URL 확인
이 API는 service-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-api.playnanoo.com/storage/v20211101/load/public - Method:
PUT - 인증 필요: 예
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| storage_key | string | 필수 | 원격 구성 키 (RemoteConfig_{tableCode} 형식) |
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| StorageKey | string | 스토리지 키 |
| StorageValue | string | 스토리지 값 |
| remote_config_variables | List\<RemoteConfigVariable> | 원격 구성 변수 목록 |
RemoteConfigVariable 구조
| 필드 | 타입 | 설명 |
|---|---|---|
| remote_config_variable_type | string | 변수 타입 |
| remote_config_variable_key | string | 변수 키 |
| remote_config_variable_description | string | 변수 설명 |
| remote_config_variable_value | string | 변수 값 |
| remote_config_variable_createdAt | long | 생성 시간 |
Unity C# 구현
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;
public class RemoteConfig
{
static string url = "https://service-api.playnanoo.com/storage/v20211101/load/public";
[Serializable]
public class Req : DeviceInfo
{
public string storage_key;
public IEnumerator Send(
string tableCode,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(tableCode)) this.storage_key = $"RemoteConfig_{tableCode}";
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
url,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string StorageKey;
public string StorageValue;
public List<RemoteConfigVariable> remote_config_variables;
}
[Serializable]
public class RemoteConfigVariable
{
public string remote_config_variable_type;
public string remote_config_variable_key;
public string remote_config_variable_description;
public string remote_config_variable_value;
public long remote_config_variable_createdAt;
}
}
사용 예제
public void LoadRemoteConfig()
{
string tableCode = "Remote Config Table Code";
RemoteConfig.Req req = new RemoteConfig.Req();
StartCoroutine(req.Send(
tableCode: tableCode,
onSuccess: res =>
{
// Newtonsoft.Json을 사용하면 추가 파싱을 하지 않아도 됩니다.
var data = JsonUtility.FromJson<RemoteConfig.Res>(res.StorageValue);
foreach (var v in data.remote_config_variables)
{
Debug.Log($"Type : [{v.remote_config_variable_type}]");
Debug.Log($"Key : [{v.remote_config_variable_key}]");
Debug.Log($"Description : [{v.remote_config_variable_description}]");
Debug.Log($"Value : [{v.remote_config_variable_value}]");
Debug.Log($"CreateAt : [{v.remote_config_variable_createdAt}]");
}
},
onError: (error) =>
{
Debug.LogError($"RemoteConfig 실패: [{error.ErrorCode}] {error.Message}");
}
));
}