Skip to content

Commit

Permalink
(PC-33516)[API] feat: remove ProviderAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoudray-pass committed Jan 10, 2025
1 parent c0219bd commit 989ead4
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 314 deletions.
22 changes: 0 additions & 22 deletions api/src/pcapi/core/providers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from pcapi.core.offerers.models import Venue
import pcapi.core.providers.constants as provider_constants
from pcapi.infrastructure.repository.stock_provider.provider_api import ProviderAPI
from pcapi.models import Base
from pcapi.models import Model
from pcapi.models.deactivable_mixin import DeactivableMixin
Expand Down Expand Up @@ -85,17 +84,6 @@ def hasProviderEnableCharlie(self) -> bool:
def hasOffererProvider(self) -> bool:
return bool(self.offererProvider)

@property
def implements_provider_api(self) -> bool:
return self.apiUrl is not None and not self.offererProvider

def getProviderAPI(self) -> ProviderAPI:
return ProviderAPI(
api_url=self.apiUrl, # type: ignore[arg-type]
name=self.name,
authentication_token=self.authToken,
)


class VenueProviderExternalUrls(PcObject, Base, Model, DeactivableMixin):
"""
Expand Down Expand Up @@ -279,16 +267,6 @@ class VenueProviderCreationPayload:
venueIdAtOfferProvider: str | None = None


@dataclass
class StockDetail:
products_provider_reference: str
offers_provider_reference: str
venue_reference: str
stocks_provider_reference: str
available_quantity: int
price: decimal.Decimal


class AllocinePivot(PcObject, Base, Model):
venueId: int = sa.Column(sa.BigInteger, sa.ForeignKey("venue.id"), index=False, nullable=False, unique=True)

Expand Down
Empty file.
143 changes: 0 additions & 143 deletions api/src/pcapi/infrastructure/repository/stock_provider/provider_api.py

This file was deleted.

16 changes: 2 additions & 14 deletions api/src/pcapi/local_providers/provider_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from pcapi.core.providers import repository as providers_repository
from pcapi.core.providers.api import update_venue_synchronized_offers_active_status_job
from pcapi.core.providers.constants import CINEMA_PROVIDER_NAMES
from pcapi.infrastructure.repository.stock_provider import provider_api
import pcapi.local_providers
from pcapi.local_providers.cinema_providers.ems.ems_stocks import EMSStocks
from pcapi.models import db
Expand Down Expand Up @@ -58,12 +57,7 @@ def synchronize_venue_providers(venue_providers: list[provider_models.VenueProvi
synchronize_venue_provider(venue_provider, limit)
except (urllib3_exceptions.HTTPError, requests.exceptions.RequestException) as exception:
logger.error("Connexion error while synchronizing venue_provider", extra=log_data | {"exc": exception})
except provider_api.ProviderAPIException as exception:
logger.error( # pylint: disable=logging-fstring-interpolation
f"ProviderAPIException with code {exception.status_code} while synchronizing venue_provider",
extra=log_data | {"exc": exception},
)
except Exception as exception: # pylint: disable=broad-except
except Exception: # pylint: disable=broad-except
logger.exception("Unexpected error while synchronizing venue provider", extra=log_data)


Expand Down Expand Up @@ -129,13 +123,7 @@ def synchronize_ems_venue_providers(from_last_version: bool = False) -> None:
except (urllib3_exceptions.HTTPError, requests.exceptions.RequestException) as exception:
logger.error("Connexion error while synchronizing venue_provider", extra=log_data | {"exc": exception})
venues_provider_to_sync.discard(venue_provider.id)
except provider_api.ProviderAPIException as exception:
logger.error( # pylint: disable=logging-fstring-interpolation
f"ProviderAPIException with code {exception.status_code} while synchronizing venue_provider",
extra=log_data | {"exc": exception},
)
venues_provider_to_sync.discard(venue_provider.id)
except Exception as exception: # pylint: disable=broad-except
except Exception: # pylint: disable=broad-except
logger.exception("Unexpected error while synchronizing venue provider", extra=log_data)
venues_provider_to_sync.discard(venue_provider.id)

Expand Down
5 changes: 0 additions & 5 deletions api/tests/core/providers/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,10 @@ def test_prevent_creation_for_non_existing_provider(self):
(offerers_models.VenueTypeCode.DIGITAL, False),
),
)
@patch(
"pcapi.infrastructure.repository.stock_provider.provider_api.ProviderAPI.is_siret_registered",
return_value=True,
)
@patch("pcapi.core.search.async_index_venue_ids")
def test_permanent_venue_marking(
self,
mocked_async_index_venue_ids,
_unused_mock,
venue_type,
is_permanent,
):
Expand Down
Empty file.

This file was deleted.

0 comments on commit 989ead4

Please sign in to comment.