Skip to content

Commit 4160e38

Browse files
committed
feat(app): add createApp and getAppsWithAccess methods
1 parent c3d4276 commit 4160e38

File tree

4 files changed

+93
-3
lines changed

4 files changed

+93
-3
lines changed

src/modules/app/index.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { AppUserInterface, AppUpdatePasswordInterface, WhereCondition, AllAppUsersInterface, OrderBy, AppCreateUserParams, CreatedAppCreateUser, AppActivateUser, AppDeactiveUser, } from '../../types';
2-
import { APP_ACTIVE_USER, APP_CREATE_USER, APP_DEACTIVE_USER, USER_UPDATE_PASSWORD_MUTATION } from '../../mutations';
3-
import { GET_APP_USERS } from '../../queries';
1+
import type { AppUserInterface, AppUpdatePasswordInterface, WhereCondition, AllAppUsersInterface, OrderBy, AppCreateUserParams, CreatedAppCreateUser, AppActivateUser, AppDeactiveUser, AppWithAccessResponse, CreateAppInput, CreateAppResponse, } from '../../types';
2+
import { APP_ACTIVE_USER, APP_CREATE_USER, APP_DEACTIVE_USER, CREATE_APP, USER_UPDATE_PASSWORD_MUTATION } from '../../mutations';
3+
import { GET_APPS_WITH_ACCESS, GET_APP_USERS } from '../../queries';
44
import type { ClientType } from '../../index';
55

66
class Users {
@@ -113,4 +113,21 @@ export class App {
113113
this.users = new Users(this.client);
114114

115115
}
116+
117+
public async createApp(input: CreateAppInput): Promise<CreateAppResponse> {
118+
const response = await this.client.mutate({
119+
mutation: CREATE_APP,
120+
variables: {
121+
input
122+
}
123+
})
124+
return response.data
125+
}
126+
127+
public async getAppsWithAccess(): Promise<AppWithAccessResponse> {
128+
const response = await this.client.query({
129+
query: GET_APPS_WITH_ACCESS
130+
})
131+
return response.data
132+
}
116133
}

src/mutations/app.mutation.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,19 @@ export const APP_DEACTIVE_USER = gql`
5656
appDeActiveUser(user_id: $user_id)
5757
}
5858
`;
59+
60+
export const CREATE_APP = gql`
61+
mutation CreateApp($input: AppInput!) {
62+
createApp(input: $input) {
63+
name
64+
url
65+
description
66+
domain
67+
is_actived
68+
ecosystem_auth
69+
payments_active
70+
is_public
71+
domain_based
72+
}
73+
}
74+
`;

src/queries/app.query.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,21 @@ export const GET_APP_USERS = gql`
8181
}
8282
}
8383
`;
84+
85+
export const GET_APPS_WITH_ACCESS = gql`
86+
query {
87+
apps(first: 60) {
88+
data {
89+
id
90+
name
91+
key
92+
default_apps_plan_id
93+
created_at
94+
}
95+
paginatorInfo {
96+
currentPage
97+
lastPage
98+
}
99+
}
100+
}
101+
`;

src/types/app.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,42 @@ export interface AppActivateUser {
108108
export interface AppDeactiveUser {
109109
appDeActiveUser: boolean;
110110
}
111+
112+
export interface AppWithAccessResponse {
113+
apps: {
114+
data: {
115+
id: string;
116+
name: string;
117+
key: string;
118+
default_apps_plan_id: string;
119+
created_at: string;
120+
}[];
121+
paginatorInfo: PaginatorInfo;
122+
};
123+
}
124+
125+
export interface CreateAppInput {
126+
name: string;
127+
url: string;
128+
description?: string;
129+
domain: string;
130+
is_actived: 1;
131+
ecosystem_auth: 0,
132+
payments_active: 0,
133+
is_public: 1
134+
domain_based: 0
135+
}
136+
137+
export interface CreateAppResponse {
138+
createApp: {
139+
name: string;
140+
url: string;
141+
description?: string;
142+
domain: string;
143+
is_actived: boolean;
144+
ecosystem_auth: boolean;
145+
payments_active: boolean;
146+
is_public: boolean;
147+
domain_based: boolean;
148+
};
149+
}

0 commit comments

Comments
 (0)