import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
-import { Observable } from 'rxjs';
-import { map } from 'rxjs/operators';
-import { EIJob, EIType, EIProducer } from '../../interfaces/ei.jobs';
-import { ControlpanelSuccessTransport } from '../../interfaces/controlpanel.types';
+import { Observable, of } from 'rxjs';
+import { EIJob, EIProducer } from '../../interfaces/ei.types';
/**
* Services for calling the EI endpoints.
})
export class EIService {
- private basePath = 'api/enrichment';
- private eiTypePath = 'eitypes';
- private eiJobPath = 'eijobs';
- private eiProducerPath = 'eiproducers';
+ private basePath = '/ei-producer/v1';
+ eiJobsPath = 'eijobs';
+ eiProducersPath = 'eiproducers';
private buildPath(...args: any[]) {
let result = this.basePath;
args.forEach(part => {
result = result + '/' + part;
});
- console.log("URL: "+result);
return result;
}
// injects to variable httpClient
}
- /**
- * Gets version details
- * @returns Observable that should yield a String
- */
- getVersion(): Observable<string> {
- const url = this.buildPath('version');
- return this.httpClient.get<ControlpanelSuccessTransport>(url).pipe(
- // Extract the string here
- map(res => res['data'])
- );
+ getProducerIds(): Observable<String[]> {
+ const url = this.buildPath(this.eiProducersPath);
+ return this.httpClient.get<String[]>(url);
}
- getEITypes(): Observable<EIType[]> {
- const url = this.buildPath(this.eiTypePath);
- return this.httpClient.get<EIType[]>(url);
- }
-
- getEIJobs(): Observable<EIJob[]> {
- const url = this.buildPath(this.eiJobPath);
+ getJobsForProducer(producerId: String): Observable<EIJob[]> {
+ const url = this.buildPath(this.eiProducersPath, producerId, this.eiJobsPath);
return this.httpClient.get<EIJob[]>(url);
}
getEIProducers(): Observable<EIProducer[]> {
- const url = this.buildPath(this.eiProducerPath);
+ const url = this.buildPath(this.eiProducersPath);
return this.httpClient.get<EIProducer[]>(url);
}
}