import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs/Observable";
import { UsersService } from "./users-service";

@Injectable()
export class GamesService{
  public API = "https://tabletoptracker.herokuapp.com";
  public GAMES_API = this.API + "/games";
  public gameId:any;

  constructor(public http: HttpClient){
  }

  getAllGames(){
    return this.http.get(this.GAMES_API);
  }

  getGameById(id: String) {
    return this.http.get(this.GAMES_API+"/id/"+id);
  }

  addGame(game){
    console.log(game);
    return this.http.post(this.GAMES_API,game);
  }

  setGameId(game){
    return this.gameId = game.id;
  }

}