src.offers.offers_client_port
Domain model and port for the offers repository.
1"""Domain model and port for the offers repository.""" 2 3from abc import ABC, abstractmethod 4 5from src.offers.models import Offer 6 7class OfferNotFound(Exception): 8 """Error raised when API service returns 404""" 9 10 11class OffersClientError(Exception): 12 """Error raised when API service returns a non-404 error""" 13 14 15class OffersClientPort(ABC): 16 """Port: repository interface for persisting and retrieving offers.""" 17 18 # TODO: Award is not appropriate here. We want a decoupled abstraction. 19 # Maybe something like "CredentialPayload"? That can be built from the Award. 20 # So maybe we can build that here? 21 22 @abstractmethod 23 def create(self, offer_id: str) -> str: 24 """Persist an offer. 25 26 Args: 27 offer: The offer to store. 28 29 Returns: 30 The offer URI 31 """ 32 ... 33 34 @abstractmethod 35 def get(self, offer_id: str) -> Offer: 36 """Retrieve an offer by its identifier. 37 38 Args: 39 offer_id: The unique offer identifier. 40 41 Returns: 42 The matching Offer. 43 44 Raises: 45 KeyError: When no offer with the given id exists. 46 """ 47 ...
class
OfferNotFound(builtins.Exception):
Error raised when API service returns 404
class
OffersClientError(builtins.Exception):
12class OffersClientError(Exception): 13 """Error raised when API service returns a non-404 error"""
Error raised when API service returns a non-404 error
class
OffersClientPort(abc.ABC):
16class OffersClientPort(ABC): 17 """Port: repository interface for persisting and retrieving offers.""" 18 19 # TODO: Award is not appropriate here. We want a decoupled abstraction. 20 # Maybe something like "CredentialPayload"? That can be built from the Award. 21 # So maybe we can build that here? 22 23 @abstractmethod 24 def create(self, offer_id: str) -> str: 25 """Persist an offer. 26 27 Args: 28 offer: The offer to store. 29 30 Returns: 31 The offer URI 32 """ 33 ... 34 35 @abstractmethod 36 def get(self, offer_id: str) -> Offer: 37 """Retrieve an offer by its identifier. 38 39 Args: 40 offer_id: The unique offer identifier. 41 42 Returns: 43 The matching Offer. 44 45 Raises: 46 KeyError: When no offer with the given id exists. 47 """ 48 ...
Port: repository interface for persisting and retrieving offers.
@abstractmethod
def
create(self, offer_id: str) -> str:
23 @abstractmethod 24 def create(self, offer_id: str) -> str: 25 """Persist an offer. 26 27 Args: 28 offer: The offer to store. 29 30 Returns: 31 The offer URI 32 """ 33 ...
Persist an offer.
Args: offer: The offer to store.
Returns: The offer URI
35 @abstractmethod 36 def get(self, offer_id: str) -> Offer: 37 """Retrieve an offer by its identifier. 38 39 Args: 40 offer_id: The unique offer identifier. 41 42 Returns: 43 The matching Offer. 44 45 Raises: 46 KeyError: When no offer with the given id exists. 47 """ 48 ...
Retrieve an offer by its identifier.
Args: offer_id: The unique offer identifier.
Returns: The matching Offer.
Raises: KeyError: When no offer with the given id exists.