Skip to content

Commit

Permalink
fix: renamed method
Browse files Browse the repository at this point in the history
  • Loading branch information
myConsciousness committed Oct 27, 2022
1 parent d7b6fce commit 627b361
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Note

## v4.2.4

- Renamed from `createThread` to `createReply`.

## v4.2.3

- Fixed dependency structure.
Expand Down
24 changes: 12 additions & 12 deletions lib/src/service/tweets/tweets_service_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ extension TweetServiceExtension on TweetsService {
}) async =>
await createThreads(tweets: tweets);

/// This is a convenience method for creating a thread tied to a parent tweet.
/// This is a convenience method for creating a reply.
///
/// [parentTweetId] should be the ID of the tweet for which you want to
/// create a thread. If [parentTweetId] is an empty string,
/// [tweetId] should be the ID of the tweet for which you want to
/// create a reply. If [tweetId] is an empty string,
/// an [ArgumentError] will always occur.
///
/// ## Parameters
///
/// - [parentTweetId]: the ID of the tweet for which you want to create
/// a thread
/// - [tweetId]: The ID of the tweet for which you want to create
/// a reply.
///
/// - [text]: Text of the Tweet being created.
/// This field is required if media.media_ids is not present.
Expand Down Expand Up @@ -85,8 +85,8 @@ extension TweetServiceExtension on TweetsService {
///
/// - **User rate limit (OAuth 2.0 user Access Token)**:
/// 200 requests per 15-minute window per each authenticated user
Future<TwitterResponse<TweetData, void>> createThread({
required String parentTweetId,
Future<TwitterResponse<TweetData, void>> createReply({
required String tweetId,
required String text,
String? quoteTweetId,
bool? forSuperFollowersOnly,
Expand All @@ -97,9 +97,9 @@ extension TweetServiceExtension on TweetsService {
TweetPollParam? poll,
List<String>? excludeReplyUserIds,
}) async {
if (parentTweetId.isEmpty) {
if (tweetId.isEmpty) {
throw ArgumentError(
'The parent Tweet ID is required to create a thread.',
'The Tweet ID is required to create a reply.',
);
}

Expand All @@ -113,7 +113,7 @@ extension TweetServiceExtension on TweetsService {
geo: geo,
poll: poll,
reply: TweetReplyParam(
inReplyToTweetId: parentTweetId,
inReplyToTweetId: tweetId,
excludeReplyUserIds: excludeReplyUserIds,
),
);
Expand Down Expand Up @@ -189,8 +189,8 @@ extension TweetServiceExtension on TweetsService {

String parentTweetId = rootTweet.data.id;
for (final tweet in tweets.sublist(1)) {
final childTweet = await createThread(
parentTweetId: parentTweetId,
final childTweet = await createReply(
tweetId: parentTweetId,
text: tweet.text,
quoteTweetId: tweet.quoteTweetId,
forSuperFollowersOnly: tweet.forSuperFollowersOnly,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: twitter_api_v2
description: The lightweight and powerful wrapper library for Twitter API v2.0 written in Dart language. It works cross-platform.
version: 4.2.3
version: 4.2.4
repository: https://github.com/twitter-dart/twitter-api-v2
issue_tracker: https://github.com/twitter-dart/twitter-api-v2/issues

Expand Down
11 changes: 5 additions & 6 deletions test/src/service/tweets/tweets_service_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ void main() {
),
);

final response = await tweetsService.createThread(
parentTweetId: '1234',
final response = await tweetsService.createReply(
tweetId: '1234',
text: 'test',
);

Expand All @@ -44,17 +44,16 @@ void main() {
);

expect(
() async => await tweetsService.createThread(
parentTweetId: '',
() async => await tweetsService.createReply(
tweetId: '',
text: '',
),
throwsA(
allOf(
isA<ArgumentError>(),
predicate(
(dynamic e) =>
e.message ==
'The parent Tweet ID is required to create a thread.',
e.message == 'The Tweet ID is required to create a reply.',
),
),
),
Expand Down

0 comments on commit 627b361

Please sign in to comment.