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"; | import { BaseApi } from "./base-api.ts"; | ||||||
| 
 | 
 | ||||||
|  | export type Oauth2ApplicationCreateParams = { | ||||||
|  |     name: string, | ||||||
|  |     redirect_uris: string[], | ||||||
|  |     confidential_client?: boolean, | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export type Oauth2Application = { | export type Oauth2Application = { | ||||||
|     id: number, |     id: number, | ||||||
|     name: string, |     name: string, | ||||||
|     redirect_uris: string[], |     redirect_uris: string[], | ||||||
|     client_id: string, |     client_id: string, | ||||||
|     client_secret: string, |  | ||||||
|     confidential_client: boolean, |     confidential_client: boolean, | ||||||
|     /** |     /** | ||||||
|      * @format date-time |      * @format date-time | ||||||
|  | @ -13,6 +18,10 @@ export type Oauth2Application = { | ||||||
|     created: string, |     created: string, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export type Oauth2ApplicationResponse = { | ||||||
|  |     client_secret: string, | ||||||
|  | } & Oauth2Application | ||||||
|  | 
 | ||||||
| export class OAuth2Api extends BaseApi { | export class OAuth2Api extends BaseApi { | ||||||
|     private token: string; |     private token: string; | ||||||
|      |      | ||||||
|  | @ -21,17 +30,8 @@ export class OAuth2Api extends BaseApi { | ||||||
|         this.token = token; |         this.token = token; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     // Method to update token if needed later
 |     async createOauth2Application(params: Oauth2ApplicationCreateParams): Promise<Oauth2ApplicationResponse> { | ||||||
|     updateToken(token: string): void { |         return await this.request<Oauth2ApplicationResponse>(`/api/v1/user/applications/oauth2`, { | ||||||
|         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`, { |  | ||||||
|             method: "POST", |             method: "POST", | ||||||
|             headers: { |             headers: { | ||||||
|                 "Authorization": `Bearer ${this.token}`, |                 "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`, { |         return await this.request<Oauth2Application[]>(`/api/v1/user/applications/oauth2`, { | ||||||
|             method: "GET", |             method: "GET", | ||||||
|             headers: { |             headers: { | ||||||
|  | @ -65,12 +65,8 @@ export class OAuth2Api extends BaseApi { | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     async updateOauth2Application(id: number, params: { |     async updateOauth2Application(id: number, params: Oauth2ApplicationCreateParams): Promise<Oauth2ApplicationResponse> { | ||||||
|         name: string, |         return await this.request<Oauth2ApplicationResponse>(`/api/v1/user/applications/oauth2/${id}`, { | ||||||
|         redirect_uris: string[], |  | ||||||
|         confidential_client?: boolean, |  | ||||||
|     }): Promise<Oauth2Application | undefined> { |  | ||||||
|         return await this.request<Oauth2Application>(`/api/v1/user/applications/oauth2/${id}`, { |  | ||||||
|             method: "PATCH", |             method: "PATCH", | ||||||
|             headers: { |             headers: { | ||||||
|                 "Authorization": `Bearer ${this.token}`, |                 "Authorization": `Bearer ${this.token}`, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue