Beispiel #1
0
        public static HashSet <string> GetScenesCids(IWebRequest webRequest, ApiTLD tld, List <Vector2Int> coords)
        {
            HashSet <string> sceneCids = new HashSet <string>();

            foreach (Vector2Int v in coords)
            {
                string url = GetScenesAPIUrl(tld, v.x, v.y, 0, 0);

                DownloadHandler downloadHandler = null;

                try
                {
                    downloadHandler = webRequest.Get(url);
                }
                catch (HttpRequestException e)
                {
                    throw new HttpRequestException($"Request error! Parcels couldn't be fetched! -- {url} -- {e.Message}", e);
                }

                ScenesAPIData scenesApiData = JsonUtility.FromJson <ScenesAPIData>(downloadHandler.text);
                downloadHandler.Dispose();

                Assert.IsTrue(scenesApiData != null, "Invalid response from ScenesAPI");
                Assert.IsTrue(scenesApiData.data != null, "Invalid response from ScenesAPI");

                foreach (var data in scenesApiData.data)
                {
                    sceneCids.Add(data.root_cid);
                }
            }

            return(sceneCids);
        }
Beispiel #2
0
        public static MappingsAPIData GetSceneMappingsData(IWebRequest webRequest, ApiTLD tld, string sceneCid)
        {
            string url = GetMappingsAPIUrl(tld, sceneCid);

            DownloadHandler downloadHandler = null;

            try
            {
                downloadHandler = webRequest.Get(url);
            }
            catch (HttpRequestException e)
            {
                throw new Exception($"Request error! mappings couldn't be fetched for scene {sceneCid}! -- {e.Message}");
            }

            MappingsAPIData parcelInfoApiData = JsonUtility.FromJson <MappingsAPIData>(downloadHandler.text);

            downloadHandler.Dispose();

            if (parcelInfoApiData.data.Length == 0 || parcelInfoApiData.data == null)
            {
                throw new Exception("MappingsAPIData is null?");
            }

            return(parcelInfoApiData);
        }
        public static string GetMappingsAPIUrl(ApiTLD env, string cid)
        {
            string baseUrl = GetBaseUrl(env);
            string result  = $"{baseUrl}/parcel_info?cids={cid}";

            Debug.Log($"Using mappings url {result}");
            return(result);
        }
        public static string GetBaseUrl(ApiTLD tld)
        {
            if (tld != ApiTLD.NONE)
            {
                return($"https://peer.decentraland.{GetTldString(tld)}/lambdas/contentv2");
            }

            return(customBaseUrl);
        }
        public static string GetScenesAPIUrl(ApiTLD env, int x1, int y1, int width, int height)
        {
            width  = Mathf.Max(0, width - 1);
            height = Mathf.Max(0, height - 1);

            string baseUrl = GetBaseUrl(env);
            string result  = $"{baseUrl}/scenes?x1={x1}&x2={x1 + width}&y1={y1}&y2={y1 + height}";

            Debug.Log($"Using scenes API url {result}");
            return(result);
        }
        public static string GetTldString(ApiTLD tld)
        {
            switch (tld)
            {
            case ApiTLD.NONE:
                break;

            case ApiTLD.TODAY:
                return("today");

            case ApiTLD.ZONE:
                return("zone");

            case ApiTLD.ORG:
                return("org");
            }

            return("org");
        }
        public static string GetContentAPIUrlBase(ApiTLD env)
        {
            string baseUrl = GetBaseUrl(env);

            return($"{baseUrl}/contents/");
        }