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 { IClientModel } from '@fleio-api/client-user/model/client.model';
import { Observable } from 'rxjs/internal/Observable';
import { FleioId } from '@fleio-api/base-model/base-fleio-object.model';

@Injectable({
  providedIn: 'root'
})
export class InvitationsApiService extends FleioApiService<IClientModel> {
  constructor(protected httpClient: HttpClient, protected config: ConfigService) {
    super();
    this.setEndpoint(config.getPanelApiUrl('invitations'));
  }

  acceptInvitation(id: FleioId, token: string): Observable<any> {
    return this.objectPostAction(id, 'accept_invitation', {
      token
    });
  }
}
