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.awards.models import Award
 6
 7from .models import Offer
 8
 9
10class OfferNotFound(Exception):
11    """Error raised when API service returns 404"""
12
13
14class OffersClientError(Exception):
15    """Error raised when API service returns a non-404 error"""
16
17
18class OffersClientPort(ABC):
19    """Port: repository interface for persisting and retrieving offers."""
20
21    @abstractmethod
22    def create(self, offer_id: str, award: Award) -> str:
23        """Create a credential offer on the SSI agent.
24
25        Args:
26            offer_id: The offer identifier to create.
27            award: The award (OB3 AchievementCredential) for this offer.
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            OfferNotFound: When no offer with the given id exists.
46            OffersClientError: When the upstream service returns an error.
47        """
48        ...
class OfferNotFound(builtins.Exception):
11class OfferNotFound(Exception):
12    """Error raised when API service returns 404"""

Error raised when API service returns 404

class OffersClientError(builtins.Exception):
15class OffersClientError(Exception):
16    """Error raised when API service returns a non-404 error"""

Error raised when API service returns a non-404 error

class OffersClientPort(abc.ABC):
19class OffersClientPort(ABC):
20    """Port: repository interface for persisting and retrieving offers."""
21
22    @abstractmethod
23    def create(self, offer_id: str, award: Award) -> str:
24        """Create a credential offer on the SSI agent.
25
26        Args:
27            offer_id: The offer identifier to create.
28            award: The award (OB3 AchievementCredential) for this offer.
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            OfferNotFound: When no offer with the given id exists.
47            OffersClientError: When the upstream service returns an error.
48        """
49        ...

Port: repository interface for persisting and retrieving offers.

@abstractmethod
def create(self, offer_id: str, award: src.awards.models.Award) -> str:
22    @abstractmethod
23    def create(self, offer_id: str, award: Award) -> str:
24        """Create a credential offer on the SSI agent.
25
26        Args:
27            offer_id: The offer identifier to create.
28            award: The award (OB3 AchievementCredential) for this offer.
29
30        Returns:
31            The offer URI.
32        """
33        ...

Create a credential offer on the SSI agent.

Args: offer_id: The offer identifier to create. award: The award (OB3 AchievementCredential) for this offer.

Returns: The offer URI.

@abstractmethod
def get(self, offer_id: str) -> src.offers.models.Offer:
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            OfferNotFound: When no offer with the given id exists.
47            OffersClientError: When the upstream service returns an error.
48        """
49        ...

Retrieve an offer by its identifier.

Args: offer_id: The unique offer identifier.

Returns: The matching Offer.

Raises: OfferNotFound: When no offer with the given id exists. OffersClientError: When the upstream service returns an error.