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

// Services
import { ApiService } from '../api/api.service';

@Injectable({
  providedIn: 'root'
})
export class SuggestiveService {

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

  /**
  * Private model for suggestive data
  * @type object
  */
  suggestive = {
    data: {
    }
  };

  /**
   * Get top trending suggestives
   * @return {unresolved}
   */
  getSuggestive(name: string) {
    return this.api.read('/User-Suggestive?name=' + name);
  };

  /**
   * Handles API error
   * @param {Object} response
   * @returns {undefined}
   */
  errorCallBack(response: any) {
    this.api.errorCallback(response);
  };

  /**
   * Checks whether the current user has dispensing data.
   *
   * @returns {Promise<object>} A promise that resolves with the API response.
   */
  hasDispensingData() {
    return this.api.read('/User-Suggestive/hasDispensingData');
  };
}
