Ejemplo n.º 1
0
        private static string GetUsername(Story.Rootobject s)
        {
            string authorId = s.data.First().relationships.author.data.id;

            var authorName = s.included.First(x => x.id == authorId && x.type == "user").attributes.name;

            return(authorName);
        }
Ejemplo n.º 2
0
        private static string GenerateTags(Story.Rootobject relationshipsTags)
        {
            List <string> tagIds =
                relationshipsTags.data.First().relationships.tags.data.Select(datum1 => datum1.id).ToList();
            List <string> tagNames = new List <string>();

            foreach (string tagId in tagIds)
            {
                string tagName =
                    relationshipsTags.included.First(x => x.id == tagId && x.type == "story_tag").attributes.name;
                tagNames.Add(tagName);
            }

            string builtTagLineContent = string.Join("`, `", tagNames);

            builtTagLineContent = "`" + builtTagLineContent + "`";
            return(builtTagLineContent);
        }
Ejemplo n.º 3
0
        private static List <Story.Rootobject> GetPostText(List <string> sanitizedNames)
        {
            List <Story.Rootobject> resultCollection = new List <Story.Rootobject>();

            foreach (var sanitizedName in sanitizedNames)
            {
                string queryUrl = "https://www.fimfiction.net/api/v2/stories" +
                                  "?include=characters,tags,author" +
                                  "&sort=-relevance" +
                                  "&page[size]=1" +
                                  "&fields[user]=name" +
                                  "&fields[story]=title,description,date_published,total_num_views,num_words,rating,completion_status,tags,content_rating,author" +
                                  "&fields[story_tag]=name,type" +
                                  $"&query={sanitizedName}";
                string res =
                    BotClient.GetStringAsync(queryUrl)
                    .Result;
                Story.Rootobject searchResult = JsonConvert.DeserializeObject <Story.Rootobject>(res);
                resultCollection.Add(searchResult);
            }
            return(resultCollection);
        }