< Summary

Class:WearablesAPIData
Assembly:WearablesFetching
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/ServiceProviders/Wearables/WearablesAPIData.cs
Covered lines:0
Uncovered lines:16
Coverable lines:16
Total lines:125
Line coverage:0% (0 of 16)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetWearableItems()0%42600%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/ServiceProviders/Wearables/WearablesAPIData.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4[Serializable]
 5public class WearablesAPIData
 6{
 7    [Serializable]
 8    public class Wearable
 9    {
 10        [Serializable]
 11        public class Data
 12        {
 13            [Serializable]
 14            public class Representation
 15            {
 16                [Serializable]
 17                public class Content
 18                {
 19                    public string key;
 20                    public string url;
 21                }
 22
 23                public string[] bodyShapes;
 24                public string mainFile;
 25                public string[] overrideReplaces;
 26                public string[] overrideHides;
 27                public Content[] contents;
 28            }
 29
 30            public string[] tags;
 31            public string category;
 32            public Representation[] representations;
 33        }
 34
 35        public string id;
 36        public string description;
 37        public string thumbnail;
 38        public string rarity;
 39        public Data data;
 40        public i18n[] i18n;
 41        public int createdAt;
 42        public int updatedAt;
 43    }
 44
 45    [Serializable]
 46    public class PaginationData
 47    {
 48        public int limit;
 49        public string next = null;
 50    }
 51
 52    private const string WEARABLES_CONTENT_BASE_URL = "https://peer.decentraland.org/content/contents/";
 53
 54    public List<Wearable> wearables;
 55    public PaginationData pagination;
 56    public List<WearableItem> GetWearableItems()
 57    {
 058        if (wearables == null || wearables.Count == 0)
 059            return null;
 60
 061        List<WearableItem> result = new List<WearableItem>();
 62
 063        foreach (var wearableData in wearables)
 64        {
 65            // Populate new WearableItem with fetched data
 066            WearableItem wearable = new WearableItem()
 67            {
 68                id = wearableData.id,
 69                baseUrl = WEARABLES_CONTENT_BASE_URL,
 70                thumbnail = wearableData.thumbnail,
 71                rarity = wearableData.rarity,
 72                description = wearableData.description,
 73                i18n = wearableData.i18n,
 74                data = new WearableItem.Data()
 75                {
 76                    category = wearableData.data.category,
 77                    tags = wearableData.data.tags
 78                }
 79            };
 80
 081            List<WearableItem.Representation> wearableRepresentations = new List<WearableItem.Representation>();
 082            foreach (var wearableDataRepresentation in wearableData.data.representations)
 83            {
 084                WearableItem.Representation wearableRepresentation = new WearableItem.Representation()
 85                {
 86                    bodyShapes = wearableDataRepresentation.bodyShapes,
 87                    overrideHides = wearableDataRepresentation.overrideHides,
 88                    overrideReplaces = wearableDataRepresentation.overrideReplaces,
 89                    mainFile = wearableDataRepresentation.mainFile
 90                };
 91
 092                List<WearableItem.MappingPair> contentMappingPairs = new List<WearableItem.MappingPair>();
 093                foreach (var content in wearableDataRepresentation.contents)
 94                {
 095                    contentMappingPairs.Add(new WearableItem.MappingPair()
 96                    {
 97                        key = content.key,
 98                        hash = content.url.Substring(content.url.LastIndexOf("/") + 1)
 99                    });
 100                }
 101
 0102                wearableRepresentation.contents = contentMappingPairs.ToArray();
 0103                wearableRepresentations.Add(wearableRepresentation);
 104            }
 105
 0106            wearable.data.representations = wearableRepresentations.ToArray();
 0107            result.Add(wearable);
 108        }
 109
 0110        return result;
 111    }
 112}
 113
 114[Serializable]
 115public class WearableCollectionsAPIData
 116{
 117    [Serializable]
 118    public class Collection
 119    {
 120        public string id;
 121        public string name;
 122    }
 123
 124    public Collection[] collections;
 125}

Methods/Properties

GetWearableItems()