2021-09-08 13:11:42 +02:00
|
|
|
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
|
|
|
|
import { MessageService } from './message.service';
|
|
|
|
import { serviceBaseUrl } from './config';
|
|
|
|
|
|
|
|
|
2021-10-31 21:47:53 +01:00
|
|
|
import { Account, Fee, OverheadAdvance } from './data-objects';
|
2021-11-08 21:04:21 +01:00
|
|
|
import { Saldo, Tenant_with_Saldo, UniqueNumber } from './ext-data-objects';
|
2021-09-08 13:11:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' })
|
2021-09-09 11:36:01 +02:00
|
|
|
export class ExtApiService {
|
2021-09-08 13:11:42 +02:00
|
|
|
constructor(private messageService: MessageService, private http: HttpClient) { }
|
|
|
|
|
2021-09-09 11:36:01 +02:00
|
|
|
async getOverheadAdvancesByFlat(id: number): Promise<OverheadAdvance[]> {
|
|
|
|
this.messageService.add(`ExtApiService: get overheadadvances by flat ${id}`);
|
|
|
|
return this.http.get<OverheadAdvance[]>(`${serviceBaseUrl}/v1/overhead_advances/flat/${id}`).toPromise()
|
|
|
|
}
|
|
|
|
|
2021-10-31 21:47:53 +01:00
|
|
|
async getAccountByDescription(description: string): Promise<Account> {
|
|
|
|
this.messageService.add(`ExtApiService: get account by description ${description}`);
|
|
|
|
return this.http.get<Account>(`${serviceBaseUrl}/v1/accounts/bydescription/${description}`).toPromise()
|
|
|
|
}
|
|
|
|
|
2021-09-09 11:36:01 +02:00
|
|
|
async getFeeByTenancies(id: number): Promise<Fee[]> {
|
|
|
|
this.messageService.add(`ExtApiService: get fees by flat ${id}`);
|
|
|
|
return this.http.get<Fee[]>(`${serviceBaseUrl}/v1/fees/tenancy/${id}`).toPromise()
|
2021-09-08 13:11:42 +02:00
|
|
|
}
|
2021-09-09 18:00:24 +02:00
|
|
|
|
|
|
|
async getAccountSaldo(id: number): Promise<Saldo> {
|
|
|
|
this.messageService.add(`ExtApiService: get saldo for account ${id}`);
|
|
|
|
return this.http.get<Saldo>(`${serviceBaseUrl}/v1/account/saldo/${id}`).toPromise()
|
|
|
|
}
|
2021-09-14 14:14:56 +02:00
|
|
|
|
|
|
|
async getTenantsWithSaldo(): Promise<Tenant_with_Saldo[]> {
|
|
|
|
this.messageService.add("ExtApiService: get tenants with saldo");
|
|
|
|
return this.http.get<Tenant_with_Saldo[]>(`${serviceBaseUrl}/v1/tenants/saldo`).toPromise()
|
|
|
|
}
|
2021-11-08 21:04:21 +01:00
|
|
|
|
|
|
|
async getUniqueNumber(): Promise<UniqueNumber> {
|
|
|
|
this.messageService.add("ExtApiService: get unique number");
|
|
|
|
return this.http.get<UniqueNumber>(`${serviceBaseUrl}/v1/uniquenumber`).toPromise()
|
|
|
|
}
|
2021-09-08 13:11:42 +02:00
|
|
|
}
|