No changes detected in diff
No code was added or removed in the provided diff; only context lines were present.
This commit is contained in:
46
envelope-generator-ui/src/app/services/history.service.ts
Normal file
46
envelope-generator-ui/src/app/services/history.service.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user