private IEnumerator GetLastPubDateCoroutine(string id) { string json = string.Concat("{ \"id\" : \"", id, "\" }"); string url = "https://isartdigitalf2pscrawl.herokuapp.com/lastPubDate/get"; using (UnityWebRequest req = PostJson(url, json)) { req.SetRequestHeader("Authorization", "Bearer " + Token); yield return(req.SendWebRequest()); if (req.isNetworkError || req.isHttpError) { Debug.LogWarning(string.Concat("[ServerManager] Cannot get LastPubDate, reason : ", req.downloadHandler.text)); LastPubDate date = new LastPubDate(GameManager.Credentials.id, System.DateTime.Now); SaveLastPubDate(date); AdsManager.Instance.GetLastPubDate(date); } else { LastPubDate date = JsonUtility.FromJson <LastPubDate>(req.downloadHandler.text); AdsManager.Instance.GetLastPubDate(date); } } }
private IEnumerator SaveLastPubDateCoroutine(LastPubDate date) { string json = JsonUtility.ToJson(date); //Debug.Log(json); string url = "https://isartdigitalf2pscrawl.herokuapp.com/lastPubDate/save"; using (UnityWebRequest req = PostJson(url, json)) { req.SetRequestHeader("Authorization", "Bearer " + Token); yield return(req.SendWebRequest()); if (req.isNetworkError || req.isHttpError) { Debug.LogWarning(string.Concat("[ServerManager] Cannot save LastPubDate, reason : ", req.downloadHandler.text)); } } }
public void SaveLastPubDate(LastPubDate date) { StartCoroutine(SaveLastPubDateCoroutine(date)); }