deno.land / x / gesso@v0.1.2 / src / JWTs.ts
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import { BaseApi } from "./BaseApi.ts";import { Configuration } from "./Configuration.ts";import { Jwt } from "../types/models.ts";import { CreateJwtParams, RefreshJwtParams } from "../types/params.ts";
export class JWTs extends BaseApi { constructor(config: Configuration) { super(config); }
public async createJwt( params?: CreateJwtParams, body?: unknown, ): Promise<Jwt> { const endpoint = "/api/v1/jwts"; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Jwt; }
return Promise.reject(response); }
public async refreshJwt( params?: RefreshJwtParams, body?: unknown, ): Promise<Jwt> { const endpoint = "/api/v1/jwts/refresh"; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Jwt; }
return Promise.reject(response); }}
Version Info