EscolaLMS/sdk

View on GitHub
src/services/profile.ts

Summary

Maintainability
A
3 hrs
Test Coverage
import request from "umi-request";
import * as API from "../types/api";
import { currentTimezone } from "../utils";

export async function changePassword(
  apiUrl: string,
  token: string,
  body: API.ChangePasswordRequest
) {
  return request<API.AuthResponse>(`${apiUrl}/api/profile/password`, {
    method: "PUT",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json",
      Authorization: `Bearer ${token}`,
      "Current-timezone": currentTimezone(),
    },
    data: body,
  });
}

export async function deleteAccount(apiUrl: string, token: string) {
  return request<API.AuthResponse>(`${apiUrl}/api/profile`, {
    method: "DELETE",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json",
      Authorization: `Bearer ${token}`,
      "Current-timezone": currentTimezone(),
    },
  });
}