import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { Observable } from "rxjs/Rx";
var PeopleFinderService = (function () {
    function PeopleFinderService(http) {
        this.http = http;
        this._getDirectUserUrl = "http://peoplefinder.ghdnet.internal/home/GetMatchingGhdPeople?searchTerm=";
        this._getPhootoUrl = "http://peoplefinder.ghdnet.internal/home/image?personid=";
    }
    /**
     * Match a GHD Staff details in PeopleFinder
     * @param {string} query string containing a part of name of the GHD Staff
     * @return {Array<GHDPeopleFinder>}
     */
    PeopleFinderService.prototype.loadMatchingGHDPersons = function (query) {
        var _this = this;
        return this.http.get(this._getDirectUserUrl + query)
            .map(this.extractData)
            .catch(function (err) { return _this.handleError(err); });
    };
    /**
     * Gets a Base 64 photo of the GHD staff
     * @param {string} id login id of the GHD person
     * @return {string}
     */
    PeopleFinderService.prototype.getGHDPhoto = function (id) {
        return this._getPhootoUrl + id;
    };
    PeopleFinderService.prototype.extractData = function (res) {
        if (res.status < 200 || res.status >= 300) {
            throw new Error('Bad response status: ' + res.status);
        }
        var body = res.json();
        return body || {};
    };
    PeopleFinderService.prototype.handleError = function (error) {
        return Observable.throw(error);
    };
    PeopleFinderService.decorators = [
        { type: Injectable },
    ];
    /** @nocollapse */
    PeopleFinderService.ctorParameters = function () { return [
        { type: Http, },
    ]; };
    return PeopleFinderService;
}());
export { PeopleFinderService };
//# sourceMappingURL=peopleFinder.service.js.map