import { Injectable } from '@angular/core';
import { ConfigService } from '@shared/config/config.service';
import { FleioApiService } from '../../fleio-api.service';
import { HttpClient } from '@angular/common/http';
import { IOrderModel } from '../model/order.model';
import { Observable } from 'rxjs';
import { FleioId } from '@fleio-api/base-model/base-fleio-object.model';

@Injectable({
  providedIn: 'root'
})
export class OrdersApiService extends FleioApiService<IOrderModel> {
  // noinspection JSUnusedGlobalSymbols
  constructor(protected httpClient: HttpClient, protected config: ConfigService) {
    super();
    this.setEndpoint(config.getPanelApiUrl('billing/orders'));
  }

  accept(orderId: FleioId): Observable<any> {
    return this.objectPostAction(orderId, 'accept', {});
  }

  cancel(orderId: FleioId): Observable<any> {
    return this.objectPostAction(orderId, 'cancel', {});
  }

  verify(orderId: FleioId): Observable<any> {
    return this.objectPostAction(orderId, 'verify', {});
  }

  setPending(orderId: FleioId): Observable<any> {
    return this.objectPostAction(orderId, 'pending', {});
  }
}
