Skip to content

Commit fdf9422

Browse files
committed
add v11 post api
Signed-off-by: ふぁ <yuki@yuki0311.com>
1 parent dec45fe commit fdf9422

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

twitter-openapi-typescript/src/apis/postApi.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import * as i from 'twitter-openapi-typescript-generated';
22
import { DefaultFlag } from '@/types';
3-
import { buildHeader, entriesCursor } from '@/models/api';
4-
import { TwitterApiUtilsResponse } from '@/types/response';
5-
6-
type Response<T> = Promise<TwitterApiUtilsResponse<T>>;
3+
import { buildHeader, entriesCursor } from '@/models';
4+
import { TwitterApiUtilsResponse } from '@/types';
75

86
type PostCreateTweetParam = {
97
tweetText: string;

twitter-openapi-typescript/src/apis/v11PostApi.ts

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import * as i from 'twitter-openapi-typescript-generated';
2-
import { DefaultFlag } from '@/types';
2+
import { DefaultFlag, TwitterApiUtilsResponse } from '@/types';
3+
import { buildHeader } from '@/models';
4+
5+
type PostCreateFriendshipsParam = {
6+
userId: string;
7+
extraParam?: { [key: string]: any };
8+
};
9+
10+
type PostDestroyFriendshipsParam = {
11+
userId: string;
12+
extraParam?: { [key: string]: any };
13+
};
314

415
export class V11PostApiUtils {
516
api: i.V11PostApi;
@@ -9,4 +20,54 @@ export class V11PostApiUtils {
920
this.api = api;
1021
this.flag = flag;
1122
}
23+
24+
async postCreateFriendships(param: PostCreateFriendshipsParam): Promise<TwitterApiUtilsResponse<undefined>> {
25+
const response = await this.api.postCreateFriendshipsRaw({
26+
includeBlockedBy: 1,
27+
includeBlocking: 1,
28+
includeCanDm: 1,
29+
includeCanMediaTag: 1,
30+
includeExtHasNftAvatar: 1,
31+
includeExtIsBlueVerified: 1,
32+
includeExtProfileImageShape: 1,
33+
includeExtVerifiedType: 1,
34+
includeFollowedBy: 1,
35+
includeMuteEdge: 1,
36+
includeProfileInterstitialType: 1,
37+
includeWantRetweets: 1,
38+
skipStatus: 1,
39+
userId: param.userId,
40+
...param.extraParam,
41+
});
42+
return {
43+
raw: { response: response.raw },
44+
header: buildHeader(response.raw.headers),
45+
data: undefined,
46+
};
47+
}
48+
49+
async postDestroyFriendships(param: PostDestroyFriendshipsParam): Promise<TwitterApiUtilsResponse<undefined>> {
50+
const response = await this.api.postDestroyFriendshipsRaw({
51+
includeBlockedBy: 0,
52+
includeBlocking: 0,
53+
includeCanDm: 0,
54+
includeCanMediaTag: 0,
55+
includeExtHasNftAvatar: 0,
56+
includeExtIsBlueVerified: 0,
57+
includeExtProfileImageShape: 0,
58+
includeExtVerifiedType: 0,
59+
includeFollowedBy: 0,
60+
includeMuteEdge: 0,
61+
includeProfileInterstitialType: 0,
62+
includeWantRetweets: 0,
63+
skipStatus: 0,
64+
userId: param.userId,
65+
...param.extraParam,
66+
});
67+
return {
68+
raw: { response: response.raw },
69+
header: buildHeader(response.raw.headers),
70+
data: undefined,
71+
};
72+
}
1273
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { getClient, logger } from '@test/init';
2+
3+
test('postCreateFriendships', async () => {
4+
const client = await getClient();
5+
const response = await client.getV11PostApi().postCreateFriendships({ userId: '44196397' });
6+
expect(response.raw.response.ok).toBe(true);
7+
});
8+
9+
test('postDestroyFriendships', async () => {
10+
const client = await getClient();
11+
const response = await client.getV11PostApi().postDestroyFriendships({ userId: '44196397' });
12+
expect(response.raw.response.ok).toBe(true);
13+
});

0 commit comments

Comments
 (0)