Skip to content

Commit

Permalink
Merge pull request #112 from fa0311/dev
Browse files Browse the repository at this point in the history
update 0.0.41
  • Loading branch information
fa0311 authored Oct 30, 2024
2 parents fc8929f + 0068e71 commit fb62699
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 22 deletions.
4 changes: 2 additions & 2 deletions twitter-openapi-typescript-generated/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [email protected].25
## [email protected].26

This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:

Expand Down Expand Up @@ -36,7 +36,7 @@ navigate to the folder of your consuming project and run one of the following co
_published:_

```
npm install [email protected].25 --save
npm install [email protected].26 --save
```

_unPublished (not recommended):_
Expand Down
4 changes: 2 additions & 2 deletions twitter-openapi-typescript-generated/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion twitter-openapi-typescript-generated/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twitter-openapi-typescript-generated",
"version": "0.0.25",
"version": "0.0.26",
"description": "OpenAPI client for twitter-openapi-typescript-generated",
"author": "fa0311",
"repository": {
Expand Down
48 changes: 48 additions & 0 deletions twitter-openapi-typescript-generated/src/apis/TweetApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface GetLikesRequest {
pathQueryId: string;
variables: string;
features: string;
fieldToggles: string;
}

export interface GetListLatestTweetsTimelineRequest {
Expand Down Expand Up @@ -93,18 +94,21 @@ export interface GetUserMediaRequest {
pathQueryId: string;
variables: string;
features: string;
fieldToggles: string;
}

export interface GetUserTweetsRequest {
pathQueryId: string;
variables: string;
features: string;
fieldToggles: string;
}

export interface GetUserTweetsAndRepliesRequest {
pathQueryId: string;
variables: string;
features: string;
fieldToggles: string;
}

/**
Expand Down Expand Up @@ -530,6 +534,13 @@ export class TweetApi extends runtime.BaseAPI {
);
}

if (requestParameters['fieldToggles'] == null) {
throw new runtime.RequiredError(
'fieldToggles',
'Required parameter "fieldToggles" was null or undefined when calling getLikes().'
);
}

const queryParameters: any = {};

if (requestParameters['variables'] != null) {
Expand All @@ -540,6 +551,10 @@ export class TweetApi extends runtime.BaseAPI {
queryParameters['features'] = requestParameters['features'];
}

if (requestParameters['fieldToggles'] != null) {
queryParameters['fieldToggles'] = requestParameters['fieldToggles'];
}

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
Expand Down Expand Up @@ -1196,6 +1211,13 @@ export class TweetApi extends runtime.BaseAPI {
);
}

if (requestParameters['fieldToggles'] == null) {
throw new runtime.RequiredError(
'fieldToggles',
'Required parameter "fieldToggles" was null or undefined when calling getUserMedia().'
);
}

const queryParameters: any = {};

if (requestParameters['variables'] != null) {
Expand All @@ -1206,6 +1228,10 @@ export class TweetApi extends runtime.BaseAPI {
queryParameters['features'] = requestParameters['features'];
}

if (requestParameters['fieldToggles'] != null) {
queryParameters['fieldToggles'] = requestParameters['fieldToggles'];
}

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
Expand Down Expand Up @@ -1327,6 +1353,13 @@ export class TweetApi extends runtime.BaseAPI {
);
}

if (requestParameters['fieldToggles'] == null) {
throw new runtime.RequiredError(
'fieldToggles',
'Required parameter "fieldToggles" was null or undefined when calling getUserTweets().'
);
}

const queryParameters: any = {};

if (requestParameters['variables'] != null) {
Expand All @@ -1337,6 +1370,10 @@ export class TweetApi extends runtime.BaseAPI {
queryParameters['features'] = requestParameters['features'];
}

if (requestParameters['fieldToggles'] != null) {
queryParameters['fieldToggles'] = requestParameters['fieldToggles'];
}

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
Expand Down Expand Up @@ -1458,6 +1495,13 @@ export class TweetApi extends runtime.BaseAPI {
);
}

if (requestParameters['fieldToggles'] == null) {
throw new runtime.RequiredError(
'fieldToggles',
'Required parameter "fieldToggles" was null or undefined when calling getUserTweetsAndReplies().'
);
}

const queryParameters: any = {};

if (requestParameters['variables'] != null) {
Expand All @@ -1468,6 +1512,10 @@ export class TweetApi extends runtime.BaseAPI {
queryParameters['features'] = requestParameters['features'];
}

if (requestParameters['fieldToggles'] != null) {
queryParameters['fieldToggles'] = requestParameters['fieldToggles'];
}

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export const TimelineGeneralContextContextTypeEnum = {
Location: 'Location',
Sparkle: 'Sparkle',
Conversation: 'Conversation',
List: 'List'
List: 'List',
Community: 'Community'
} as const;
export type TimelineGeneralContextContextTypeEnum = typeof TimelineGeneralContextContextTypeEnum[keyof typeof TimelineGeneralContextContextTypeEnum];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ export interface UserResponseData {
* @type {UserResults}
* @memberof UserResponseData
*/
user: UserResults;
user?: UserResults;
}

/**
* Check if a given object implements the UserResponseData interface.
*/
export function instanceOfUserResponseData(value: object): value is UserResponseData {
if (!('user' in value) || value['user'] === undefined) return false;
return true;
}

Expand All @@ -52,7 +51,7 @@ export function UserResponseDataFromJSONTyped(json: any, ignoreDiscriminator: bo
}
return {

'user': UserResultsFromJSON(json['user']),
'user': json['user'] == null ? undefined : UserResultsFromJSON(json['user']),
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
inputSpec: twitter-openapi/dist/compatible/openapi-3.0.yaml
outputDir: .
npmName: twitter-openapi-typescript-generated
npmVersion: 0.0.25
npmVersion: 0.0.26

# withoutRuntimeChecks: false
legacyDiscriminatorBehavior: false
Expand Down
2 changes: 2 additions & 0 deletions twitter-openapi-typescript-generated/tools/win/init.ps1
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# 7.9.0 is not working
# https://github.com/OpenAPITools/openapi-generator/issues/19858
Invoke-WebRequest -OutFile tools/openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar
12 changes: 6 additions & 6 deletions twitter-openapi-typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions twitter-openapi-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twitter-openapi-typescript",
"version": "0.0.40",
"version": "0.0.41",
"description": "Implementation of Twitter internal API in TypeScript",
"scripts": {
"test": "jest",
Expand All @@ -21,7 +21,7 @@
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts",
"dependencies": {
"twitter-openapi-typescript-generated": "^0.0.25"
"twitter-openapi-typescript-generated": "^0.0.26"
},
"devDependencies": {
"@types/jest": "*",
Expand Down
6 changes: 3 additions & 3 deletions twitter-openapi-typescript/src/apis/userApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DefaultFlag, RequestParam, TwitterApiUtilsResponse, UserApiUtilsData, initOverrides } from '@/models';
import { buildHeader, errorCheck, getKwargs, userOrNullConverter } from '@/utils';
import { buildHeader, errorCheck, getKwargs, nonNullable, userOrNullConverter } from '@/utils';
import * as i from 'twitter-openapi-typescript-generated';

type getUserByScreenNameParam = {
Expand Down Expand Up @@ -51,7 +51,7 @@ export class UserApiUtils {
const response = this.request({
key: 'UserByScreenName',
apiFn: this.api.getUserByScreenNameRaw,
convertFn: (e) => e.data.user,
convertFn: (e) => nonNullable(e.data.user),
param: args,
});
return response;
Expand All @@ -64,7 +64,7 @@ export class UserApiUtils {
const response = this.request({
key: 'UserByRestId',
apiFn: this.api.getUserByRestIdRaw,
convertFn: (e) => e.data.user,
convertFn: (e) => nonNullable(e.data.user),
param: args,
});
return response;
Expand Down
16 changes: 16 additions & 0 deletions twitter-openapi-typescript/test/api/userApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ test('getUserByScreenName', async () => {
expect(response.raw.response.ok).toBe(true);
});

test('getUserByScreenNameNotFound', async () => {
logger.log('getUserByScreenName');
const client = await getClient();
const response = await client.getUserApi().getUserByScreenName({ screenName: 'Wendoleecs' });
printUser(response.data);
expect(response.raw.response.ok).toBe(true);
});

test('getUserByScreenNameFreezed', async () => {
logger.log('getUserByScreenName');
const client = await getClient();
const response = await client.getUserApi().getUserByScreenName({ screenName: 'anal' });
printUser(response.data);
expect(response.raw.response.ok).toBe(true);
});

test('getUserByRestId', async () => {
logger.log('getUserByRestId');
const client = await getClient();
Expand Down

0 comments on commit fb62699

Please sign in to comment.