feat(service): Unterstützung von Query-Parametern im HistoryService hinzugefügt
- Methode `getHistory` hinzugefügt, um das Abrufen von History-Daten mit optionalen Query-Parametern wie `envelopeId`, `referenceType`, `userReference`, `withSender` und `withReceiver` zu ermöglichen. - Methode `getHistoryAsync` implementiert, um History-Daten mit async/await abzurufen. - `Options`-Interface eingeführt, um optionale Query-Parameter für History-Anfragen zu definieren.
This commit is contained in:
parent
cd88f5c833
commit
5d2bf56493
@ -1,5 +1,5 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable, firstValueFrom } from 'rxjs';
|
||||
import { API_URL } from '../tokens/index';
|
||||
|
||||
@ -14,4 +14,33 @@ export class HistoryService {
|
||||
const api_url = inject(API_URL);
|
||||
this.url = `${api_url}/history`;
|
||||
}
|
||||
|
||||
public getHistory(options?: Options): Observable<any> {
|
||||
let params = new HttpParams();
|
||||
if (options) {
|
||||
if (options.envelopeId)
|
||||
params = params.set('envelopeId', options.envelopeId.toString());
|
||||
if (options.referenceType)
|
||||
params = params.set('referenceType', options.referenceType.toString());
|
||||
if (options.userReference)
|
||||
params = params.set('userReference', options.userReference.toString());
|
||||
if (options.withReceiver)
|
||||
params = params.set('withReceiver', options.withReceiver.toString());
|
||||
if (options.withSender)
|
||||
params = params.set('withSender', options.withSender.toString());
|
||||
}
|
||||
return this.http.get(this.url, { params });
|
||||
}
|
||||
|
||||
public async getHistoryAsync(options?: Options): Promise<any> {
|
||||
return firstValueFrom(this.getHistory(options));
|
||||
}
|
||||
}
|
||||
|
||||
interface Options {
|
||||
envelopeId?: number;
|
||||
userReference?: string;
|
||||
referenceType?: number;
|
||||
withSender?: boolean;
|
||||
withReceiver?: boolean;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user