// 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 PasswordService {

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

  deaName: string = '';
  userId: number = 0;

  /**
   * sets user Name
   * @param {string} name
  */
  setdeaName(name: string) {
    if (typeof name === 'string') {
      this.deaName = name;
    }
  };

  /**
   * gets current userName
   * @returns {String|userName}
  */
  getdeaName() {
    return this.deaName;
  };

  /**
   * sets user EmailId
   * @param  id
  */
  setuserId(id: any) {
    this.userId = id;
  };

  /**
   * gets current user Email Id
   * @returns {String|userId}
  */
  getuserId() {
    return this.userId;
  };

  /**
   * Authenticate password
   * @returns {object} promise
   */
  getPasswordAuthentication(name: string, email: any) {
    var retrievePassword = {};
    retrievePassword = {
      user_name: name,
      email: email
    };
    return this.api.create('/Authentication', retrievePassword);
  };

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

}
