-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
86 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/recommendation_engine/app/domain/menu/values/getir/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .menu import GetirMenuValue |
64 changes: 64 additions & 0 deletions
64
src/recommendation_engine/app/domain/menu/values/getir/menu.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from pydantic import HttpUrl | ||
from dataclasses import dataclass | ||
|
||
from ..price import Price | ||
from ..menu import MenuValue | ||
|
||
|
||
@dataclass(frozen=True) | ||
class GetirMenuValue(MenuValue): | ||
category: str | ||
product_id: str | ||
name: str | ||
price: Price | ||
description: str | ||
image_url: str | None | ||
full_screen_image_url: str | None | ||
is_available: bool | ||
|
||
def validate_category(self) -> str: | ||
if not isinstance(self.category, str): | ||
raise ValueError("Invalid comment category type expected.") | ||
return self.category | ||
|
||
def validate_product_id(self) -> str: | ||
if not isinstance(self.product_id, str): | ||
raise ValueError("Invalid comment product id type expected.") | ||
return self.product_id | ||
|
||
def validate_name(self) -> str: | ||
if not isinstance(self.name, str): | ||
raise ValueError("Invalid comment name type expected.") | ||
return self.name | ||
|
||
def validate_price(self) -> Price: | ||
if not isinstance(self.price, str): | ||
raise ValueError("Invalid comment price type expected.") | ||
|
||
amount = self.price.replace("₺", "").replace(",", ".").strip() | ||
amount = float(amount) | ||
return Price(amount=amount, currency="TL") | ||
|
||
def validate_description(self) -> str: | ||
if not isinstance(self.description, str): | ||
raise ValueError("Invalid comment description type expected.") | ||
return self.description | ||
|
||
def validate_image_url(self) -> str | None: | ||
if not isinstance(self.image_url, str): | ||
raise ValueError("Invalid comment image url type expected.") | ||
if len(self.image_url) == 0: | ||
return None | ||
return str(HttpUrl(self.image_url)) | ||
|
||
def validate_full_screen_image_url(self) -> str | None: | ||
if not isinstance(self.full_screen_image_url, str): | ||
raise ValueError("Invalid comment full_screen_image_url type expected.") | ||
if len(self.full_screen_image_url) == 0: | ||
return None | ||
return str(HttpUrl(self.full_screen_image_url)) | ||
|
||
def validate_is_available(self) -> bool: | ||
if not isinstance(self.is_available, bool): | ||
raise ValueError("Invalid comment is available type expected.") | ||
return self.is_available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,8 @@ | ||
from pydantic import HttpUrl | ||
from dataclasses import dataclass | ||
|
||
from .price import Price | ||
from ...mixins import DataclassValidationMixin | ||
|
||
|
||
@dataclass(frozen=True) | ||
class MenuValue(DataclassValidationMixin): | ||
category: str | ||
product_id: str | ||
name: str | ||
price: Price | ||
description: str | ||
image_url: str | None | ||
full_screen_image_url: str | None | ||
is_available: bool | ||
|
||
def validate_category(self) -> str: | ||
if not isinstance(self.category, str): | ||
raise ValueError("Invalid comment category type expected.") | ||
return self.category | ||
|
||
def validate_product_id(self) -> str: | ||
if not isinstance(self.product_id, str): | ||
raise ValueError("Invalid comment product id type expected.") | ||
return self.product_id | ||
|
||
def validate_name(self) -> str: | ||
if not isinstance(self.name, str): | ||
raise ValueError("Invalid comment name type expected.") | ||
return self.name | ||
|
||
def validate_price(self) -> Price: | ||
if not isinstance(self.price, str): | ||
raise ValueError("Invalid comment price type expected.") | ||
|
||
amount = self.price.replace("₺", "").replace(",", ".").strip() | ||
amount = float(amount) | ||
return Price(amount=amount, currency="TL") | ||
|
||
def validate_description(self) -> str: | ||
if not isinstance(self.description, str): | ||
raise ValueError("Invalid comment description type expected.") | ||
return self.description | ||
|
||
def validate_image_url(self) -> str | None: | ||
if not isinstance(self.image_url, str): | ||
raise ValueError("Invalid comment image url type expected.") | ||
if len(self.image_url) == 0: | ||
return None | ||
return str(HttpUrl(self.image_url)) | ||
|
||
def validate_full_screen_image_url(self) -> str | None: | ||
if not isinstance(self.full_screen_image_url, str): | ||
raise ValueError("Invalid comment full_screen_image_url type expected.") | ||
if len(self.full_screen_image_url) == 0: | ||
return None | ||
return str(HttpUrl(self.full_screen_image_url)) | ||
|
||
def validate_is_available(self) -> bool: | ||
if not isinstance(self.is_available, bool): | ||
raise ValueError("Invalid comment is available type expected.") | ||
return self.is_available | ||
pass |
19 changes: 0 additions & 19 deletions
19
src/recommendation_engine/app/domain/menu/values/menu_stack.py
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
src/recommendation_engine/app/domain/menu/values/request_value.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters