Add a create method to the session.Client

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-07-12 10:58:45 +02:00
parent d5857952aa
commit 0327cf21e5
+20 -1
View File
@@ -1,11 +1,19 @@
import type { Fetcher, RequestOptions } from "./fetcher.js";
import type { SuccessResponse } from "./shared.js";
import type { ZodSchema } from "zod";
import type { ZodSchema, z } from "zod";
import { number, object, string } from "zod";
import { successResponseSchema } from "./shared.js";
export const sessionPayloadSchema = object({
sessionId: string(),
signature: string(),
publicKey: string(),
});
export type SessionPayload = z.infer<typeof sessionPayloadSchema>;
interface Session {
sessionId: string;
status: string;
@@ -40,6 +48,17 @@ export class Client {
);
}
public async create(options?: RequestOptions): Promise<Session> {
return this.#fetcher.fetchOk(
{
method: "POST",
path: "sessions",
options,
},
sessionSchema,
);
}
public async update(
id: string,
body: {