import { APIBase } from '@dvn/core/api/apiBase';
import { notImplemented } from '@dvn/dvn-mock/api/utils';
import { User } from '@dvn/kimlik/api/models';
import { getSessionData } from '@dvn/kimlik/index';
export class KimlikApiMentornity {
  constructor(endpoint, headers) {
    this.api = new APIBase(endpoint, headers);
  }
  activateUser(_email, _firstName, _lastName, _password) {
    return Promise.reject(notImplemented('KimlikApiMentornity.activateUser'));
  }
  addAuthInterceptor(token) {
    console.log('addAuthInterceptor', token);
  }
  login(email, password) {
    return new Promise(async (resolve) => {
      const response = await this.api.post('login', { email, password });
      resolve({ userId: response.user._id, jwt: response.accessToken });
    });
  }
  logout() {
    return Promise.resolve({});
  }
  register(_email, _firstName, _lastName, _password) {
    return Promise.reject(notImplemented('KimlikApiMentornity.register'));
  }
  getSession() {
    return new Promise(async (resolve) => {
      const user = await this.api.get(`users/${getSessionData().uid}`);
      resolve({ user: User.decode(user) });
    });
  }
  getUsers() {
    return Promise.reject('not-implemented');
  }
  getApiKeys() {
    return Promise.reject('not-implemented');
  }
  createApiKey(_data) {
    return Promise.reject('not-implemented');
  }
  deleteApiKey(_id) {
    return Promise.reject('not-implemented');
  }
  updateApiKey(_id, _data) {
    return Promise.reject('not-implemented');
  }
  getSAMLConfigs() {
    return Promise.reject('not-implemented');
  }
  createSAMLConfig(_data) {
    return Promise.reject('not-implemented');
  }
  deleteSAMLConfig(_id) {
    return Promise.reject('not-implemented');
  }
  updateSAMLConfig(_id, _data) {
    return Promise.reject('not-implemented');
  }
}
