File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ export type TwitterOpenApiCookie = {
2222 value : string ;
2323} ;
2424
25+ export type TwitterOpenApiClientOptions = {
26+ flag ?: DefaultFlag ;
27+ } ;
28+
2529export class TwitterOpenApi {
2630 static hash = 'd5ccc25869b68cbb39c68fa81a1fa77967a667da' ;
2731 static url = `https://raw.githubusercontent.com/fa0311/twitter-openapi/${ this . hash } /src/config/placeholder.json` ;
@@ -90,7 +94,7 @@ export class TwitterOpenApi {
9094 return context ;
9195 }
9296
93- async getClient ( ) : Promise < TwitterOpenApiClient > {
97+ async getClient ( options ?: TwitterOpenApiClientOptions ) : Promise < TwitterOpenApiClient > {
9498 const cookies : TwitterOpenApiCookie [ ] = await this . getGuestSession ( ) ;
9599 const config : i . ConfigurationParameters = {
96100 fetchApi : this . fetchApi ,
@@ -106,8 +110,10 @@ export class TwitterOpenApi {
106110 } ,
107111 accessToken : TwitterOpenApi . bearer ,
108112 } ;
109- const flag = this . fetchApi ( TwitterOpenApi . url , { method : 'GET' } ) . then ( ( res ) => res . json ( ) ) as Promise < DefaultFlag > ;
110- return new TwitterOpenApiClient ( new i . Configuration ( config ) , await flag ) ;
113+ const flag =
114+ options . flag ||
115+ ( ( await this . fetchApi ( TwitterOpenApi . url , { method : 'GET' } ) . then ( ( res ) => res . json ( ) ) ) as DefaultFlag ) ;
116+ return new TwitterOpenApiClient ( new i . Configuration ( config ) , flag ) ;
111117 }
112118
113119 async getClientFromCookies ( ct0 : string , authToken : string ) : Promise < TwitterOpenApiClient > {
You can’t perform that action at this time.
0 commit comments