import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs/Observable";
import {Injectable} from "@angular/core";


export class User{
  id: number;
  name: string;
  email: string;

  constructor(id:number,name: string, email: string){
    this.id = id;
    this.name = name;
    this.email = email;
  }
}

@Injectable()
export class UserService{


  public API = "http://localhost:8080";
  public USER_API = this.API + "/users";

  constructor(public http: HttpClient) {
  }

  get(id: string) {
    return this.http.get(this.USER_API + '/' + id);
  }

  getUsers(): Observable<any> {
    return this.http.get(this.USER_API);
  }

  getUser(id: number): Observable<any> {
    return this.http.get(this.USER_API + "/" + id);
  }
}
