/*
 * Copyright (C) 2022 StApps
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

/**
 * TODO: Take it from the StApps Core
 */
import {SCAcademicPriceGroup} from '@openstapps/core';

/**
 * A user configuration
 */
export interface SCUserConfiguration {
  /**
   * User's e-mail
   */
  email?: string;

  /**
   * User's family name
   */
  familyName?: string;

  /**
   * User's given name
   */
  givenName?: string;

  /**
   * ID given to the user
   */
  id: string;

  /**
   * The complete name of the user combining all the parts of the name into one
   */
  name: string;

  /**
   * Role assigned to the user
   */
  role: keyof SCAcademicPriceGroup;

  /**
   * Student ID given to the user
   */
  studentId?: string;
}

/**
 * TODO: Take it from the backend's config
 */
type mapping = {[key in keyof SCUserConfiguration]: string};

/**
 * TODO: Take it from the backend's config
 */
export const userMapping: mapping = {
  id: 'id',
  name: 'sn',
  role: 'attributes.eduPersonPrimaryAffiliation',
  email: 'attributes.mailPrimaryAddress',
  studentId: 'attributes.employeeNumber',
  givenName: 'attributes.givenName',
  familyName: 'attributes.sn',
};

/**
 * TODO: Take it from the StApps Core
 */
export type SCAuthorizationProviderType = 'default' | 'paia';
