diff --git a/BarbezDotEu.Twitter/BarbezDotEu.Twitter.csproj b/BarbezDotEu.Twitter/BarbezDotEu.Twitter.csproj
index 009525c..a856dae 100644
--- a/BarbezDotEu.Twitter/BarbezDotEu.Twitter.csproj
+++ b/BarbezDotEu.Twitter/BarbezDotEu.Twitter.csproj
@@ -1,13 +1,13 @@
- net5.0
+ net6.0
Hannes Barbez
Hannes Barbez
BarbezDotEu.Twitter
BarbezDotEu.Twitter
BarbezDotEu.Twitter
- ©2021 Hannes Barbez
- 3.0.1
+ ©2022 Hannes Barbez
+ 4.0.0
An unofficial, modern, very much work-in-progress client for Twitter APIs.
basic;polite;Twitter;integration;third-party integration;provider;barbez
true
@@ -22,6 +22,6 @@
-
+
diff --git a/BarbezDotEu.Twitter/TwitterConfiguration.cs b/BarbezDotEu.Twitter/TwitterConfiguration.cs
index b93d99d..5a8d13f 100644
--- a/BarbezDotEu.Twitter/TwitterConfiguration.cs
+++ b/BarbezDotEu.Twitter/TwitterConfiguration.cs
@@ -8,35 +8,10 @@ namespace BarbezDotEu.Twitter
///
public class TwitterConfiguration
{
- ///
- /// A constant representing this package's default implementation for the fully-qualified URL to use to search for topics in recent tweets. However, omits the actual search query and query fields.
- ///
- public const string DEFAULTSEARCHRECENTTWEETSURL = "https://api.twitter.com/2/tweets/search/recent?query=";
-
- ///
- /// A constant representing this package's default implementation for the query fields to query the with.
- ///
- public const string DEFAULTSEARCHRECENTTWEETSFIELDS = "&tweet.fields=attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,public_metrics,referenced_tweets,reply_settings,source,text,withheld&max_results=";
-
- ///
- /// A constant representing this package's default implementation of the OAuth 2 Token URL for authentication.
- ///
- public const string DEFAULTOAUTH2TOKENURL = "https://api.twitter.com/oauth2/token";
-
- ///
- /// A constant representing this package's default assumption of the maximum number of calls allowed per minute.
- ///
- public const long DEFAULTMAXCALLSPERMINUTE = 2;
-
- ///
- /// A constant representing this package's default assumption of the maximum number of results to return per request.
- ///
- public const long DEFAULTRESULTSPERREQUEST = 15;
-
///
/// Gets the maximum number of calls allowed per minute (see the Twitter developer website for current rates).
///
- public string MaxCallsPerMinute { get; }
+ public long MaxCallsPerMinute { get; }
///
/// Gets the maximum number of results to return per request.
@@ -61,114 +36,29 @@ public class TwitterConfiguration
///
/// Gets the consumer key for authentication. (Get yours from the Twitter.com developer website)
///
- public string ConsumerKey { get; }
+ internal string ConsumerKey { get; }
///
/// Gets the consumer secret for authentication. (Get yours from the Twitter.com developer website)
///
- public string ConsumerSecret { get; }
+ internal string ConsumerSecret { get; }
///
/// Constructs a new using given parameters.
///
/// The maximum number of calls allowed per minute (see the Twitter.com developer website for current rates).
/// The maximum number of results to return per request.
- /// The fully-qualified URL to use to search for topics in recent tweets. However, omits the actual search query and query fields.
- /// The query fields to query the with.
- /// The OAuth 2 Token URL for authentication.
/// The consumer key for authentication. (Get yours from the Twitter.com developer website)
/// The secret for authentication. (Get yours from the Twitter.com developer website)
- public TwitterConfiguration(string maxCallsPerMinute, long resultsPerRequest, string searchRecentTweetsUrl, string searchRecentTweetsFields, string oAuth2TokenUrl, string consumerKey, string consumerSecret)
+ public TwitterConfiguration(long maxCallsPerMinute, long resultsPerRequest, string consumerKey, string consumerSecret)
{
this.MaxCallsPerMinute = maxCallsPerMinute;
this.ResultsPerRequest = resultsPerRequest;
- this.SearchRecentTweetsUrl = searchRecentTweetsUrl;
- this.SearchRecentTweetsFields = searchRecentTweetsFields;
- this.OAuth2TokenUrl = oAuth2TokenUrl;
- this.ConsumerKey = consumerKey;
- this.ConsumerSecret = consumerSecret;
- }
-
- ///
- /// Constructs a new using given parameters.
- ///
- /// The maximum number of calls allowed per minute (see the Twitter.com developer website for current rates).
- /// The maximum number of results to return per request.
- /// The fully-qualified URL to use to search for topics in recent tweets. However, omits the actual search query and query fields.
- /// The query fields to query the with.
- /// The OAuth 2 Token URL for authentication.
- /// The consumer key for authentication. (Get yours from the Twitter.com developer website)
- /// The secret for authentication. (Get yours from the Twitter.com developer website)
- public TwitterConfiguration(string maxCallsPerMinute, string resultsPerRequest, string searchRecentTweetsUrl, string searchRecentTweetsFields, string oAuth2TokenUrl, string consumerKey, string consumerSecret)
- {
- this.MaxCallsPerMinute = maxCallsPerMinute;
- this.ResultsPerRequest = GetResultsPerRequest(resultsPerRequest);
- this.SearchRecentTweetsUrl = searchRecentTweetsUrl;
- this.SearchRecentTweetsFields = searchRecentTweetsFields;
- this.OAuth2TokenUrl = oAuth2TokenUrl;
+ this.SearchRecentTweetsUrl = "https://api.twitter.com/2/tweets/search/recent?query=";
+ this.SearchRecentTweetsFields = "&tweet.fields=attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,public_metrics,referenced_tweets,reply_settings,source,text,withheld&max_results=";
+ this.OAuth2TokenUrl = "https://api.twitter.com/oauth2/token";
this.ConsumerKey = consumerKey;
this.ConsumerSecret = consumerSecret;
}
-
- ///
- /// Constructs a new using given parameters.
- ///
- /// The maximum number of calls allowed per minute (see the Twitter.com developer website for current rates).
- /// The maximum number of results to return per request.
- /// The fully-qualified URL to use to search for topics in recent tweets. However, omits the actual search query and query fields.
- /// The query fields to query the with.
- /// The OAuth 2 Token URL for authentication.
- /// The consumer key for authentication. (Get yours from the Twitter.com developer website)
- /// The secret for authentication. (Get yours from the Twitter.com developer website)
- public TwitterConfiguration(long maxCallsPerMinute, long resultsPerRequest, string searchRecentTweetsUrl, string searchRecentTweetsFields, string oAuth2TokenUrl, string consumerKey, string consumerSecret)
- : this(maxCallsPerMinute.ToString(), resultsPerRequest, searchRecentTweetsUrl, searchRecentTweetsFields, oAuth2TokenUrl, consumerKey, consumerSecret)
- {
- }
-
- ///
- /// Constructs a new using given parameters and using some default settings.
- ///
- /// The consumer key for authentication. (Get yours from the Twitter.com developer website)
- /// The secret for authentication. (Get yours from the Twitter.com developer website)
- public TwitterConfiguration(string consumerKey, string consumerSecret)
- : this(DEFAULTMAXCALLSPERMINUTE.ToString(), DEFAULTRESULTSPERREQUEST, DEFAULTSEARCHRECENTTWEETSURL, DEFAULTSEARCHRECENTTWEETSFIELDS, DEFAULTOAUTH2TOKENURL, consumerKey, consumerSecret)
- {
- }
-
- ///
- /// Constructs a new using given parameters and using some default settings.
- ///
- /// The maximum number of calls allowed per minute (see the Twitter.com developer website for current rates).
- /// The consumer key for authentication. (Get yours from the Twitter.com developer website)
- /// The secret for authentication. (Get yours from the Twitter.com developer website)
- public TwitterConfiguration(long maxCallsPerMinute, string consumerKey, string consumerSecret)
- : this(maxCallsPerMinute.ToString(), DEFAULTRESULTSPERREQUEST, DEFAULTSEARCHRECENTTWEETSURL, DEFAULTSEARCHRECENTTWEETSFIELDS, DEFAULTOAUTH2TOKENURL, consumerKey, consumerSecret)
- {
- }
-
- ///
- /// Constructs a new using given parameters and using some default settings.
- ///
- /// The maximum number of calls allowed per minute (see the Twitter.com developer website for current rates).
- /// The consumer key for authentication. (Get yours from the Twitter.com developer website)
- /// The secret for authentication. (Get yours from the Twitter.com developer website)
- public TwitterConfiguration(string maxCallsPerMinute, string consumerKey, string consumerSecret)
- : this(maxCallsPerMinute, DEFAULTRESULTSPERREQUEST, DEFAULTSEARCHRECENTTWEETSURL, DEFAULTSEARCHRECENTTWEETSFIELDS, DEFAULTOAUTH2TOKENURL, consumerKey, consumerSecret)
- {
- }
-
- ///
- /// From a given string, parses the max. number of results to return per request. If not possible to parse, returns .
- ///
- /// The string representation of the value of the maximum number of results per request.
- /// The maximum number of results to return per request.
- private static long GetResultsPerRequest(string resultsPerRequest)
- {
- var success = long.TryParse(resultsPerRequest, out long numberOfResultsPerRequest);
- if (success)
- return numberOfResultsPerRequest;
-
- return DEFAULTRESULTSPERREQUEST;
- }
}
}