Skip to content

Commit c10e853

Browse files
authored
Merge pull request #824 from Rishikant181/dev
6.2.0
2 parents adacaea + 2bdbc19 commit c10e853

18 files changed

Lines changed: 337 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Rettiwt-API can be used with or without logging in to Twitter. As such, the two
7272
- User Subscriptions
7373
- User Timeline
7474
- User Unfollow
75+
- User Profile Update
7576

7677
By default, Rettiwt-API uses 'guest' authentication. If however, access to the full set of resources is required, 'user' authentication can be used. This is done by using the cookies associated with your Twitter/X account, and encoding them into an `API_KEY` for convenience. The said `API_KEY` can be obtained by using a browser extension, as follows:
7778

@@ -498,6 +499,7 @@ So far, the following operations are supported:
498499
- [Getting the replies timeline of the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#replies)
499500
- [Getting the tweet timeline of the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#timeline)
500501
- [Unfollowing a given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#unfollow)
502+
- [Updating the profile of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#updateProfile)
501503

502504
## CLI Usage
503505

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rettiwt-api",
3-
"version": "6.1.7",
3+
"version": "6.2.0",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"description": "An API for fetching data from TwitterAPI, without any rate limits!",

src/collections/Extractors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { IUserLikesResponse } from '../types/raw/user/Likes';
4646
import { IUserListsResponse } from '../types/raw/user/Lists';
4747
import { IUserMediaResponse } from '../types/raw/user/Media';
4848
import { IUserNotificationsResponse } from '../types/raw/user/Notifications';
49+
import { IUserProfileUpdateResponse } from '../types/raw/user/ProfileUpdate';
4950
import { IUserRecommendedResponse } from '../types/raw/user/Recommended';
5051
import { IUserSubscriptionsResponse } from '../types/raw/user/Subscriptions';
5152
import { IUserTweetsResponse } from '../types/raw/user/Tweets';
@@ -139,6 +140,7 @@ export const Extractors = {
139140
USER_TIMELINE_AND_REPLIES: (response: IUserTweetsAndRepliesResponse): CursoredData<Tweet> =>
140141
new CursoredData<Tweet>(response, BaseType.TWEET),
141142
USER_UNFOLLOW: (response: IUserUnfollowResponse): boolean => (response?.id ? true : false),
143+
USER_PROFILE_UPDATE: (response: IUserProfileUpdateResponse): boolean => (response?.name ? true : false),
142144

143145
/* eslint-enable @typescript-eslint/naming-convention */
144146
};

src/collections/Groups.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ export const PostResourcesGroup = [
7474
ResourceType.TWEET_UNSCHEDULE,
7575
ResourceType.USER_FOLLOW,
7676
ResourceType.USER_UNFOLLOW,
77+
ResourceType.USER_PROFILE_UPDATE,
7778
];

src/collections/Requests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const Requests: { [key in keyof typeof ResourceType]: (args: IFetchArgs |
8080
USER_TIMELINE: (args: IFetchArgs) => UserRequests.tweets(args.id!, args.count, args.cursor),
8181
USER_TIMELINE_AND_REPLIES: (args: IFetchArgs) => UserRequests.tweetsAndReplies(args.id!, args.count, args.cursor),
8282
USER_UNFOLLOW: (args: IPostArgs) => UserRequests.unfollow(args.id!),
83+
USER_PROFILE_UPDATE: (args: IPostArgs) => UserRequests.updateProfile(args.profileOptions!),
8384

8485
/* eslint-enable @typescript-eslint/naming-convention */
8586
};

src/commands/User.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,27 @@ function createUserCommand(rettiwt: Rettiwt): Command {
274274
}
275275
});
276276

277+
// Update Profile
278+
user.command('update-profile')
279+
.description('Update your profile information')
280+
.option('-n, --name <string>', 'Display name (max 50 characters)')
281+
.option('-u, --url <string>', 'Profile URL')
282+
.option('-l, --location <string>', 'Location (max 30 characters)')
283+
.option('-d, --description <string>', 'Description/bio (max 160 characters)')
284+
.action(async (options?: UserProfileUpdateOptions) => {
285+
try {
286+
const result = await rettiwt.user.updateProfile({
287+
name: options?.name,
288+
url: options?.url,
289+
location: options?.location,
290+
description: options?.description,
291+
});
292+
output(result);
293+
} catch (error) {
294+
output(error);
295+
}
296+
});
297+
277298
return user;
278299
}
279300

@@ -288,4 +309,14 @@ type UserAnalyticsOptions = {
288309
verifiedFollowers?: boolean;
289310
};
290311

312+
/**
313+
* The options for updating user profile.
314+
*/
315+
type UserProfileUpdateOptions = {
316+
name?: string;
317+
url?: string;
318+
location?: string;
319+
description?: string;
320+
};
321+
291322
export default createUserCommand;

src/enums/Resource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ export enum ResourceType {
6262
USER_TIMELINE = 'USER_TIMELINE',
6363
USER_TIMELINE_AND_REPLIES = 'USER_TIMELINE_AND_REPLIES',
6464
USER_UNFOLLOW = 'USER_UNFOLLOW',
65+
USER_PROFILE_UPDATE = 'USER_PROFILE_UPDATE',
6566
}

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export * from './enums/Tweet';
1818
// MODELS
1919
export * from './models/args/FetchArgs';
2020
export * from './models/args/PostArgs';
21+
export * from './models/args/ProfileArgs';
2122
export * from './models/data/Conversation';
2223
export * from './models/data/CursoredData';
2324
export * from './models/data/DirectMessage';
@@ -45,6 +46,7 @@ export * from './services/public/UserService';
4546
// TYPES
4647
export * from './types/args/FetchArgs';
4748
export * from './types/args/PostArgs';
49+
export * from './types/args/ProfileArgs';
4850
export * from './types/data/Conversation';
4951
export * from './types/data/CursoredData';
5052
export * from './types/data/DirectMessage';
@@ -111,6 +113,7 @@ export { IUserSubscriptionsResponse as IRawUserSubscriptionsResponse } from './t
111113
export { IUserTweetsResponse as IRawUserTweetsResponse } from './types/raw/user/Tweets';
112114
export { IUserTweetsAndRepliesResponse as IRawUserTweetsAndRepliesResponse } from './types/raw/user/TweetsAndReplies';
113115
export { IUserUnfollowResponse as IRawUserUnfollowResponse } from './types/raw/user/Unfollow';
116+
export { IUserProfileUpdateResponse as IRawUserProfileUpdateResponse } from './types/raw/user/ProfileUpdate';
114117
export * from './types/ErrorHandler';
115118
export * from './types/RettiwtConfig';
116119
export { IConversationTimelineResponse as IRawConversationTimelineResponse } from './types/raw/dm/Conversation';

src/models/args/PostArgs.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { INewTweet, INewTweetMedia, IPostArgs, IUploadArgs } from '../../types/args/PostArgs';
22

3+
import { ProfileUpdateOptions } from './ProfileArgs';
4+
35
/**
46
* Options specifying the data that is to be posted.
57
*
68
* @public
79
*/
810
export class PostArgs implements IPostArgs {
11+
public conversationId?: string;
912
public id?: string;
13+
public profileOptions?: ProfileUpdateOptions;
1014
public tweet?: NewTweet;
1115
public upload?: UploadArgs;
1216
public userId?: string;
@@ -20,6 +24,8 @@ export class PostArgs implements IPostArgs {
2024
this.tweet = args.tweet ? new NewTweet(args.tweet) : undefined;
2125
this.upload = args.upload ? new UploadArgs(args.upload) : undefined;
2226
this.userId = args.userId;
27+
this.conversationId = args.conversationId;
28+
this.profileOptions = args.profileOptions ? new ProfileUpdateOptions(args.profileOptions) : undefined;
2329
}
2430
}
2531

0 commit comments

Comments
 (0)