Skip to content

Commit

Permalink
Merge #503
Browse files Browse the repository at this point in the history
503: fix: renamed method r=myConsciousness a=myConsciousness

# 1. Description

<!-- Provide a description of what this PR is doing.
If you're modifying existing behavior, describe the existing behavior, how this PR is changing it,
and what motivated the change. If this is a breaking change, specify explicitly which APIs have been
changed. -->

## 1.1. Checklist

<!-- Before you create this PR confirm that it meets all requirements listed below by checking the
relevant checkboxes (`[x]`). This will ensure a smooth and quick review process. -->

- [x] The title of my PR starts with a [Conventional Commit] prefix (`fix:`, `feat:`, `docs:` etc).
- [x] I have read the [Contributor Guide] and followed the process outlined for submitting PRs.
- [x] I have updated/added tests for ALL new/updated/fixed functionality.
- [x] I have updated/added relevant documentation in `docs` and added dartdoc comments with `///`.
- [x] I have updated/added relevant examples in `examples`.

## 1.2. Breaking Change

<!-- Does your PR require users to manually update their apps to accommodate your change?

If the PR is a breaking change this should be indicated with suffix "!"  (for example, `feat!:`, `fix!:`). See [Conventional Commit] for details.
-->

- [x] Yes, this is a breaking change.
- [ ] No, this is _not_ a breaking change.

## 1.3. Related Issues

<!-- Provide a list of issues related to this PR from the [issue database].
Indicate which of these issues are resolved or fixed by this PR, i.e. Fixes #xxxx* !-->

<!-- Links -->

[issue database]: https://github.com/twitter-dart/twitter-api-v2/issues
[contributor guide]: https://github.com/twitter-dart/twitter-api-v2/blob/main/CONTRIBUTING.md
[style guide]: https://github.com/twitter-dart/twitter-api-v2/blob/main/STYLEGUIDE.md
[conventional commit]: https://conventionalcommits.org


Co-authored-by: myConsciousness <[email protected]>
  • Loading branch information
bors[bot] and myConsciousness authored Oct 27, 2022
2 parents d7b6fce + 627b361 commit 4b796fb
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 4b796fb

Please sign in to comment.