refactor: correct response
This commit is contained in:
parent
7ba57c13ef
commit
61d17a4dcd
1 changed files with 15 additions and 19 deletions
|
@ -1,11 +1,16 @@
|
|||
import { BaseApi } from "./base-api.ts";
|
||||
|
||||
export type Oauth2ApplicationCreateParams = {
|
||||
name: string,
|
||||
redirect_uris: string[],
|
||||
confidential_client?: boolean,
|
||||
}
|
||||
|
||||
export type Oauth2Application = {
|
||||
id: number,
|
||||
name: string,
|
||||
redirect_uris: string[],
|
||||
client_id: string,
|
||||
client_secret: string,
|
||||
confidential_client: boolean,
|
||||
/**
|
||||
* @format date-time
|
||||
|
@ -13,6 +18,10 @@ export type Oauth2Application = {
|
|||
created: string,
|
||||
}
|
||||
|
||||
export type Oauth2ApplicationResponse = {
|
||||
client_secret: string,
|
||||
} & Oauth2Application
|
||||
|
||||
export class OAuth2Api extends BaseApi {
|
||||
private token: string;
|
||||
|
||||
|
@ -21,17 +30,8 @@ export class OAuth2Api extends BaseApi {
|
|||
this.token = token;
|
||||
}
|
||||
|
||||
// Method to update token if needed later
|
||||
updateToken(token: string): void {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
async createOauth2Application(params: {
|
||||
name: string,
|
||||
redirect_uris: string[],
|
||||
confidential_client?: boolean,
|
||||
}): Promise<Oauth2Application | undefined> {
|
||||
return await this.request<Oauth2Application>(`/api/v1/user/applications/oauth2`, {
|
||||
async createOauth2Application(params: Oauth2ApplicationCreateParams): Promise<Oauth2ApplicationResponse> {
|
||||
return await this.request<Oauth2ApplicationResponse>(`/api/v1/user/applications/oauth2`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Authorization": `Bearer ${this.token}`,
|
||||
|
@ -41,7 +41,7 @@ export class OAuth2Api extends BaseApi {
|
|||
});
|
||||
}
|
||||
|
||||
async getOauth2Applications(): Promise<Oauth2Application[] | undefined> {
|
||||
async getOauth2Applications(): Promise<Oauth2Application[]> {
|
||||
return await this.request<Oauth2Application[]>(`/api/v1/user/applications/oauth2`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
@ -65,12 +65,8 @@ export class OAuth2Api extends BaseApi {
|
|||
});
|
||||
}
|
||||
|
||||
async updateOauth2Application(id: number, params: {
|
||||
name: string,
|
||||
redirect_uris: string[],
|
||||
confidential_client?: boolean,
|
||||
}): Promise<Oauth2Application | undefined> {
|
||||
return await this.request<Oauth2Application>(`/api/v1/user/applications/oauth2/${id}`, {
|
||||
async updateOauth2Application(id: number, params: Oauth2ApplicationCreateParams): Promise<Oauth2ApplicationResponse> {
|
||||
return await this.request<Oauth2ApplicationResponse>(`/api/v1/user/applications/oauth2/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Authorization": `Bearer ${this.token}`,
|
||||
|
|
Loading…
Add table
Reference in a new issue