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

import { JumpTypeResp, JumpTypeReq } from "../models/jumpType";

import { BaseService } from "./base.service";

@Injectable()
export class JumpTypeService extends BaseService {
  constructor(private http: HttpClient) {
    super();
  }

  public getListOfJumpTypes(): Observable<Array<JumpTypeResp>> {
    return this.http.get<Array<JumpTypeResp>>(`${this.apiUrl}/JumpType`, {
      headers: this.headers
    });
  }

  public AddJumpType(jumptypetName: string) {
    const bodyJumpType: JumpTypeReq = {
      id: 0,
      name: jumptypetName
    };

    return this.http.post(`${this.apiUrl}/JumpType`,
                          bodyJumpType, 
                          { headers: this.headers });
  }
}
