All files / src/services/api/routers BudgetRouter.tsx

83.33% Statements 5/6
80% Branches 4/5
100% Functions 2/2
83.33% Lines 5/6

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 26 27 28 29 30                                  2209x       2209x 9x 9x 9x          
import type { Budgets } from "@/objects/Budget";
import { Dictionary } from "@/types/ext";
import { AxiosRequestConfig } from "axios";
import { APIRouter } from "../ApiRouter";
 
/**
 * Budgets (svc-core `/app/budgets`): where every cost cap governing the
 * request's workspace stands. A budget is created as a `cost_cap` rule,
 * through the rule router.
 */
export class BudgetRouter extends APIRouter {
  constructor(
    host: string,
    token: string | null = null,
    default_config: AxiosRequestConfig | null = null,
    headers: Dictionary<string> = {},
  ) {
    super("budgets", host, token, default_config, headers);
  }
 
  /** Every budget governing the workspace, worst first, and its month. */
  list = async (): Promise<Budgets | null> => {
    const res = await this.api.get<Budgets>(super.endpoint(""));
    Eif (super.validRes(res)) {
      return res.data;
    }
    return null;
  };
}