Data Retrieval
API for retrieving remote configuration values.
URL Confirmation
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/storage/v20211101/load/public - Method:
PUT - Authentication Required: Yes
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| storage_key | string | Required | Remote configuration key (RemoteConfig_{tableCode} format) |
DeviceInfo Inheritance
The Req class of this API inherits from DeviceInfo. All properties of DeviceInfo are automatically included.
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| StorageKey | string | Storage key |
| StorageValue | string | Storage value |
| remote_config_variables | List\<RemoteConfigVariable> | List of remote configuration variables |
RemoteConfigVariable Structure
| Field | Type | Description |
|---|---|---|
| remote_config_variable_type | string | Variable type |
| remote_config_variable_key | string | Variable key |
| remote_config_variable_description | string | Variable description |
| remote_config_variable_value | string | Variable value |
| remote_config_variable_createdAt | long | Creation time |
Unity C# Implementation
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;
}
}
Usage Example
public void LoadRemoteConfig()
{
string tableCode = "Remote Config Table Code";
RemoteConfig.Req req = new RemoteConfig.Req();
StartCoroutine(req.Send(
tableCode: tableCode,
onSuccess: res =>
{
// No additional parsing required when using 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 failed: [{error.ErrorCode}] {error.Message}");
}
));
}