본문으로 건너뛰기

데이터 조회

원격 구성 값을 조회하는 API입니다.

URL 확인

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

API 정보

  • URL: https://service-api.playnanoo.com/storage/v20211101/load/public
  • Method: PUT
  • 인증 필요: 예

요청 파라미터

파라미터타입필수설명
storage_keystring필수원격 구성 키 (RemoteConfig_{tableCode} 형식)
DeviceInfo 상속

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

응답 데이터

Res 클래스

필드타입설명
StorageKeystring스토리지 키
StorageValuestring스토리지 값
remote_config_variablesList\<RemoteConfigVariable>원격 구성 변수 목록

RemoteConfigVariable 구조

필드타입설명
remote_config_variable_typestring변수 타입
remote_config_variable_keystring변수 키
remote_config_variable_descriptionstring변수 설명
remote_config_variable_valuestring변수 값
remote_config_variable_createdAtlong생성 시간

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}");
}
));
}