All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.app.core.services.campaign-scheduling.service.ts Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-FileCopyrightText: 2017-2024 Enedis
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 */

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { environment } from '@env/environment';
import { HttpClient } from '@angular/common/http';
import { CampaignScheduling } from '@core/model/campaign/campaign-scheduling.model';

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

    private resourceUrl = '/api/ui/campaign/v1/scheduling';

    constructor(private http: HttpClient) { }


    findAll(): Observable> {
        return this.http.get>(environment.backend + this.resourceUrl).pipe(map((res: Array) => {
            return res;
        }));
    }

    create(campaignScheduling: CampaignScheduling): Observable {
        return this.http.post(environment.backend + this.resourceUrl, campaignScheduling);
    }

    delete(id: number): Observable {
        return this.http.delete(environment.backend + `${this.resourceUrl}/${id}`);
    }
}