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

0% Statements 0/31
0% Branches 0/1
0% Functions 0/1
0% Lines 0/31

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 31 32                                                               
import { http } from '@amalia/core/http/client';
import { type Relationship, type RelationshipRequest } from '@amalia/payout-definition/plans/types';

export class RelationshipsApiClient {
  public static async list(): Promise<Relationship[]> {
    const { data } = await http.get<Relationship[]>('/relationships');
    return data;
  }

  public static async get(relationshipId: string): Promise<Relationship> {
    const { data } = await http.get<Relationship>(`/relationships/${relationshipId}`);
    return data;
  }

  public static async create(relationship: RelationshipRequest): Promise<Relationship> {
    const { data } = await http.post<Relationship>('/relationships/', relationship);
    return data;
  }

  public static async update(
    relationshipId: Relationship['id'],
    relationshipToUpdate: RelationshipRequest,
  ): Promise<Relationship> {
    const { data } = await http.patch<Relationship>(`/relationships/${relationshipId}`, relationshipToUpdate);
    return data;
  }

  public static async delete(relationshipId: Relationship['id']): Promise<void> {
    await http.delete(`/relationships/${relationshipId}`);
  }
}