Exemplo n.º 1
0
        public static QuoteFmUser createFromApi(User user, bool getFollowers = false, bool getFollowings = false, bool getRecommendations = false)
        {
            if (user == null)
            {
                return(null);
            }
            QuoteFmUser qfmUser = new QuoteFmUser();

            qfmUser.username       = user.username;
            qfmUser.Fullname       = user.fullname;
            qfmUser.Id             = user.id;
            qfmUser.Avatar         = user.avatar;
            qfmUser.Created        = user.created;
            qfmUser.Bio            = user.bio;
            qfmUser.FollowingCount = user.followingCount;
            qfmUser.FollowerCount  = user.followerCount;
            qfmUser.Location       = user.location;
            qfmUser.Twitter        = user.twitter;
            qfmUser.Url            = user.url;

            if (getFollowings)
            {
                qfmUser.getFollowings();
            }

            return(qfmUser);
        }
Exemplo n.º 2
0
        public static QuoteFmItem createFromApi(Recommendation recommendation)
        {
            if (recommendation == null)
            {
                return(null);
            }
            QuoteFmItem item = new QuoteFmItem();

            // Created At is missing!
            if (recommendation.article != null)
            {
                item.CreatedAt = recommendation.article.created.Value;
            }
            else
            {
                item.CreatedAt = DateTime.Now;
            }

            item.AuthorName  = recommendation.user.username;
            item.Id          = recommendation.id;
            item.Text        = recommendation.quote;
            item.QuoteType   = QuoteTypes.Recommendation;
            item.ClientName  = recommendation.domain.name;
            item.ArticleLink = recommendation.article.url;
            item.Author      = QuoteFmUser.createFromApi(recommendation.user);

            return(item);
        }
Exemplo n.º 3
0
        public void  getFollowings()
        {
            ListOfUsers listOfFollwoings = QuoteSharp.API.getUsersListOfFollowings(this.username);

            Followings.Clear();
            foreach (User following in listOfFollwoings.entities)
            {
                Followings.Add(QuoteFmUser.createFromApi(following));
            }
        }
Exemplo n.º 4
0
        public bool verifyCredentials()
        {
            User user = QuoteSharp.API.getUser(username);

            if (user != null)
            {
                this.User        = QuoteFmUser.createFromApi(user, getFollowings: true);
                LoginSuccessfull = true;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        public static QuoteFmItem createFromApi(Article article)
        {
            if (article == null)
            {
                return(null);
            }
            if (article.topquote == null)
            {
                return(null);
            }
            QuoteFmItem item = new QuoteFmItem();

            item.CreatedAt = article.created.Value;

            item.Id          = article.id;
            item.AuthorName  = article.topquote.user.fullname;
            item.Text        = article.topquote.quote;
            item.QuoteType   = QuoteTypes.Recommendation;
            item.ClientName  = article.topquote.domain.name;
            item.ArticleLink = article.url;
            item.Author      = QuoteFmUser.createFromApi(article.topquote.user);

            return(item);
        }