All files / app/service/api origin.service.ts

75% Statements 12/16
100% Branches 5/5
42.85% Functions 3/7
66.66% Lines 8/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39  3x     3x             3x     3x 3x 3x       1x       1x                            
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { DateTime } from 'luxon';
import { catchError, map, Observable } from 'rxjs';
import { params } from '../../util/http';
import { ConfigService } from '../config.service';
import { LoginService } from '../login.service';
 
@Injectable({
  providedIn: 'root'
})
export class OriginService {
 
  constructor(
    private http: HttpClient,
    private config: ConfigService,
    private login: LoginService,
  ) { }
 
  private get base() {
    return this.config.api + '/api/v1/origin';
  }
 
  list(): Observable<string[]> {
    return this.http.get(`${this.base}`).pipe(
      map(res => res as string[]),
      catchError(err => this.login.handleHttpError(err)),
    );
  }
 
  delete(origin: string, olderThan: DateTime): Observable<void> {
    return this.http.delete<void>(`${this.base}`, {
      params: params({ origin, olderThan }),
    }).pipe(
      catchError(err => this.login.handleHttpError(err)),
    );
  }
}