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

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

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

    constructor(private http: HttpClient) {
    }

    get() {
        return this.http.get(environment.apiUrl + "/users/user");
    }

    update(user: any) {
        return this.http.patch(environment.apiUrl + "/users/user", user);
    }

    setPassword(old: string, password: string, password2: string) {
        return this.http.post(environment.apiUrl + "/users/password", { old: old, password: password, password2: password2 });
    }
}