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

import {environment} from '../../environments/environment';

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

    constructor(private http: HttpClient) {
    }

    getAll() {
        return this.http.get(environment.apiUrl + "/profiles");
    }

    getAllForUser(username) {
        return this.http.get(environment.apiUrl + "/profiles/" + username);
    }

    getForUser(username, name) {
        return this.http.get(environment.apiUrl + "/profiles/" + username + "/" + name);
    }

    createOrUpdate(profileModel) {
        return this.http.post(environment.apiUrl + "/profiles", profileModel);
    }

    delete(name) {
        return this.http.delete(environment.apiUrl + "/profiles/" + name);
    }
}