Skip to content

Commit

Permalink
Merge pull request #125 from Rishikant181/dev
Browse files Browse the repository at this point in the history
v3.4.0-alpha.2
  • Loading branch information
Rishikant181 authored Feb 20, 2024
2 parents 41efd94 + 6192cd5 commit c357a92
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rettiwt-core",
"version": "3.4.0-alpha.1",
"version": "3.4.0-alpha.2",
"description": "The core library for the reverse-engineered Twitter API",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion src/enums/Resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export enum EResourceType {
TWEET_DETAILS = '/i/api/graphql/0hWvDhmW8YQ-S_ib3azIrw/TweetResultByRestId',
TWEET_FAVORITERS = '/i/api/graphql/9XKD3EWWC2BKpIFyDj4KKQ/Favoriters',
TWEET_RETWEETERS = '/i/api/graphql/v5h-KLmyl-wqZ8i-a_q73w/Retweeters',
TWEET_REPLIES = '/i/api/graphql/B9_KmbkLhXt6jRwGjJrweg/TweetDetail',

// LIST
LIST_DETAILS = '/i/api/graphql/gO1_eYPohKYHwCG2m-1ZnQ/ListByRestId',
Expand Down
2 changes: 0 additions & 2 deletions src/models/args/FetchArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class FetchArgs {
EResourceType.TWEET_DETAILS,
EResourceType.TWEET_FAVORITERS,
EResourceType.TWEET_RETWEETERS,
EResourceType.TWEET_REPLIES,
EResourceType.USER_DETAILS,
EResourceType.USER_DETAILS_BY_ID,
EResourceType.USER_FOLLOWERS,
Expand All @@ -59,7 +58,6 @@ export class FetchArgs {
EResourceType.TWEET_DETAILS,
EResourceType.TWEET_FAVORITERS,
EResourceType.TWEET_RETWEETERS,
EResourceType.TWEET_REPLIES,
EResourceType.USER_DETAILS_BY_ID,
EResourceType.USER_FOLLOWERS,
EResourceType.USER_FOLLOWING,
Expand Down
6 changes: 6 additions & 0 deletions src/models/args/PostArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,18 @@ export class TweetArgs {
@IsObject({ each: true })
public media?: MediaArgs[];

/** The id of the Tweet to which the given Tweet must be a reply. */
@IsOptional()
@IsNumberString()
public replyTo?: string;

/**
* @param args - The additional user-defined arguments for posting the resource.
*/
public constructor(args: TweetArgs) {
this.text = args.text;
this.media = args.media ? args.media.map((item) => new MediaArgs(item)) : undefined;
this.replyTo = args.replyTo;

// Validating this object
const validationResult = validateSync(this);
Expand Down
37 changes: 26 additions & 11 deletions src/models/payloads/Variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ import { EResourceType } from '../../enums/Resources';
export class Variables {
/* eslint-disable @typescript-eslint/naming-convention */
public id?: string;
public focalTweetId?: string;
public tweetId?: string;
public tweet_id?: string;
public userId?: string;
public listId?: string;
public screen_name?: string;
public count?: number;
public cursor?: string;
public controller_data?: string;
public rawQuery?: string;
public tweet_text?: string;
public media?: MediaVariable;
public reply?: ReplyVariable;
public product?: string;
public includePromotedContent?: boolean;
public isMetatagsQuery?: boolean;
public withBirdwatchNotes?: boolean;
public withVoice?: boolean;
public withCommunity?: boolean;
public withReplays?: boolean;
Expand All @@ -43,6 +43,7 @@ export class Variables {
if (resourceType == EResourceType.CREATE_TWEET) {
this.tweet_text = args.tweet?.text;
this.media = args.tweet?.media ? new MediaVariable(args.tweet.media) : undefined;
this.reply = args.tweet?.replyTo ? new ReplyVariable(args.tweet.replyTo) : undefined;
} else if (resourceType == EResourceType.CREATE_RETWEET || resourceType == EResourceType.FAVORITE_TWEET) {
this.tweet_id = args.id;
} else if (resourceType == EResourceType.LIST_DETAILS) {
Expand Down Expand Up @@ -71,12 +72,6 @@ export class Variables {
this.count = args.count;
this.cursor = args.cursor;
this.includePromotedContent = false;
} else if (resourceType == EResourceType.TWEET_REPLIES) {
this.focalTweetId = args.id;
this.cursor = args.cursor;
this.includePromotedContent = false;
this.withBirdwatchNotes = false;
this.withVoice = false;
} else if (resourceType == EResourceType.USER_DETAILS) {
this.screen_name = args.id;
} else if (resourceType == EResourceType.USER_DETAILS_BY_ID) {
Expand Down Expand Up @@ -114,15 +109,15 @@ export class Variables {
*/
export class MediaVariable {
/* eslint-disable @typescript-eslint/naming-convention */
public media_entities: MediaVariableEntity[];
public media_entities: MediaEntityVariable[];
public possibly_sensitive: boolean;
/* eslint-enable @typescript-eslint/naming-convention */

/**
* @param media - The list of MediaArgs objects specifying the media items to be sent in the Tweet.
*/
public constructor(media: MediaArgs[]) {
this.media_entities = media.map((item) => new MediaVariableEntity(item));
this.media_entities = media.map((item) => new MediaEntityVariable(item));
this.possibly_sensitive = false;
}
}
Expand All @@ -132,7 +127,7 @@ export class MediaVariable {
*
* @public
*/
export class MediaVariableEntity {
export class MediaEntityVariable {
/* eslint-disable @typescript-eslint/naming-convention */
public media_id: string;
public tagged_users: string[];
Expand All @@ -146,3 +141,23 @@ export class MediaVariableEntity {
this.tagged_users = media.tags ?? [];
}
}

/**
* Reply specific details to be sent in payload.
*
* @public
*/
export class ReplyVariable {
/* eslint-disable @typescript-eslint/naming-convention */
public in_reply_to_tweet_id: string;
public exclude_reply_user_ids: string[];
/* eslint-enable @typescript-eslint/naming-convention */

/**
* @param replyTo - The id of the Tweet to which this Tweet is a reply.
*/
public constructor(replyTo: string) {
this.in_reply_to_tweet_id = replyTo;
this.exclude_reply_user_ids = [];
}
}

0 comments on commit c357a92

Please sign in to comment.