var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Injectable } from '@angular/core';
import { throwError } from 'rxjs';
import { plainToClass } from 'class-transformer';
import { HttpErrorService } from '../../../services';
import { AbstractAppConfig } from '../../../../app.config';
import { CaseHistory } from '../domain';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { catchError, map } from 'rxjs/operators';
var CaseHistoryService = /** @class */ (function () {
    function CaseHistoryService(httpClient, httpErrorService, appConfig) {
        this.httpClient = httpClient;
        this.httpErrorService = httpErrorService;
        this.appConfig = appConfig;
    }
    CaseHistoryService_1 = CaseHistoryService;
    CaseHistoryService.prototype.get = function (caseId, eventId) {
        var _this = this;
        var url = this.appConfig.getCaseHistoryUrl(caseId, eventId);
        var headers = new HttpHeaders({
            'Accept': [CaseHistoryService_1.V2_MEDIATYPE_CASE_EVENT_VIEW, CaseHistoryService_1.QC_V2_MEDIATYPE_CASE_EVENT_VIEW],
        });
        return this.httpClient
            .get(url, { headers: headers })
            .pipe(map(function (caseHistory) { return plainToClass(CaseHistory, caseHistory); }), catchError(function (error) {
            _this.httpErrorService.setError(error);
            return throwError(error);
        }));
    };
    var CaseHistoryService_1;
    CaseHistoryService.V2_MEDIATYPE_CASE_EVENT_VIEW = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.ui-event-view.v2+json;charset=UTF-8';
    CaseHistoryService.QC_V2_MEDIATYPE_CASE_EVENT_VIEW = 'application/vnd.app.quickcase.store.data.api.ui-event-view.v2+json;charset=UTF-8';
    CaseHistoryService = CaseHistoryService_1 = __decorate([
        Injectable(),
        __metadata("design:paramtypes", [HttpClient,
            HttpErrorService,
            AbstractAppConfig])
    ], CaseHistoryService);
    return CaseHistoryService;
}());
export { CaseHistoryService };
//# sourceMappingURL=case-history.service.js.map