Skip to content

Commit

Permalink
chore: indent
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrodrigo19 committed Oct 16, 2024
1 parent 9121186 commit 1661f9e
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 21 deletions.
23 changes: 15 additions & 8 deletions mock-payment-server/server.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
from pydantic import BaseModel
import uvicorn
from fastapi import Body, FastAPI, Request
from typing import Annotated, Literal

import httpx
import uvicorn
from fastapi import Body, FastAPI
from pydantic import BaseModel

fake_db = {}


async def set_webhook_url_for_user_payment(user_id: int, webhook_url: str):
fake_db[user_id] = webhook_url


async def get_webhook_urls():
return list(fake_db.values())


class Payment(BaseModel):
user_id: str
user_amount: float
total_sale_amount: float


class WebHookResponse(BaseModel):
status: Literal["ok", "error"]


app = FastAPI()


@app.webhooks.post("payment-status-webhook")
async def payment_webhook(paymeny_data: Payment):
"""_summary_
Expand All @@ -33,7 +39,7 @@ async def payment_webhook(paymeny_data: Payment):
Args:
paymeny_data (Payment): _description_
"""

pass


Expand All @@ -59,11 +65,11 @@ async def user_paymeny(paymeny_info: Payment):
result = "ok"
else:
result = "error"

notification_data = {
"payment_status": result
}

webhook_urls = await get_webhook_urls()
async with httpx.AsyncClient() as client:
for webhook_url in webhook_urls:
Expand All @@ -72,5 +78,6 @@ async def user_paymeny(paymeny_info: Payment):
print(f"Failed to send notification to {webhook_url}")
return notification_data


if __name__ == "__main__":
uvicorn.run("server:app", host="127.0.0.1", port=8001, reload=True)
uvicorn.run("server:app", host="127.0.0.1", port=8001, reload=True)
4 changes: 2 additions & 2 deletions src/api/presentation/http/http.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from fastapi import FastAPI

from src.api.presentation.routes.health import health
from src.api.presentation.routes.products import products
from src.api.presentation.routes.cart import cart
from src.api.presentation.routes.client import client
from src.api.presentation.routes.health import health
from src.api.presentation.routes.products import products

app = FastAPI()
app.include_router(products.router, tags=["products"])
Expand Down
1 change: 1 addition & 0 deletions src/api/presentation/routes/cart/cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async def get_order_by_id(id: str) -> OrderResponseDto:
logger.exception(f"Server Error | {id=}")
raise HTTPException(status_code=500, detail=exc.args)


@router.put("/api/v1/order/{id}/status")
async def update_order_status(id: str, new_status: str) -> OrderResponseDto:
try:
Expand Down
4 changes: 2 additions & 2 deletions src/cart/adapters/postgres_gateway.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import List

from cart.domain.entities.order_product import OrderProduct
from product.domain.entities.product import Product
from src.cart.domain.entities.order import Order
from src.cart.domain.entities.order_product import OrderProduct
from src.cart.domain.enums.paymentConditions import PaymentConditions
from src.cart.ports.cart_gateway import ICartGateway
from src.cart.ports.unit_of_work_interface import ICartUnitOfWork
from src.product.domain.entities.product import Product


class PostgreSqlOrderGateway(ICartGateway):
Expand Down
2 changes: 1 addition & 1 deletion src/cart/adapters/postgresql_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.orm import Session

from product.adapters.product_table import ProductTable
from src.cart.adapters.order_table import OrderTable, OrderProductTable
from src.cart.ports.repository_interface import IRepository
from src.product.adapters.product_table import ProductTable


class PostgreSqlRepository(IRepository):
Expand Down
2 changes: 1 addition & 1 deletion src/cart/adapters/pydantic_presenter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import List

from cart.domain.enums.order_status import OrderStatus
from src.api.presentation.shared.dtos.order_response_dto import OrderResponseDto, OrderProductResponseDto
from src.cart.domain.entities.order import Order
from src.cart.domain.enums.order_status import OrderStatus
from src.cart.ports.cart_presenter import ICartPresenter


Expand Down
1 change: 0 additions & 1 deletion src/product/adapters/postgresql_uow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ProductPostgreSqlUow(IProductUnitOfWork):
def __init__(self, session_factory):
self.session_factory = session_factory()


def __enter__(self):
self.session: Session = self.session_factory
self.repository = PostgreSqlProductRepository(session=self.session)
Expand Down
2 changes: 1 addition & 1 deletion src/product/domain/validators/product_validator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from src.product.domain_exception import ProductDomainException
from src.api.presentation.shared.enums.categories import Categories
from src.product.domain_exception import ProductDomainException


class ProductValidator:
Expand Down
1 change: 0 additions & 1 deletion src/product/ports/product_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def get_products(self) -> List[Product]:
@abstractmethod
def get_product_by_sku(self, sku: str) -> Product:
...


@abstractmethod
def create_update_product(self, product: Product) -> Product:
Expand Down
3 changes: 0 additions & 3 deletions src/product/ports/repository_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@


class IProductRepository(ABC):
"""
Repository interface definition for all repositories.
"""

@abstractmethod
def get_all(self) -> List[Dict]:
Expand Down
1 change: 0 additions & 1 deletion tests/in_memory_repository.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Dict


from src.product.ports.repository_interface import IProductRepository


Expand Down

0 comments on commit 1661f9e

Please sign in to comment.