initial commit

This commit is contained in:
2022-12-22 16:38:25 +01:00
commit a3f54bb537
143 changed files with 24386 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import {Injectable} from "@angular/core";
import {Observable} from "rxjs";
import {HttpClient, HttpHeaders, HttpResponse} from "@angular/common/http";
@Injectable({
providedIn: 'root'
})
export class MastodonApiService {
constructor(private httpClient: HttpClient) {
}
get<T>(url: string) {
return this.httpClient.get<T>(url);
}
getAuthenticated<T>(url: string, accessToken: string): Observable<T> {
const reqHeader = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + accessToken
});
return this.httpClient.get<T>(url, {headers: reqHeader});
}
getAuthenticatedWithResponseHeaders<T>(url: string, accessToken: string): Observable<HttpResponse<T>> {
const reqHeader = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + accessToken
});
return this.httpClient.get<T>(url, {headers: reqHeader, observe: 'response'});
}
post<T>(url: string, parameters: object) {
return this.httpClient.post<T>(url, parameters);
}
postAuthenticated(url: string, body: { account_ids: string[] }, accessToken: string) {
const reqHeader = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + accessToken
});
return this.httpClient.post(url, body, {headers: reqHeader});
}
deleteAuthenticated(url: string, body: { account_ids: string[] }, accessToken: string) {
const reqHeader = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + accessToken
});
return this.httpClient.delete(url, {headers: reqHeader, body});
}
}