Files
EnvelopeGenerator/envelope-generator-ui/src/app/services/history.service.ts
TekH eda30472b9 No changes detected in diff
No code was added or removed in the provided diff; only context lines were present.
2026-02-02 10:14:15 +01:00

46 lines
1.3 KiB
TypeScript

import { Injectable, inject } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, firstValueFrom } from 'rxjs';
import { API_URL } from '../tokens/index';
@Injectable({
providedIn: 'root'
})
export class HistoryService {
protected url: string;
constructor(private http: HttpClient) {
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);
if (options.referenceType != null)
params = params.set('referenceType', options.referenceType);
if (options.userReference)
params = params.set('userReference', options.userReference);
if (options.withReceiver)
params = params.set('withReceiver', options.withReceiver);
if (options.withSender)
params = params.set('withSender', options.withSender);
}
return this.http.get(this.url, { params });
}
public async getHistoryAsync(options?: Options): Promise<any> {
return firstValueFrom(this.getHistory(options));
}
}
class Options {
envelopeId?: number;
userReference?: string;
referenceType: number | null = null;
withSender?: boolean;
withReceiver?: boolean;
}