Ejemplo n.º 1
0
        public virtual async Task <SnapshotResponse> GetSnapshot(Tuple <string, string> slug)
        {
            var snapReq = new SnapshotRequest();

            snapReq.SetQuery($"slug:{slug.Item1}", $"snapshotType:{slug.Item2}");
            snapReq.SetFields("snapNum", "title", "snapshotType", "isActive", "id", "createdDate", "updatedDate");
            // build the rest of the Json request, what sections to include/exclude
            // first, the tech cards
            var incCard     = new IncludeItem("card", new Include("name"));
            var incCardTech = new IncludeItem("cardTech", incCard);
            var incDeckTech = new IncludeItem("deckTech", incCardTech);
            // then, acutal decks and cards
            var incSlugs    = new IncludeItem("slugs", new Include("linked", "slug"));
            var inCardsCard = new IncludeItem("card", new Include("id", "name", "cardType", "cost"));
            var incCards    = new IncludeItem("cards", inCardsCard);
            var incDeck     = new IncludeItem("deck", new Include()
            {
                Fields = new List <string> {
                    "id", "name", "slug", "playerClass"
                },
                Items = new List <IncludeItem>()
                {
                    incSlugs, incCards
                }
            });
            var incTiers = new IncludeItem("deckTiers", new Include()
            {
                Fields = new List <string> {
                    "name", "id", "deckId", "tier"
                },
                Items = new List <IncludeItem>()
                {
                    incDeck, incDeckTech
                }
            });

            snapReq.Includes = new List <IncludeItem>()
            {
                incTiers
            };
            // make the request and deserialize
            var snapRespJson = await _http.JsonGet(BaseSnapshotUrl + JsonConvert.SerializeObject(snapReq, _settings));

            var snapResponse = JsonConvert.DeserializeObject <SnapshotResponse>(snapRespJson);

            // check there are no errors
            if (snapResponse.Error != null)
            {
                throw new ImportException($"Getting the snapshot failed ({snapResponse.Error.Status})");
            }

            return(snapResponse);
        }
Ejemplo n.º 2
0
 public IncludeItem(string relation, IncludeItem single)
 {
     Relation = relation;
     Scope    = new Include(single);
 }