import IService from "."; import User from "../types/User"; import HttpHandler from "./http"; export default class UserService implements IService { constructor(private key: string) {} private http = new HttpHandler(); private path: string = "/api/v1/users"; all = async (): Promise => { const response = await this.http.get(this.path, this.key); return (response.parsedBody as unknown) as User[]; }; get = async (id: string): Promise => { const response = await this.http.get(`${this.path}/${id}`, this.key); const body = response.parsedBody; return body ?? ({} as User); }; add = async (item: User): Promise => { await this.http.post(this.path, item, this.key); }; update = async (id: string, item: User): Promise => { throw new Error("Method not implemented."); }; delete = async (id: string): Promise => { throw new Error("Method not implemented."); }; }