31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
import { Observable } from 'rxjs';
|
|
import { filter, map } from 'rxjs/operators';
|
|
import { StrictHttpResponse } from '../../strict-http-response';
|
|
import { RequestBuilder } from '../../request-builder';
|
|
import { Answers } from '../../models/answers';
|
|
import { Tested } from '../../models/tested';
|
|
export interface TestSource$Params {
|
|
limit?: number;
|
|
body: Answers;
|
|
}
|
|
export function testSource(
|
|
http: HttpClient,
|
|
rootUrl: string,
|
|
params: TestSource$Params,
|
|
context?: HttpContext,
|
|
): Observable<StrictHttpResponse<Tested>> {
|
|
const rb = new RequestBuilder(rootUrl, testSource.PATH, 'post');
|
|
if (params) {
|
|
rb.query('limit', params.limit, {});
|
|
rb.body(params.body, 'application/json');
|
|
}
|
|
return http.request(rb.build({ responseType: 'json', accept: 'application/json', context })).pipe(
|
|
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
map((r: HttpResponse<any>) => {
|
|
return r as StrictHttpResponse<Tested>;
|
|
}),
|
|
);
|
|
}
|
|
testSource.PATH = '/ingest/sources/test';
|