< Summary

Class:DCL.ContentServerUtils
Assembly:ContentServerUtils
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/Utils/ContentServerUtils/ContentServerUtils.cs
Covered lines:0
Uncovered lines:20
Coverable lines:20
Total lines:106
Line coverage:0% (0 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetTldString(...)0%30500%
ContentServerUtils()0%2100%
GetBaseUrl(...)0%6200%
GetScenesAPIUrl(...)0%2100%
GetMappingsAPIUrl(...)0%2100%
GetContentAPIUrlBase(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/Utils/ContentServerUtils/ContentServerUtils.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL
 4{
 5    public static class ContentServerUtils
 6    {
 7        [System.Serializable]
 8        public class ScenesAPIData
 9        {
 10            [System.Serializable]
 11            public class Data
 12            {
 13                public string parcel_id;
 14                public string root_cid;
 15                public string scene_cid;
 16            }
 17
 18            public Data[] data;
 19        }
 20
 21        [System.Serializable]
 22        public class MappingsAPIData
 23        {
 24            [System.Serializable]
 25            public class Data
 26            {
 27                [System.Serializable]
 28                public class Content
 29                {
 30                    public MappingPair[] contents;
 31                }
 32
 33                public Content content;
 34            }
 35
 36            public Data[] data;
 37        }
 38
 39        [System.Serializable]
 40        public class MappingPair
 41        {
 42            public string file;
 43            public string hash;
 44        }
 45
 46        public enum ApiTLD
 47        {
 48            NONE,
 49            TODAY,
 50            ZONE,
 51            ORG,
 52        }
 53
 54        public static string GetTldString(ApiTLD tld)
 55        {
 56            switch (tld)
 57            {
 58                case ApiTLD.NONE:
 59                    break;
 60                case ApiTLD.TODAY:
 061                    return "today";
 62                case ApiTLD.ZONE:
 063                    return "zone";
 64                case ApiTLD.ORG:
 065                    return "org";
 66            }
 67
 068            return "org";
 69        }
 70
 071        public static string customBaseUrl = "";
 72
 73        public static string GetBaseUrl(ApiTLD tld)
 74        {
 075            if (tld != ApiTLD.NONE)
 076                return $"https://peer-lb.decentraland.{GetTldString(tld)}/lambdas/contentv2";
 77
 078            return customBaseUrl;
 79        }
 80
 81        public static string GetScenesAPIUrl(ApiTLD env, int x1, int y1, int width, int height)
 82        {
 083            width = Mathf.Max(0, width - 1);
 084            height = Mathf.Max(0, height - 1);
 85
 086            string baseUrl = GetBaseUrl(env);
 087            string result = $"{baseUrl}/scenes?x1={x1}&x2={x1 + width}&y1={y1}&y2={y1 + height}";
 088            Debug.Log($"Using scenes API url {result}");
 089            return result;
 90        }
 91
 92        public static string GetMappingsAPIUrl(ApiTLD env, string cid)
 93        {
 094            string baseUrl = GetBaseUrl(env);
 095            string result = $"{baseUrl}/parcel_info?cids={cid}";
 096            Debug.Log($"Using mappings url {result}");
 097            return result;
 98        }
 99
 100        public static string GetContentAPIUrlBase(ApiTLD env)
 101        {
 0102            string baseUrl = GetBaseUrl(env);
 0103            return $"{baseUrl}/contents/";
 104        }
 105    }
 106}