< Summary

Class:DCLServices.WearablesCatalogService.BuilderWearable
Assembly:WearablesCatalogService
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/WearablesCatalogService/WearableCollectionResponseFromBuilder.cs
Covered lines:0
Uncovered lines:5
Coverable lines:5
Total lines:122
Line coverage:0% (0 of 5)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:3
Method coverage:0% (0 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ToWearableRepresentation(...)0%2100%
ToWearableData(...)0%2100%
ToWearableItem(...)0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/WearablesCatalogService/WearableCollectionResponseFromBuilder.cs

#LineLine coverage
 1using DCL.Emotes;
 2using System;
 3using System.Collections.Generic;
 4using System.Linq;
 5
 6namespace DCLServices.WearablesCatalogService
 7{
 8    [Serializable]
 9    public class WearableCollectionResponseFromBuilder
 10    {
 11        [Serializable]
 12        public class Pagination
 13        {
 14            public int total;
 15            public int limit;
 16            public int pages;
 17            public int page;
 18            public BuilderWearable[] results;
 19        }
 20
 21        public Pagination data;
 22    }
 23
 24    [Serializable]
 25    public class WearableItemResponseFromBuilder
 26    {
 27        public BuilderWearable data;
 28    }
 29
 30    [Serializable]
 31    public class BuilderWearable
 32    {
 33        [Serializable]
 34        public class BuilderWearableData
 35        {
 36            [Serializable]
 37            public class Representation
 38            {
 39                public string[] bodyShapes;
 40                public string mainFile;
 41                public string[] contents;
 42                public string[] overrideHides;
 43                public string[] overrideReplaces;
 44
 45                public WearableItem.Representation ToWearableRepresentation(string contentUrl, Dictionary<string, string
 46                {
 047                    return new WearableItem.Representation
 48                    {
 49                        bodyShapes = bodyShapes,
 50                        mainFile = mainFile,
 51                        overrideHides = overrideHides,
 52                        overrideReplaces = overrideReplaces,
 053                        contents = contents.Select(s => new WearableItem.MappingPair
 54                                            {
 55                                                key = s,
 56                                                hash = hashes[s],
 57                                                url = $"{contentUrl}/{hashes[s]}",
 58                                            })
 59                                           .ToArray(),
 60                    };
 61                }
 62            }
 63
 64            public string category;
 65            public bool loop;
 66            public string[] replaces;
 67            public string[] hides;
 68            public string[] tags;
 69            public Representation[] representations;
 70            public bool blockVrmExport;
 71
 72            public WearableItem.Data ToWearableData(string contentUrl, Dictionary<string, string> hashes)
 73            {
 074                return new WearableItem.Data
 75                {
 76                    category = category,
 77                    hides = hides,
 78                    loop = loop,
 79                    replaces = replaces,
 80                    tags = tags,
 081                    representations = representations.Select(r => r.ToWearableRepresentation(contentUrl, hashes)).ToArra
 82
 83                    // TODO: builder api does not include this information
 84                    removesDefaultHiding = Array.Empty<string>(),
 85                    blockVrmExport = blockVrmExport,
 86                };
 87            }
 88        }
 89
 90        public string id;
 91        public string name;
 92        public string description;
 93        public string rarity;
 94        public string type;
 95        public BuilderWearableData data;
 96        public Dictionary<string, string> contents;
 97        public string thumbnail;
 98
 99        public WearableItem ToWearableItem(string contentUrl, string assetBundleUrl)
 100        {
 0101            return new WearableItem
 102            {
 103                id = id,
 104                baseUrl = contentUrl,
 105                description = description,
 106                thumbnail = contents[thumbnail],
 107                rarity = rarity,
 108                i18n = new[]
 109                {
 110                    new i18n
 111                    {
 112                        code = "en",
 113                        text = name,
 114                    },
 115                },
 116                baseUrlBundles = assetBundleUrl,
 117                data = data.ToWearableData(contentUrl, contents),
 118                emoteDataV0 = type == "emote" ? new EmoteDataV0 { loop = data.loop } : null,
 119            };
 120        }
 121    }
 122}