Ejemplo n.º 1
0
        public User(dynamic input)
        {
            try
            {
                OriginalObject = input;

                if (Helpers.HasProperty(input, "username"))
                {
                    Id            = input.id;
                    UserName      = input.username;
                    CreatedAt     = input.created_at;
                    PinnedTweetId = input.pinned_tweet_id;
                    PublicMetrics = new Metrics.Public(input.public_metrics);
                }
                else if (Helpers.HasProperty(input, "screen_name"))
                {
                    Id        = input.id.ToString();
                    UserName  = input.screen_name;
                    CreatedAt = Helpers.ConvertV1Date(input.created_at);
                }

                Name            = input.name;
                Description     = input.description;
                Entities        = BaseEntity.GetEntities(input.entities);
                Location        = input.location;
                ProfileImageUrl = new Uri(input.profile_image_url);
                Protected       = input.@protected;
                Url             = new Uri(input.url);
                Verified        = input.verified;

                if (Helpers.HasProperty(input, "withheld"))
                {
                    Withheld = new WithheldContent(input.withheld);
                }
            }
            catch
            {
                // any missing properties that are not on the input object
                // and not caught with Helpers.HasProperty if statement,
                // do not fail(for now)
            }
        }
Ejemplo n.º 2
0
        public Tweet(dynamic input)
        {
            try
            {
                OriginalObject = input;

                Id                = input.id;
                Text              = input.text;
                AuthorId          = input.author_id;
                ConversationId    = input.conversation_id;
                CreatedAt         = input.created_at;
                Entities          = BaseEntity.GetEntities(input.entities);
                InReplyToUserId   = input.in_reply_to_user_id;
                Language          = input.lang;
                PossiblySensitive = input.possibly_sensitive;
                PublicMetrics     = new Metrics.Public(input.public_metrics);
                Source            = input.source;

                if (Helpers.HasProperty(input, "attachments"))
                {
                    Attachments = new Attachments(input.attachments);
                }

                if (Helpers.HasProperty(input, "geo"))
                {
                    Geo            = input.geo;
                    OriginalObject = input;
                }

                if (Helpers.HasProperty(input, "reply_settings"))
                {
                    ReplySettings = Helpers.ToTitleCase(input.reply_settings);
                }

                if (Helpers.HasProperty(input, "withheld"))
                {
                    Withheld = new WithheldContent(input.withheld);
                }

                if (Helpers.HasProperty(input, "referenced_tweets"))
                {
                    List <ReferencedTweet> referencedTweets = new List <ReferencedTweet>();
                    foreach (dynamic refTweet in input.referenced_tweets)
                    {
                        referencedTweets.Add(new ReferencedTweet(refTweet));
                    }
                    ReferencedTweets = referencedTweets;
                }

                if (Helpers.HasProperty(input, "context_annotations"))
                {
                    List <Context.ContextAnnotation> contextAnnotations = new List <Context.ContextAnnotation>();
                }

                if (Helpers.HasProperty(input, "non_public_metrics"))
                {
                    NonPublicMetrics = new NonPublic(input.non_public_metrics);
                }
                if (Helpers.HasProperty(input, "organic_metrics"))
                {
                    OrganicMetrics = new Organic(input.organic_metrics);
                }
                if (Helpers.HasProperty(input, "promoted_metrics"))
                {
                    PromotedMetrics = new Promoted(input.promoted_metrics);
                }
            }
            catch
            {
                // any missing properties that are not on the input object
                // and not caught with Helpers.HasProperty if statement,
                // do not fail (for now)
            }
        }