-
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.
- updated adv search dialog
- Loading branch information
Showing
10 changed files
with
141 additions
and
46 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# public_api/api/categories.py | ||
|
||
from typing import List | ||
from public_api.shared_schemas import ProductCategory, ProductCategoryCreate, ProductCategoryUpdate | ||
from .client import APIClient | ||
|
||
class CategoriesAPI: | ||
def __init__(self, client: APIClient): | ||
self.client = client | ||
|
||
def create_category(self, category: ProductCategoryCreate) -> ProductCategory: | ||
response = self.client.post("/product_categories/", json=category.model_dump()) | ||
return ProductCategory.model_validate(response) | ||
|
||
def get_categories(self, skip: int = 0, limit: int = 100) -> List[ProductCategory]: | ||
response = self.client.get(f"/product_categories/?skip={skip}&limit={limit}") | ||
return [ProductCategory.model_validate(item) for item in response] | ||
|
||
def get_category(self, category_id: int) -> ProductCategory: | ||
response = self.client.get(f"/product_categories/{category_id}") | ||
return ProductCategory.model_validate(response) | ||
|
||
def update_category(self, category_id: int, category: ProductCategoryUpdate) -> ProductCategory: | ||
response = self.client.put(f"/product_categories/{category_id}", json=category.model_dump()) | ||
return ProductCategory.model_validate(response) | ||
|
||
def delete_category(self, category_id: int) -> None: | ||
self.client.delete(f"/product_categories/{category_id}") |
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
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
Oops, something went wrong.