import * as O from 'fp-ts/Option';
import { BackendApiClient } from '../../../apis/api-client';
export class ManageBenefitsApi {
  async getPageStateAsync() {
    return BackendApiClient.instance.url(`benefits/ui/manage-page`).get().json();
  }
  async loadBenefitForEditingAsync(benefitId) {
    return BackendApiClient.instance.url(`benefits/edit/${benefitId}`).get().json();
  }
  async postCommandAsync(benefitId, commandDto) {
    const request = {
      command: commandDto
    };
    return BackendApiClient.instance
      .url(`benefits/edit/${O.getOrElse(() => '')(benefitId)}`)
      .post(request)
      .badRequest(() => {
      throw new Error('Failed to execute benefit command');
    })
      .text();
  }
}
export default new ManageBenefitsApi();
