All files / libs/payout-definition/state/src/lib/periods periods.api-client.ts

32% Statements 8/25
100% Branches 0/0
0% Functions 0/2
32% Lines 8/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261x 1x 1x 1x 1x                             1x 1x       1x  
import { http } from '@amalia/core/http/client';
import { type Period, type PeriodFrequencyEnum } from '@amalia/payout-definition/periods/types';
 
export class PeriodsApiClient {
  public static async getPeriodByDate({
    dateString,
    frequency,
  }: {
    dateString: string;
    frequency: PeriodFrequencyEnum;
  }): Promise<Period> {
    const { data: period } = await http.get<Period>(`/periods/${encodeURIComponent(dateString)}`, {
      params: {
        shouldCreate: true,
        frequency,
      },
    });
    return period;
  }
 
  public static async getAllPeriods(): Promise<Period[]> {
    const { data: period } = await http.get<Period[]>('/periods');
    return period;
  }
}