// Angular Core
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

// Services
import { ApiService } from '../../../../services/api/api.service';
@Injectable({
  providedIn: 'root'
})
export class RegisterService {

  constructor(private http: HttpClient, public api: ApiService) { }

  /**
   * Gets user classifications information
   * @returns {object} promise
   */
  getClassifications() {
    return this.api.read('/Registration/getClassifications');
  };

  /**
   * Gets specialties information
   * @param {int} classificationId
   * @returns {object} promise
   */
  getSpecialties(classificationId: number) {
    return this.api.read('/Registration/getSpecialties?classification_id=' + classificationId);
  };


  /**
   * sends respose to api service for handling
   * @param {object} response object
   * @returns {undefined}
   */
  errorCallBack(response: {}) {
    this.api.errorCallback(response);
  };

  /**
   * Retrieve user information (e.g., username, email, preview mode status, registration status)
   * @param {string} userName
   * @returns {object} promise
   */
  getUserInfo(userName: string) {
    return this.api.read('/Registration/getUserInfo?user_name=' + userName);
  };

  /**
   * register new user
   * @param {array} data
   * @returns {object} promise
   */
  createNewUser(data: []) {
    return this.api.create('/Registration', data);
  };

  /**
   * register preview user
   * @param {array} data
   * @returns {object} promise
   */
  updatePmsAuthInfo(data: {}) {
    return this.api.create('/Registration/updatePmsAuthInfo', data);
  };
}
