All files / libs/tenants/companies/state/src/lib/api-client companies.api-client.ts

50% Statements 12/24
100% Branches 0/0
0% Functions 0/4
50% Lines 12/24

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 251x 1x 1x 1x 1x       1x 1x       1x 1x     1x 1x         1x  
import { http } from '@amalia/core/http/client';
import { type Company, type COMPANY_INTEGRATIONS } from '@amalia/tenants/companies/types';
 
export class CompaniesApiClient {
  public static async getCompany(): Promise<Company> {
    const { data } = await http.get<Company>('/companies');
    return data;
  }
 
  public static async updateCompany(companyToUpdate: Partial<Company>): Promise<Company> {
    const { data } = await http.patch<Company>('/companies', companyToUpdate);
    return data;
  }
 
  public static async registerIntegration(integration: COMPANY_INTEGRATIONS, code: string) {
    await http.post(`/integrations/${integration}/register`, { code });
  }
 
  public static async uploadLogo({ file }: { file: { base64: string; name: string } | null }) {
    const { data: pictureURL } = await http.patch<unknown>('/companies/logo', { file });

    return pictureURL;
  }
}