Coverage for src/henrri_connect/companies/asynchro.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-05 10:54 +0200

1""" 

2Sous-client pour les endpoints /v1/companies. 

3 

4Constantes: 

5- ``COMPANIES_ENDPOINT`` URL de base des endpoints entreprises (/v1/companies). 

6 

7Classes: 

8- ``henrri_connect.companies.asynchro.AsyncCompaniesClient`` 

9 Accès asynchrone aux endpoints entreprises. 

10 

11Notes: 

12- Utiliser de préférence l'objet ``henrri_connect.connect.AsyncHenrriClient`` pour acceder 

13aux endpoints. 

14""" 

15 

16from __future__ import annotations 

17 

18from typing import TYPE_CHECKING 

19 

20from ..models import Address, Company 

21 

22if TYPE_CHECKING: 

23 from ..connect import AsyncHenrriClient 

24 

25COMPANIES_ENDPOINT = "/v1/companies" 

26 

27class AsyncCompaniesClient: 

28 """ 

29 Accès asynchrone aux endpoints entreprises. 

30 

31 Arguments 

32 - ``client`` (AsyncHenrriClient) : Client Henrri Connect. 

33 

34 Methodes 

35 - get(self, company_id: int) : Récupère une entreprise par son identifiant. 

36 - get_address(self, company_id: int) : Récupère l'adresse d'une entreprise. 

37 """ 

38 

39 def __init__(self, client: AsyncHenrriClient) -> None: 

40 self._c = client 

41 

42 async def get(self, company_id: int) -> Company: 

43 """ 

44 Récupère une entreprise par son identifiant. 

45 

46 Arguments 

47 - ``company_id`` : Identifiant de l'entreprise. 

48 

49 Returns 

50 - ``henrri_connect.models.Company`` : Entreprise. 

51 """ 

52 resp = await self._c.request("GET", f"{COMPANIES_ENDPOINT}/{company_id}") 

53 return Company.model_validate(resp.json()) 

54 

55 async def get_address(self, company_id: int) -> Address: 

56 """ 

57 Récupère l'adresse d'une entreprise. 

58 

59 Arguments 

60 - ``company_id`` : Identifiant de l'entreprise. 

61 

62 Returns 

63 - ``henrri_connect.models.Address`` : Adresse de l'entreprise. 

64 """ 

65 resp = await self._c.request("GET", f"{COMPANIES_ENDPOINT}/{company_id}/address") 

66 return Address.model_validate(resp.json())