import {Injectable} from "@angular/core"; import {AppConfig} from "../../app.config"; import {HttpClient} from "../http-client"; import {Promotion} from "../../models/model-interfaces"; @Injectable() export class PromotionService { constructor(private http: HttpClient, private config: AppConfig) { } getUnconfirmedPromotions(fraction?: string) { return this.http.get(this.config.apiUrl + this.config.apiPromotionPath + '?inProgress=true&fractFilter=' + fraction) .map(res => res.json()) } getSquadPromotions(squadId: string) { return this.http.get(this.config.apiUrl + this.config.apiPromotionPath + '?squadId=' + squadId) .map(res => res.json()) } requestPromotion(promotion: Promotion) { return this.http.post(this.config.apiUrl + this.config.apiPromotionPath, promotion) } updatePromotion(promotion) { return this.http.patch(this.config.apiUrl + this.config.apiPromotionPath + '/' + promotion._id, promotion) .map(res => res.json()) } deletePromotion(promotionId) { return this.http.delete(this.config.apiUrl + this.config.apiPromotionPath + promotionId) } }