示例#1
1
        public bool PublishTweet(ITweet tweet, IPublishTweetOptionalParameters optionalParameters = null)
        {
            if (tweet == null)
            {
                throw new ArgumentException("Tweet cannot be null!");
            }

            var parameters = new PublishTweetParameters(tweet.Text, optionalParameters);
            var tweetDTO = InternalPublishTweet(parameters);

            UpdateTweetIfTweetSuccessfullyBeenPublished(tweet, tweetDTO);

            return tweet.IsTweetPublished;
        }
示例#2
0
        public ITweet PublishTweet(string text, IPublishTweetOptionalParameters optionalParameters = null)
        {
            var parameters = new PublishTweetParameters(text, optionalParameters);
            var tweetDTO   = InternalPublishTweet(parameters);

            return(_tweetFactory.GenerateTweetFromDTO(tweetDTO));
        }
示例#3
0
        public ITweet PublishTweet(string text, IPublishTweetOptionalParameters optionalParameters = null)
        {
            var parameters = new PublishTweetParameters(text, optionalParameters);
            var tweetDTO = InternalPublishTweet(parameters);

            return _tweetFactory.GenerateTweetFromDTO(tweetDTO);
        }
示例#4
0
        public static int EstimateTweetLength(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
        {
            var textLength = text == null ? 0 : StringExtension.EstimateTweetLength(text);

            if (text == null || publishTweetOptionalParameters == null)
            {
                return(textLength);
            }

            if (publishTweetOptionalParameters.QuotedTweet != null)
            {
                var newText = text.TrimEnd();

                textLength  = StringExtension.EstimateTweetLength(newText);
                textLength += 1; // for the space that needs to be added before the link to quoted tweet.
                textLength += TweetinviConsts.MEDIA_CONTENT_SIZE;
            }

            if (!publishTweetOptionalParameters.Medias.IsNullOrEmpty() ||
                !publishTweetOptionalParameters.MediaIds.IsNullOrEmpty() ||
                !publishTweetOptionalParameters.MediaBinaries.IsNullOrEmpty())
            {
                textLength += TweetinviConsts.MEDIA_CONTENT_SIZE;
            }

            return(textLength);
        }
示例#5
0
        public PublishTweetParameters(string text, IPublishTweetOptionalParameters optionalParameters = null)
        {
            Text = text;

            if (optionalParameters == null)
            {
                Parameters = new PublishTweetOptionalParameters();
            }
            else
            {
                Parameters = optionalParameters;
            }
        }
示例#6
0
        public PublishTweetParameters(string text, IPublishTweetOptionalParameters optionalParameters = null)
        {
            Text = text;

            if (optionalParameters == null)
            {
                Parameters = new PublishTweetOptionalParameters();
            }
            else
            {
                Parameters = optionalParameters;
            }
        }
示例#7
0
        public bool PublishTweet(ITweet tweet, IPublishTweetOptionalParameters optionalParameters = null)
        {
            if (tweet == null)
            {
                throw new ArgumentException("Tweet cannot be null!");
            }

            var parameters = new PublishTweetParameters(tweet.Text, optionalParameters);
            var tweetDTO   = InternalPublishTweet(parameters);

            UpdateTweetIfTweetSuccessfullyBeenPublished(tweet, tweetDTO);

            return(tweet.IsTweetPublished);
        }
        public string PublishTweet(string text, IPublishTweetOptionalParameters optionalParameters = null)
        {
            // The exceptions have to be raised before the QueryGenerator as 
            // We do not want to wait for the media to be uploaded to throw the
            // Exception. And The logic of uploading the media should live in
            // the TweetController

            var publishParameter = new PublishTweetParameters(text, optionalParameters);

            _tweetQueryValidator.ThrowIfTweetCannotBePublished(publishParameter);
            _tweetController.UploadMedias(publishParameter);

            var query = _tweetQueryGenerator.GetPublishTweetQuery(publishParameter);
            return _twitterAccessor.ExecuteJsonPOSTQuery(query);
        }
        public string PublishTweet(string text, IPublishTweetOptionalParameters optionalParameters = null)
        {
            // The exceptions have to be raised before the QueryGenerator as
            // We do not want to wait for the media to be uploaded to throw the
            // Exception. And The logic of uploading the media should live in
            // the TweetController

            var publishParameter = new PublishTweetParameters(text, optionalParameters);

            _tweetQueryValidator.ThrowIfTweetCannotBePublished(publishParameter);
            _tweetController.UploadMedias(publishParameter);

            var query = _tweetQueryGenerator.GetPublishTweetQuery(publishParameter);

            return(_twitterAccessor.ExecuteJsonPOSTQuery(query));
        }
示例#10
0
        public int Length(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
        {
            var textLength = text == null ? 0 : text.TweetLength();

            if (publishTweetOptionalParameters == null)
            {
                return(textLength);
            }

            if (publishTweetOptionalParameters.QuotedTweet != null)
            {
                textLength += TweetinviConsts.MEDIA_CONTENT_SIZE;
            }

            if (!publishTweetOptionalParameters.Medias.IsNullOrEmpty() ||
                !publishTweetOptionalParameters.MediaIds.IsNullOrEmpty() ||
                !publishTweetOptionalParameters.MediaBinaries.IsNullOrEmpty())
            {
                textLength += TweetinviConsts.MEDIA_CONTENT_SIZE;
            }

            return(textLength);
        }
示例#11
0
 // Tweet
 public ITweet PublishTweet(string text, IPublishTweetOptionalParameters parameters)
 {
     return(ExecuteAuthenticatedUserOperation(() => _tweetController.PublishTweet(text, parameters)));
 }
示例#12
0
文件: Tweet.cs 项目: rudiv/tweetinvi
 public static bool CanBePublished(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return TweetController.CanBePublished(text, publishTweetOptionalParameters);
 }
示例#13
0
文件: Tweet.cs 项目: rudiv/tweetinvi
 public static int Length(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return TweetController.Length(text, publishTweetOptionalParameters);
 }
示例#14
0
文件: Tweet.cs 项目: rudiv/tweetinvi
 public static ITweet PublishTweet(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return TweetController.PublishTweet(text, publishTweetOptionalParameters);
 }
示例#15
0
 /// <summary>
 /// Publish a tweet
 /// </summary>
 public static ITweet PublishTweet(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return(TweetController.PublishTweet(text, publishTweetOptionalParameters));
 }
示例#16
0
 // Tweet Controller
 public static async Task<ITweet> PublishTweet(string text, IPublishTweetOptionalParameters parameters = null)
 {
     return await Sync.ExecuteTaskAsync(() => Tweet.PublishTweet(text, parameters));
 }
示例#17
0
 public bool CanBePublished(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return(true);
     //return TweetinviConsts.MAX_TWEET_SIZE >= EstimateTweetLength(text, publishTweetOptionalParameters);
 }
 public PublishTweetParameters(string text, IPublishTweetOptionalParameters optionalParameters = null)
 {
     Text = text;
     Parameters = optionalParameters ?? new PublishTweetOptionalParameters();
 }
示例#19
0
 public PublishTweetParameters(string text, IPublishTweetOptionalParameters optionalParameters = null)
 {
     Text       = text;
     Parameters = optionalParameters ?? new PublishTweetOptionalParameters();
 }
示例#20
0
 public static IPublishTweetParameters CreatePublishTweetParameters(string text, IPublishTweetOptionalParameters optionalParameters = null)
 {
     return new PublishTweetParameters(text, optionalParameters);
 }
示例#21
0
 /// <summary>
 /// Get the length of a tweet as calculated by Twitter
 /// </summary>
 public static int Length(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return(TweetController.Length(text, publishTweetOptionalParameters));
 }
示例#22
0
 public bool CanBePublished(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return TweetinviConsts.MAX_TWEET_SIZE <= Length(text, publishTweetOptionalParameters);
 }
示例#23
0
 /// <summary>
 /// Verify that a tweet can be published
 /// </summary>
 public static bool CanBePublished(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return(TweetController.CanBePublished(text, publishTweetOptionalParameters));
 }
示例#24
0
 public bool CanBePublished(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
 {
     return(TweetinviConsts.MAX_TWEET_SIZE >= Length(text, publishTweetOptionalParameters));
 }
示例#25
0
 public static IPublishTweetParameters CreatePublishTweetParameters(string text, IPublishTweetOptionalParameters optionalParameters = null)
 {
     return(new PublishTweetParameters(text, optionalParameters));
 }
示例#26
0
 // Publish Tweet
 public static string PublishTweet(string text, IPublishTweetOptionalParameters parameters = null)
 {
     return TweetJsonController.PublishTweet(text, parameters);
 }
示例#27
0
 // Tweet Controller
 public static async Task <ITweet> PublishTweet(string text, IPublishTweetOptionalParameters parameters = null)
 {
     return(await Sync.ExecuteTaskAsync(() => Tweet.PublishTweet(text, parameters)));
 }
示例#28
0
        public int Length(string text, IPublishTweetOptionalParameters publishTweetOptionalParameters = null)
        {
            var textLength = text == null ? 0 : text.TweetLength();

            if (publishTweetOptionalParameters == null)
            {
                return textLength;
            }

            if (publishTweetOptionalParameters.QuotedTweet != null)
            {
                textLength += TweetinviConsts.MEDIA_CONTENT_SIZE;
            }

            if (!publishTweetOptionalParameters.Medias.IsNullOrEmpty() ||
                !publishTweetOptionalParameters.MediaIds.IsNullOrEmpty() ||
                !publishTweetOptionalParameters.MediaBinaries.IsNullOrEmpty())
            {
                textLength += TweetinviConsts.MEDIA_CONTENT_SIZE;
            }

            return textLength;
        }