import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';

import {User} from '@/_models';
import {Company} from "@/_models/company";

@Injectable({ providedIn: 'root' })
export class CompanyService {

    constructor(private http: HttpClient) { }

    getAll() {
        return this.http.get<Company[]>(`${config.apiUrl}/companies`);
    }

    register(company: Company) {
        return this.http.post(`${config.apiUrl}/companies/register`, company);
    }

    delete(id: number) {
        return this.http.delete(`${config.apiUrl}/companies/${id}`);
    }

    public save(company: Company) {
        return this.http.post<Company>(`${config.apiUrl}/companies/companies` , company);
    }
}