Files
we_bstly-web/src/app/services/admin/shortenedurl.management.service.ts
T
2025-11-09 01:58:54 +01:00

35 lines
1.2 KiB
TypeScript

import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { environment } from '../../../environments/environment';
@Injectable({
providedIn: 'root',
})
export class ShortenedUrlManagementService {
constructor(private http: HttpClient) {
}
getShortenedUrls(page: number = 0, size: number = 10, search: string = '') {
let params = new HttpParams()
.set('page', page.toString())
.set('size', size.toString())
.set('search', search);
return this.http.get(environment.apiUrl + "/url/shortener/manage", { params });
}
createOrUpdateShortenedUrl(shortenedUrl: any) {
return this.http.post(environment.apiUrl + "/url/shortener/manage", shortenedUrl);
}
deleteShortenedUrl(code: string, quota: boolean = false) {
let params = new HttpParams().set('quota', quota.toString());
return this.http.delete(environment.apiUrl + "/url/shortener/manage/" + code, { params });
}
deleteAll(owner: number, quota: boolean = false) {
let params = new HttpParams().set('quota', quota.toString());
return this.http.delete(environment.apiUrl + "/url/shortener/manage/all/" + owner, { params });
}
}