refactor(api): introduce UserContext schema for API dependency injection
Replace direct User database model imports in API endpoints with UserContext schema, following the architecture principle that API routes should not import database models directly. Changes: - Create UserContext schema in models/schema/auth.py with from_user() factory - Update app/api/deps.py to return UserContext from all auth dependencies - Add _get_user_model() helper for functions needing User model access - Update 58 API endpoint files to use UserContext instead of User - Add noqa comments for 4 legitimate edge cases (enums, internal helpers) Architecture validation: 0 errors (down from 61), 11 warnings remain Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
4
app/api/v1/vendor/analytics.py
vendored
4
app/api/v1/vendor/analytics.py
vendored
@@ -20,7 +20,7 @@ from app.core.database import get_db
|
||||
from app.core.feature_gate import RequireFeature
|
||||
from app.services.stats_service import stats_service
|
||||
from app.modules.billing.models import FeatureCode
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.analytics.schemas import (
|
||||
VendorAnalyticsCatalog,
|
||||
VendorAnalyticsImports,
|
||||
@@ -35,7 +35,7 @@ logger = logging.getLogger(__name__)
|
||||
@router.get("", response_model=VendorAnalyticsResponse)
|
||||
def get_vendor_analytics(
|
||||
period: str = Query("30d", description="Time period: 7d, 30d, 90d, 1y"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
_: None = Depends(RequireFeature(FeatureCode.BASIC_REPORTS, FeatureCode.ANALYTICS_DASHBOARD)),
|
||||
):
|
||||
|
||||
4
app/api/v1/vendor/auth.py
vendored
4
app/api/v1/vendor/auth.py
vendored
@@ -24,7 +24,7 @@ from app.core.environment import should_use_secure_cookies
|
||||
from app.exceptions import InvalidCredentialsException
|
||||
from app.services.auth_service import auth_service
|
||||
from middleware.vendor_context import get_current_vendor
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from models.schema.auth import LogoutResponse, UserLogin, VendorUserResponse
|
||||
|
||||
router = APIRouter(prefix="/auth")
|
||||
@@ -179,7 +179,7 @@ def vendor_logout(response: Response):
|
||||
|
||||
@router.get("/me", response_model=VendorUserResponse)
|
||||
def get_current_vendor_user(
|
||||
user: User = Depends(get_current_vendor_api), db: Session = Depends(get_db)
|
||||
user: UserContext = Depends(get_current_vendor_api), db: Session = Depends(get_db)
|
||||
):
|
||||
"""
|
||||
Get current authenticated vendor user.
|
||||
|
||||
28
app/api/v1/vendor/billing.py
vendored
28
app/api/v1/vendor/billing.py
vendored
@@ -21,7 +21,7 @@ from app.core.config import settings
|
||||
from app.core.database import get_db
|
||||
from app.services.billing_service import billing_service
|
||||
from app.services.subscription_service import subscription_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
router = APIRouter(prefix="/billing")
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -217,7 +217,7 @@ class AddOnCancelResponse(BaseModel):
|
||||
|
||||
@router.get("/subscription", response_model=SubscriptionStatusResponse)
|
||||
def get_subscription_status(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get current subscription status and usage metrics."""
|
||||
@@ -260,7 +260,7 @@ def get_subscription_status(
|
||||
|
||||
@router.get("/tiers", response_model=TierListResponse)
|
||||
def get_available_tiers(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get available subscription tiers for upgrade/downgrade."""
|
||||
@@ -278,7 +278,7 @@ def get_available_tiers(
|
||||
@router.post("/checkout", response_model=CheckoutResponse)
|
||||
def create_checkout_session(
|
||||
request: CheckoutRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Create a Stripe checkout session for subscription."""
|
||||
@@ -305,7 +305,7 @@ def create_checkout_session(
|
||||
|
||||
@router.post("/portal", response_model=PortalResponse)
|
||||
def create_portal_session(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Create a Stripe customer portal session."""
|
||||
@@ -322,7 +322,7 @@ def create_portal_session(
|
||||
def get_invoices(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(20, ge=1, le=100),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get invoice history."""
|
||||
@@ -352,7 +352,7 @@ def get_invoices(
|
||||
@router.get("/addons", response_model=list[AddOnResponse])
|
||||
def get_available_addons(
|
||||
category: str | None = Query(None, description="Filter by category"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get available add-on products."""
|
||||
@@ -376,7 +376,7 @@ def get_available_addons(
|
||||
|
||||
@router.get("/my-addons", response_model=list[VendorAddOnResponse])
|
||||
def get_vendor_addons(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get vendor's purchased add-ons."""
|
||||
@@ -402,7 +402,7 @@ def get_vendor_addons(
|
||||
@router.post("/cancel", response_model=CancelResponse)
|
||||
def cancel_subscription(
|
||||
request: CancelRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Cancel subscription."""
|
||||
@@ -424,7 +424,7 @@ def cancel_subscription(
|
||||
|
||||
@router.post("/reactivate")
|
||||
def reactivate_subscription(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Reactivate a cancelled subscription."""
|
||||
@@ -438,7 +438,7 @@ def reactivate_subscription(
|
||||
|
||||
@router.get("/upcoming-invoice", response_model=UpcomingInvoiceResponse)
|
||||
def get_upcoming_invoice(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Preview the upcoming invoice."""
|
||||
@@ -457,7 +457,7 @@ def get_upcoming_invoice(
|
||||
@router.post("/change-tier", response_model=ChangeTierResponse)
|
||||
def change_tier(
|
||||
request: ChangeTierRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Change subscription tier (upgrade/downgrade)."""
|
||||
@@ -481,7 +481,7 @@ def change_tier(
|
||||
@router.post("/addons/purchase")
|
||||
def purchase_addon(
|
||||
request: AddOnPurchaseRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Purchase an add-on product."""
|
||||
@@ -510,7 +510,7 @@ def purchase_addon(
|
||||
@router.delete("/addons/{addon_id}", response_model=AddOnCancelResponse)
|
||||
def cancel_addon(
|
||||
addon_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Cancel a purchased add-on."""
|
||||
|
||||
14
app/api/v1/vendor/customers.py
vendored
14
app/api/v1/vendor/customers.py
vendored
@@ -14,7 +14,7 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.customer_service import customer_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.customers.schemas import (
|
||||
CustomerDetailResponse,
|
||||
CustomerMessageResponse,
|
||||
@@ -35,7 +35,7 @@ def get_vendor_customers(
|
||||
limit: int = Query(100, ge=1, le=1000),
|
||||
search: str | None = Query(None),
|
||||
is_active: bool | None = Query(None),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -66,7 +66,7 @@ def get_vendor_customers(
|
||||
@router.get("/{customer_id}", response_model=CustomerDetailResponse)
|
||||
def get_customer_details(
|
||||
customer_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -112,7 +112,7 @@ def get_customer_orders(
|
||||
customer_id: int,
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=100),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -152,7 +152,7 @@ def get_customer_orders(
|
||||
def update_customer(
|
||||
customer_id: int,
|
||||
customer_data: CustomerUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -177,7 +177,7 @@ def update_customer(
|
||||
@router.put("/{customer_id}/status", response_model=CustomerMessageResponse)
|
||||
def toggle_customer_status(
|
||||
customer_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -202,7 +202,7 @@ def toggle_customer_status(
|
||||
@router.get("/{customer_id}/stats", response_model=CustomerStatisticsResponse)
|
||||
def get_customer_statistics(
|
||||
customer_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
4
app/api/v1/vendor/dashboard.py
vendored
4
app/api/v1/vendor/dashboard.py
vendored
@@ -16,7 +16,7 @@ from app.core.database import get_db
|
||||
from app.exceptions import VendorNotActiveException
|
||||
from app.services.stats_service import stats_service
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.analytics.schemas import (
|
||||
VendorCustomerStats,
|
||||
VendorDashboardStatsResponse,
|
||||
@@ -33,7 +33,7 @@ logger = logging.getLogger(__name__)
|
||||
@router.get("/stats", response_model=VendorDashboardStatsResponse)
|
||||
def get_vendor_dashboard_stats(
|
||||
request: Request,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
14
app/api/v1/vendor/email_settings.py
vendored
14
app/api/v1/vendor/email_settings.py
vendored
@@ -22,7 +22,7 @@ from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.vendor_email_settings_service import VendorEmailSettingsService
|
||||
from app.services.subscription_service import subscription_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
router = APIRouter(prefix="/email-settings")
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -128,7 +128,7 @@ class EmailDeleteResponse(BaseModel):
|
||||
|
||||
@router.get("", response_model=EmailSettingsResponse)
|
||||
def get_email_settings(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
) -> EmailSettingsResponse:
|
||||
"""
|
||||
@@ -156,7 +156,7 @@ def get_email_settings(
|
||||
|
||||
@router.get("/status", response_model=EmailStatusResponse)
|
||||
def get_email_status(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
) -> EmailStatusResponse:
|
||||
"""
|
||||
@@ -172,7 +172,7 @@ def get_email_status(
|
||||
|
||||
@router.get("/providers", response_model=ProvidersResponse)
|
||||
def get_available_providers(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
) -> ProvidersResponse:
|
||||
"""
|
||||
@@ -195,7 +195,7 @@ def get_available_providers(
|
||||
@router.put("", response_model=EmailUpdateResponse)
|
||||
def update_email_settings(
|
||||
data: EmailSettingsUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
) -> EmailUpdateResponse:
|
||||
"""
|
||||
@@ -229,7 +229,7 @@ def update_email_settings(
|
||||
@router.post("/verify", response_model=EmailVerifyResponse)
|
||||
def verify_email_settings(
|
||||
data: VerifyEmailRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
) -> EmailVerifyResponse:
|
||||
"""
|
||||
@@ -254,7 +254,7 @@ def verify_email_settings(
|
||||
|
||||
@router.delete("", response_model=EmailDeleteResponse)
|
||||
def delete_email_settings(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
) -> EmailDeleteResponse:
|
||||
"""
|
||||
|
||||
16
app/api/v1/vendor/email_templates.py
vendored
16
app/api/v1/vendor/email_templates.py
vendored
@@ -20,7 +20,7 @@ from app.core.database import get_db
|
||||
from app.services.email_service import EmailService
|
||||
from app.services.email_template_service import EmailTemplateService
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
router = APIRouter(prefix="/email-templates")
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -62,7 +62,7 @@ class TemplateTestRequest(BaseModel):
|
||||
|
||||
@router.get("")
|
||||
def list_overridable_templates(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -79,7 +79,7 @@ def list_overridable_templates(
|
||||
@router.get("/{code}")
|
||||
def get_template(
|
||||
code: str,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -96,7 +96,7 @@ def get_template(
|
||||
def get_template_language(
|
||||
code: str,
|
||||
language: str,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -114,7 +114,7 @@ def update_template_override(
|
||||
code: str,
|
||||
language: str,
|
||||
template_data: VendorTemplateUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -144,7 +144,7 @@ def update_template_override(
|
||||
def delete_template_override(
|
||||
code: str,
|
||||
language: str,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -168,7 +168,7 @@ def delete_template_override(
|
||||
def preview_template(
|
||||
code: str,
|
||||
preview_data: TemplatePreviewRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -201,7 +201,7 @@ def preview_template(
|
||||
def send_test_email(
|
||||
code: str,
|
||||
test_data: TemplateTestRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
14
app/api/v1/vendor/features.py
vendored
14
app/api/v1/vendor/features.py
vendored
@@ -24,7 +24,7 @@ from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.exceptions import FeatureNotFoundError
|
||||
from app.services.feature_service import feature_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
router = APIRouter(prefix="/features")
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -114,7 +114,7 @@ class FeatureCheckResponse(BaseModel):
|
||||
|
||||
@router.get("/available", response_model=FeatureCodeListResponse)
|
||||
def get_available_features(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -148,7 +148,7 @@ def get_available_features(
|
||||
def get_features(
|
||||
category: str | None = Query(None, description="Filter by category"),
|
||||
include_unavailable: bool = Query(True, description="Include features not available to vendor"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -211,7 +211,7 @@ def get_features(
|
||||
|
||||
@router.get("/categories", response_model=CategoryListResponse)
|
||||
def get_feature_categories(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -226,7 +226,7 @@ def get_feature_categories(
|
||||
|
||||
@router.get("/grouped", response_model=FeatureGroupedResponse)
|
||||
def get_features_grouped(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -273,7 +273,7 @@ def get_features_grouped(
|
||||
@router.get("/{feature_code}", response_model=FeatureDetailResponse)
|
||||
def get_feature_detail(
|
||||
feature_code: str,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -328,7 +328,7 @@ def get_feature_detail(
|
||||
@router.get("/check/{feature_code}", response_model=FeatureCheckResponse)
|
||||
def check_feature(
|
||||
feature_code: str,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
26
app/api/v1/vendor/inventory.py
vendored
26
app/api/v1/vendor/inventory.py
vendored
@@ -15,7 +15,7 @@ from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.inventory_service import inventory_service
|
||||
from app.services.inventory_transaction_service import inventory_transaction_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.inventory.schemas import (
|
||||
InventoryAdjust,
|
||||
InventoryCreate,
|
||||
@@ -38,7 +38,7 @@ logger = logging.getLogger(__name__)
|
||||
@router.post("/inventory/set", response_model=InventoryResponse)
|
||||
def set_inventory(
|
||||
inventory: InventoryCreate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Set exact inventory quantity (replaces existing)."""
|
||||
@@ -52,7 +52,7 @@ def set_inventory(
|
||||
@router.post("/inventory/adjust", response_model=InventoryResponse)
|
||||
def adjust_inventory(
|
||||
adjustment: InventoryAdjust,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Adjust inventory (positive to add, negative to remove)."""
|
||||
@@ -66,7 +66,7 @@ def adjust_inventory(
|
||||
@router.post("/inventory/reserve", response_model=InventoryResponse)
|
||||
def reserve_inventory(
|
||||
reservation: InventoryReserve,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Reserve inventory for an order."""
|
||||
@@ -80,7 +80,7 @@ def reserve_inventory(
|
||||
@router.post("/inventory/release", response_model=InventoryResponse)
|
||||
def release_reservation(
|
||||
reservation: InventoryReserve,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Release reserved inventory (cancel order)."""
|
||||
@@ -94,7 +94,7 @@ def release_reservation(
|
||||
@router.post("/inventory/fulfill", response_model=InventoryResponse)
|
||||
def fulfill_reservation(
|
||||
reservation: InventoryReserve,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Fulfill reservation (complete order, remove from stock)."""
|
||||
@@ -108,7 +108,7 @@ def fulfill_reservation(
|
||||
@router.get("/inventory/product/{product_id}", response_model=ProductInventorySummary)
|
||||
def get_product_inventory(
|
||||
product_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get inventory summary for a product."""
|
||||
@@ -123,7 +123,7 @@ def get_vendor_inventory(
|
||||
limit: int = Query(100, ge=1, le=1000),
|
||||
location: str | None = Query(None),
|
||||
low_stock: int | None = Query(None, ge=0),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get all inventory for vendor."""
|
||||
@@ -143,7 +143,7 @@ def get_vendor_inventory(
|
||||
def update_inventory(
|
||||
inventory_id: int,
|
||||
inventory_update: InventoryUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Update inventory entry."""
|
||||
@@ -157,7 +157,7 @@ def update_inventory(
|
||||
@router.delete("/inventory/{inventory_id}", response_model=InventoryMessageResponse)
|
||||
def delete_inventory(
|
||||
inventory_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Delete inventory entry."""
|
||||
@@ -177,7 +177,7 @@ def get_inventory_transactions(
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
product_id: int | None = Query(None, description="Filter by product"),
|
||||
transaction_type: str | None = Query(None, description="Filter by type"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -210,7 +210,7 @@ def get_inventory_transactions(
|
||||
def get_product_transaction_history(
|
||||
product_id: int,
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -234,7 +234,7 @@ def get_product_transaction_history(
|
||||
)
|
||||
def get_order_transaction_history(
|
||||
order_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
22
app/api/v1/vendor/invoices.py
vendored
22
app/api/v1/vendor/invoices.py
vendored
@@ -42,7 +42,7 @@ from app.exceptions.invoice import (
|
||||
)
|
||||
from app.services.invoice_service import invoice_service
|
||||
from app.modules.billing.models import FeatureCode
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.orders.schemas import (
|
||||
InvoiceCreate,
|
||||
InvoiceListPaginatedResponse,
|
||||
@@ -67,7 +67,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@router.get("/settings", response_model=VendorInvoiceSettingsResponse | None)
|
||||
def get_invoice_settings(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
_: None = Depends(RequireFeature(FeatureCode.INVOICE_LU)),
|
||||
):
|
||||
@@ -86,7 +86,7 @@ def get_invoice_settings(
|
||||
@router.post("/settings", response_model=VendorInvoiceSettingsResponse, status_code=201)
|
||||
def create_invoice_settings(
|
||||
data: VendorInvoiceSettingsCreate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -106,7 +106,7 @@ def create_invoice_settings(
|
||||
@router.put("/settings", response_model=VendorInvoiceSettingsResponse)
|
||||
def update_invoice_settings(
|
||||
data: VendorInvoiceSettingsUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -127,7 +127,7 @@ def update_invoice_settings(
|
||||
|
||||
@router.get("/stats", response_model=InvoiceStatsResponse)
|
||||
def get_invoice_stats(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -160,7 +160,7 @@ def list_invoices(
|
||||
page: int = Query(1, ge=1, description="Page number"),
|
||||
per_page: int = Query(20, ge=1, le=100, description="Items per page"),
|
||||
status: str | None = Query(None, description="Filter by status"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -207,7 +207,7 @@ def list_invoices(
|
||||
@router.get("/{invoice_id}", response_model=InvoiceResponse)
|
||||
def get_invoice(
|
||||
invoice_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -224,7 +224,7 @@ def get_invoice(
|
||||
@router.post("", response_model=InvoiceResponse, status_code=201)
|
||||
def create_invoice(
|
||||
data: InvoiceCreate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -248,7 +248,7 @@ def create_invoice(
|
||||
def update_invoice_status(
|
||||
invoice_id: int,
|
||||
data: InvoiceStatusUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -280,7 +280,7 @@ def update_invoice_status(
|
||||
def generate_invoice_pdf(
|
||||
invoice_id: int,
|
||||
regenerate: bool = Query(False, description="Force regenerate if exists"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -301,7 +301,7 @@ def generate_invoice_pdf(
|
||||
@router.get("/{invoice_id}/pdf")
|
||||
def download_invoice_pdf(
|
||||
invoice_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
34
app/api/v1/vendor/letzshop.py
vendored
34
app/api/v1/vendor/letzshop.py
vendored
@@ -31,7 +31,7 @@ from app.services.letzshop import (
|
||||
LetzshopOrderService,
|
||||
OrderNotFoundError,
|
||||
)
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.marketplace.schemas import (
|
||||
FulfillmentConfirmRequest,
|
||||
FulfillmentOperationResponse,
|
||||
@@ -81,7 +81,7 @@ def get_credentials_service(db: Session) -> LetzshopCredentialsService:
|
||||
|
||||
@router.get("/status", response_model=LetzshopCredentialsStatus)
|
||||
def get_letzshop_status(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get Letzshop integration status for the current vendor."""
|
||||
@@ -92,7 +92,7 @@ def get_letzshop_status(
|
||||
|
||||
@router.get("/credentials", response_model=LetzshopCredentialsResponse)
|
||||
def get_credentials(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get Letzshop credentials for the current vendor (API key is masked)."""
|
||||
@@ -122,7 +122,7 @@ def get_credentials(
|
||||
@router.post("/credentials", response_model=LetzshopCredentialsResponse)
|
||||
def save_credentials(
|
||||
credentials_data: LetzshopCredentialsCreate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Create or update Letzshop credentials for the current vendor."""
|
||||
@@ -158,7 +158,7 @@ def save_credentials(
|
||||
@router.patch("/credentials", response_model=LetzshopCredentialsResponse)
|
||||
def update_credentials(
|
||||
credentials_data: LetzshopCredentialsUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Partially update Letzshop credentials for the current vendor."""
|
||||
@@ -194,7 +194,7 @@ def update_credentials(
|
||||
|
||||
@router.delete("/credentials", response_model=LetzshopSuccessResponse)
|
||||
def delete_credentials(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Delete Letzshop credentials for the current vendor."""
|
||||
@@ -218,7 +218,7 @@ def delete_credentials(
|
||||
|
||||
@router.post("/test", response_model=LetzshopConnectionTestResponse)
|
||||
def test_connection(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Test the Letzshop connection using stored credentials."""
|
||||
@@ -239,7 +239,7 @@ def test_connection(
|
||||
@router.post("/test-key", response_model=LetzshopConnectionTestResponse)
|
||||
def test_api_key(
|
||||
test_request: LetzshopConnectionTestRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Test a Letzshop API key without saving it."""
|
||||
@@ -268,7 +268,7 @@ def list_orders(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
status: str | None = Query(None, description="Filter by order status"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""List Letzshop orders for the current vendor."""
|
||||
@@ -319,7 +319,7 @@ def list_orders(
|
||||
@router.get("/orders/{order_id}", response_model=LetzshopOrderDetailResponse)
|
||||
def get_order(
|
||||
order_id: int = Path(..., description="Order ID"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get a specific Letzshop order with full details."""
|
||||
@@ -381,7 +381,7 @@ def get_order(
|
||||
@router.post("/orders/import", response_model=LetzshopSyncTriggerResponse)
|
||||
def import_orders(
|
||||
sync_request: LetzshopSyncTriggerRequest = LetzshopSyncTriggerRequest(),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Import new orders from Letzshop."""
|
||||
@@ -455,7 +455,7 @@ def import_orders(
|
||||
def confirm_order(
|
||||
order_id: int = Path(..., description="Order ID"),
|
||||
confirm_request: FulfillmentConfirmRequest | None = None,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -525,7 +525,7 @@ def confirm_order(
|
||||
def reject_order(
|
||||
order_id: int = Path(..., description="Order ID"),
|
||||
reject_request: FulfillmentRejectRequest | None = None,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Reject inventory units for a Letzshop order."""
|
||||
@@ -580,7 +580,7 @@ def reject_order(
|
||||
def set_order_tracking(
|
||||
order_id: int = Path(..., description="Order ID"),
|
||||
tracking_request: FulfillmentTrackingRequest = ...,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Set tracking information for a Letzshop order."""
|
||||
@@ -642,7 +642,7 @@ def set_order_tracking(
|
||||
def list_sync_logs(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""List Letzshop sync logs for the current vendor."""
|
||||
@@ -691,7 +691,7 @@ def list_fulfillment_queue(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
status: str | None = Query(None, description="Filter by status"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""List fulfillment queue items for the current vendor."""
|
||||
@@ -743,7 +743,7 @@ def export_products_letzshop(
|
||||
"en", description="Language for title/description (en, fr, de)"
|
||||
),
|
||||
include_inactive: bool = Query(False, description="Include inactive products"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
8
app/api/v1/vendor/marketplace.py
vendored
8
app/api/v1/vendor/marketplace.py
vendored
@@ -17,7 +17,7 @@ from app.services.marketplace_import_job_service import marketplace_import_job_s
|
||||
from app.services.vendor_service import vendor_service
|
||||
from app.tasks.background_tasks import process_marketplace_import
|
||||
from middleware.decorators import rate_limit
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.marketplace.schemas import (
|
||||
MarketplaceImportJobRequest,
|
||||
MarketplaceImportJobResponse,
|
||||
@@ -32,7 +32,7 @@ logger = logging.getLogger(__name__)
|
||||
async def import_products_from_marketplace(
|
||||
request: MarketplaceImportJobRequest,
|
||||
background_tasks: BackgroundTasks,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Import products from marketplace CSV with background processing (Protected).
|
||||
@@ -96,7 +96,7 @@ async def import_products_from_marketplace(
|
||||
@router.get("/imports/{job_id}", response_model=MarketplaceImportJobResponse)
|
||||
def get_marketplace_import_status(
|
||||
job_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get status of marketplace import job (Protected)."""
|
||||
@@ -113,7 +113,7 @@ def get_marketplace_import_jobs(
|
||||
marketplace: str | None = Query(None, description="Filter by marketplace"),
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=100),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get marketplace import jobs for current vendor (Protected)."""
|
||||
|
||||
18
app/api/v1/vendor/media.py
vendored
18
app/api/v1/vendor/media.py
vendored
@@ -15,7 +15,7 @@ from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.exceptions.media import MediaOptimizationException
|
||||
from app.services.media_service import media_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from models.schema.media import (
|
||||
MediaDetailResponse,
|
||||
MediaItemResponse,
|
||||
@@ -40,7 +40,7 @@ def get_media_library(
|
||||
media_type: str | None = Query(None, description="image, video, document"),
|
||||
folder: str | None = Query(None, description="Filter by folder"),
|
||||
search: str | None = Query(None),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -74,7 +74,7 @@ def get_media_library(
|
||||
async def upload_media(
|
||||
file: UploadFile = File(...),
|
||||
folder: str | None = Query("general", description="products, general, etc."),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -116,7 +116,7 @@ async def upload_media(
|
||||
async def upload_multiple_media(
|
||||
files: list[UploadFile] = File(...),
|
||||
folder: str | None = Query("general"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -170,7 +170,7 @@ async def upload_multiple_media(
|
||||
@router.get("/{media_id}", response_model=MediaDetailResponse)
|
||||
def get_media_details(
|
||||
media_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -194,7 +194,7 @@ def get_media_details(
|
||||
def update_media_metadata(
|
||||
media_id: int,
|
||||
metadata: MediaMetadataUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -225,7 +225,7 @@ def update_media_metadata(
|
||||
@router.delete("/{media_id}", response_model=MediaDetailResponse)
|
||||
def delete_media(
|
||||
media_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -251,7 +251,7 @@ def delete_media(
|
||||
@router.get("/{media_id}/usage", response_model=MediaUsageResponse)
|
||||
def get_media_usage(
|
||||
media_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -273,7 +273,7 @@ def get_media_usage(
|
||||
@router.post("/optimize/{media_id}", response_model=OptimizationResultResponse)
|
||||
def optimize_media(
|
||||
media_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
22
app/api/v1/vendor/messages.py
vendored
22
app/api/v1/vendor/messages.py
vendored
@@ -47,7 +47,7 @@ from app.modules.messaging.schemas import (
|
||||
ReopenConversationResponse,
|
||||
UnreadCountResponse,
|
||||
)
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
router = APIRouter(prefix="/messages")
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -177,7 +177,7 @@ def list_conversations(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(20, ge=1, le=100),
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> ConversationListResponse:
|
||||
"""List conversations for vendor (vendor_customer and admin_vendor channels)."""
|
||||
vendor_id = current_user.token_vendor_id
|
||||
@@ -208,7 +208,7 @@ def list_conversations(
|
||||
@router.get("/unread-count", response_model=UnreadCountResponse)
|
||||
def get_unread_count(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> UnreadCountResponse:
|
||||
"""Get total unread message count for header badge."""
|
||||
vendor_id = current_user.token_vendor_id
|
||||
@@ -234,7 +234,7 @@ def get_recipients(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=100),
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> RecipientListResponse:
|
||||
"""Get list of available recipients for compose modal."""
|
||||
vendor_id = current_user.token_vendor_id
|
||||
@@ -275,7 +275,7 @@ def get_recipients(
|
||||
def create_conversation(
|
||||
data: ConversationCreate,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> ConversationDetailResponse:
|
||||
"""Create a new conversation with a customer."""
|
||||
vendor_id = current_user.token_vendor_id
|
||||
@@ -399,7 +399,7 @@ def get_conversation(
|
||||
conversation_id: int,
|
||||
mark_read: bool = Query(True, description="Automatically mark as read"),
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> ConversationDetailResponse:
|
||||
"""Get conversation detail with messages."""
|
||||
vendor_id = current_user.token_vendor_id
|
||||
@@ -442,7 +442,7 @@ async def send_message(
|
||||
content: str = Form(...),
|
||||
files: list[UploadFile] = File(default=[]),
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> MessageResponse:
|
||||
"""Send a message in a conversation, optionally with attachments."""
|
||||
vendor_id = current_user.token_vendor_id
|
||||
@@ -505,7 +505,7 @@ async def send_message(
|
||||
def close_conversation(
|
||||
conversation_id: int,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> CloseConversationResponse:
|
||||
"""Close a conversation."""
|
||||
vendor_id = current_user.token_vendor_id
|
||||
@@ -547,7 +547,7 @@ def close_conversation(
|
||||
def reopen_conversation(
|
||||
conversation_id: int,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> ReopenConversationResponse:
|
||||
"""Reopen a closed conversation."""
|
||||
vendor_id = current_user.token_vendor_id
|
||||
@@ -589,7 +589,7 @@ def reopen_conversation(
|
||||
def mark_read(
|
||||
conversation_id: int,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> MarkReadResponse:
|
||||
"""Mark conversation as read."""
|
||||
success = messaging_service.mark_conversation_read(
|
||||
@@ -617,7 +617,7 @@ def update_preferences(
|
||||
conversation_id: int,
|
||||
preferences: NotificationPreferencesUpdate,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
) -> PreferencesUpdateResponse:
|
||||
"""Update notification preferences for a conversation."""
|
||||
success = messaging_service.update_notification_preferences(
|
||||
|
||||
22
app/api/v1/vendor/notifications.py
vendored
22
app/api/v1/vendor/notifications.py
vendored
@@ -14,7 +14,7 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.messaging.schemas import (
|
||||
MessageResponse,
|
||||
NotificationListResponse,
|
||||
@@ -35,7 +35,7 @@ def get_notifications(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=100),
|
||||
unread_only: bool | None = Query(False),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -58,7 +58,7 @@ def get_notifications(
|
||||
|
||||
@router.get("/unread-count", response_model=UnreadCountResponse)
|
||||
def get_unread_count(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -75,7 +75,7 @@ def get_unread_count(
|
||||
@router.put("/{notification_id}/read", response_model=MessageResponse)
|
||||
def mark_as_read(
|
||||
notification_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -91,7 +91,7 @@ def mark_as_read(
|
||||
|
||||
@router.put("/mark-all-read", response_model=MessageResponse)
|
||||
def mark_all_as_read(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -108,7 +108,7 @@ def mark_all_as_read(
|
||||
@router.delete("/{notification_id}", response_model=MessageResponse)
|
||||
def delete_notification(
|
||||
notification_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -124,7 +124,7 @@ def delete_notification(
|
||||
|
||||
@router.get("/settings", response_model=NotificationSettingsResponse)
|
||||
def get_notification_settings(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -147,7 +147,7 @@ def get_notification_settings(
|
||||
@router.put("/settings", response_model=MessageResponse)
|
||||
def update_notification_settings(
|
||||
settings: NotificationSettingsUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -164,7 +164,7 @@ def update_notification_settings(
|
||||
|
||||
@router.get("/templates", response_model=NotificationTemplateListResponse)
|
||||
def get_notification_templates(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -185,7 +185,7 @@ def get_notification_templates(
|
||||
def update_notification_template(
|
||||
template_id: int,
|
||||
template_data: NotificationTemplateUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -204,7 +204,7 @@ def update_notification_template(
|
||||
@router.post("/test", response_model=MessageResponse)
|
||||
def send_test_notification(
|
||||
notification_data: TestNotificationRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
22
app/api/v1/vendor/onboarding.py
vendored
22
app/api/v1/vendor/onboarding.py
vendored
@@ -20,7 +20,7 @@ from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.onboarding_service import OnboardingService
|
||||
from app.tasks.letzshop_tasks import process_historical_import
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.marketplace.schemas import (
|
||||
CompanyProfileRequest,
|
||||
CompanyProfileResponse,
|
||||
@@ -49,7 +49,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@router.get("/status", response_model=OnboardingStatusResponse)
|
||||
def get_onboarding_status(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -69,7 +69,7 @@ def get_onboarding_status(
|
||||
|
||||
@router.get("/step/company-profile")
|
||||
def get_company_profile(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -84,7 +84,7 @@ def get_company_profile(
|
||||
@router.post("/step/company-profile", response_model=CompanyProfileResponse)
|
||||
def save_company_profile(
|
||||
request: CompanyProfileRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -118,7 +118,7 @@ def save_company_profile(
|
||||
@router.post("/step/letzshop-api/test", response_model=LetzshopApiTestResponse)
|
||||
def test_letzshop_api(
|
||||
request: LetzshopApiTestRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -136,7 +136,7 @@ def test_letzshop_api(
|
||||
@router.post("/step/letzshop-api", response_model=LetzshopApiConfigResponse)
|
||||
def save_letzshop_api(
|
||||
request: LetzshopApiConfigRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -162,7 +162,7 @@ def save_letzshop_api(
|
||||
|
||||
@router.get("/step/product-import")
|
||||
def get_product_import_config(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -177,7 +177,7 @@ def get_product_import_config(
|
||||
@router.post("/step/product-import", response_model=ProductImportConfigResponse)
|
||||
def save_product_import_config(
|
||||
request: ProductImportConfigRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -208,7 +208,7 @@ def save_product_import_config(
|
||||
def trigger_order_sync(
|
||||
request: OrderSyncTriggerRequest,
|
||||
background_tasks: BackgroundTasks,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -253,7 +253,7 @@ def trigger_order_sync(
|
||||
)
|
||||
def get_order_sync_progress(
|
||||
job_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -271,7 +271,7 @@ def get_order_sync_progress(
|
||||
@router.post("/step/order-sync/complete", response_model=OrderSyncCompleteResponse)
|
||||
def complete_order_sync(
|
||||
request: OrderSyncCompleteRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
14
app/api/v1/vendor/order_item_exceptions.py
vendored
14
app/api/v1/vendor/order_item_exceptions.py
vendored
@@ -16,7 +16,7 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.order_item_exception_service import order_item_exception_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.orders.schemas import (
|
||||
BulkResolveRequest,
|
||||
BulkResolveResponse,
|
||||
@@ -50,7 +50,7 @@ def list_vendor_exceptions(
|
||||
),
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -91,7 +91,7 @@ def list_vendor_exceptions(
|
||||
|
||||
@router.get("/stats", response_model=OrderItemExceptionStats)
|
||||
def get_vendor_exception_stats(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -112,7 +112,7 @@ def get_vendor_exception_stats(
|
||||
@router.get("/{exception_id}", response_model=OrderItemExceptionResponse)
|
||||
def get_vendor_exception(
|
||||
exception_id: int = Path(..., description="Exception ID"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -145,7 +145,7 @@ def get_vendor_exception(
|
||||
def resolve_vendor_exception(
|
||||
exception_id: int = Path(..., description="Exception ID"),
|
||||
request: ResolveExceptionRequest = ...,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -185,7 +185,7 @@ def resolve_vendor_exception(
|
||||
def ignore_vendor_exception(
|
||||
exception_id: int = Path(..., description="Exception ID"),
|
||||
request: IgnoreExceptionRequest = ...,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -228,7 +228,7 @@ def ignore_vendor_exception(
|
||||
@router.post("/bulk-resolve", response_model=BulkResolveResponse)
|
||||
def bulk_resolve_vendor_exceptions(
|
||||
request: BulkResolveRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
12
app/api/v1/vendor/orders.py
vendored
12
app/api/v1/vendor/orders.py
vendored
@@ -16,7 +16,7 @@ from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.order_inventory_service import order_inventory_service
|
||||
from app.services.order_service import order_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.orders.schemas import (
|
||||
OrderDetailResponse,
|
||||
OrderListResponse,
|
||||
@@ -34,7 +34,7 @@ def get_vendor_orders(
|
||||
limit: int = Query(100, ge=1, le=1000),
|
||||
status: str | None = Query(None, description="Filter by order status"),
|
||||
customer_id: int | None = Query(None, description="Filter by customer"),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -67,7 +67,7 @@ def get_vendor_orders(
|
||||
@router.get("/{order_id}", response_model=OrderDetailResponse)
|
||||
def get_order_details(
|
||||
order_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -86,7 +86,7 @@ def get_order_details(
|
||||
def update_order_status(
|
||||
order_id: int,
|
||||
order_update: OrderUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -174,7 +174,7 @@ class ShipmentStatusResponse(BaseModel):
|
||||
@router.get("/{order_id}/shipment-status", response_model=ShipmentStatusResponse)
|
||||
def get_shipment_status(
|
||||
order_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -210,7 +210,7 @@ def ship_order_item(
|
||||
order_id: int,
|
||||
item_id: int,
|
||||
request: ShipItemRequest | None = None,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
18
app/api/v1/vendor/payments.py
vendored
18
app/api/v1/vendor/payments.py
vendored
@@ -14,7 +14,7 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.payments.schemas import (
|
||||
PaymentBalanceResponse,
|
||||
PaymentConfigResponse,
|
||||
@@ -35,7 +35,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@router.get("/config", response_model=PaymentConfigResponse)
|
||||
def get_payment_configuration(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -60,7 +60,7 @@ def get_payment_configuration(
|
||||
@router.put("/config", response_model=PaymentConfigUpdateResponse)
|
||||
def update_payment_configuration(
|
||||
payment_config: PaymentConfigUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -81,7 +81,7 @@ def update_payment_configuration(
|
||||
@router.post("/stripe/connect", response_model=StripeConnectResponse)
|
||||
def connect_stripe_account(
|
||||
stripe_data: StripeConnectRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -99,7 +99,7 @@ def connect_stripe_account(
|
||||
|
||||
@router.delete("/stripe/disconnect", response_model=StripeDisconnectResponse)
|
||||
def disconnect_stripe_account(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -116,7 +116,7 @@ def disconnect_stripe_account(
|
||||
|
||||
@router.get("/methods", response_model=PaymentMethodsResponse)
|
||||
def get_payment_methods(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -135,7 +135,7 @@ def get_payment_methods(
|
||||
|
||||
@router.get("/transactions", response_model=TransactionsResponse)
|
||||
def get_payment_transactions(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -157,7 +157,7 @@ def get_payment_transactions(
|
||||
|
||||
@router.get("/balance", response_model=PaymentBalanceResponse)
|
||||
def get_payment_balance(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -183,7 +183,7 @@ def get_payment_balance(
|
||||
def refund_payment(
|
||||
payment_id: int,
|
||||
refund_data: RefundRequest,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
20
app/api/v1/vendor/products.py
vendored
20
app/api/v1/vendor/products.py
vendored
@@ -16,7 +16,7 @@ from app.core.database import get_db
|
||||
from app.services.product_service import product_service
|
||||
from app.services.subscription_service import subscription_service
|
||||
from app.services.vendor_product_service import vendor_product_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.catalog.schemas import (
|
||||
ProductCreate,
|
||||
ProductDeleteResponse,
|
||||
@@ -41,7 +41,7 @@ def get_vendor_products(
|
||||
limit: int = Query(100, ge=1, le=1000),
|
||||
is_active: bool | None = Query(None),
|
||||
is_featured: bool | None = Query(None),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -73,7 +73,7 @@ def get_vendor_products(
|
||||
@router.get("/{product_id}", response_model=ProductDetailResponse)
|
||||
def get_product_details(
|
||||
product_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get detailed product information including inventory."""
|
||||
@@ -87,7 +87,7 @@ def get_product_details(
|
||||
@router.post("", response_model=ProductResponse)
|
||||
def add_product_to_catalog(
|
||||
product_data: ProductCreate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -114,7 +114,7 @@ def add_product_to_catalog(
|
||||
@router.post("/create", response_model=VendorProductCreateResponse)
|
||||
def create_product_direct(
|
||||
product_data: VendorDirectProductCreate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -159,7 +159,7 @@ def create_product_direct(
|
||||
def update_product(
|
||||
product_id: int,
|
||||
product_data: ProductUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Update product in vendor catalog."""
|
||||
@@ -182,7 +182,7 @@ def update_product(
|
||||
@router.delete("/{product_id}", response_model=ProductDeleteResponse)
|
||||
def remove_product_from_catalog(
|
||||
product_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Remove product from vendor catalog."""
|
||||
@@ -202,7 +202,7 @@ def remove_product_from_catalog(
|
||||
@router.post("/from-import/{marketplace_product_id}", response_model=ProductResponse)
|
||||
def publish_from_marketplace(
|
||||
marketplace_product_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -233,7 +233,7 @@ def publish_from_marketplace(
|
||||
@router.put("/{product_id}/toggle-active", response_model=ProductToggleResponse)
|
||||
def toggle_product_active(
|
||||
product_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Toggle product active status."""
|
||||
@@ -256,7 +256,7 @@ def toggle_product_active(
|
||||
@router.put("/{product_id}/toggle-featured", response_model=ProductToggleResponse)
|
||||
def toggle_product_featured(
|
||||
product_id: int,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Toggle product featured status."""
|
||||
|
||||
6
app/api/v1/vendor/profile.py
vendored
6
app/api/v1/vendor/profile.py
vendored
@@ -14,7 +14,7 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from models.schema.vendor import VendorResponse, VendorUpdate
|
||||
|
||||
router = APIRouter(prefix="/profile")
|
||||
@@ -23,7 +23,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@router.get("", response_model=VendorResponse)
|
||||
def get_vendor_profile(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get current vendor profile information."""
|
||||
@@ -34,7 +34,7 @@ def get_vendor_profile(
|
||||
@router.put("", response_model=VendorResponse)
|
||||
def update_vendor_profile(
|
||||
vendor_update: VendorUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Update vendor profile information."""
|
||||
|
||||
10
app/api/v1/vendor/settings.py
vendored
10
app/api/v1/vendor/settings.py
vendored
@@ -16,7 +16,7 @@ from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.platform_settings_service import platform_settings_service
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
router = APIRouter(prefix="/settings")
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -156,7 +156,7 @@ class LetzshopFeedSettingsUpdate(BaseModel):
|
||||
|
||||
@router.get("")
|
||||
def get_vendor_settings(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get comprehensive vendor settings and configuration."""
|
||||
@@ -321,7 +321,7 @@ def get_vendor_settings(
|
||||
@router.put("/business-info")
|
||||
def update_business_info(
|
||||
business_info: BusinessInfoUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -363,7 +363,7 @@ def update_business_info(
|
||||
@router.put("/letzshop")
|
||||
def update_letzshop_settings(
|
||||
letzshop_config: LetzshopFeedSettingsUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Update Letzshop marketplace feed settings.
|
||||
@@ -397,7 +397,7 @@ def update_letzshop_settings(
|
||||
@router.put("/localization")
|
||||
def update_localization_settings(
|
||||
localization_config: LocalizationSettingsUpdate,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
20
app/api/v1/vendor/team.py
vendored
20
app/api/v1/vendor/team.py
vendored
@@ -24,7 +24,7 @@ from app.api.deps import (
|
||||
from app.core.database import get_db
|
||||
from app.core.permissions import VendorPermissions
|
||||
from app.services.vendor_team_service import vendor_team_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
from models.schema.team import (
|
||||
BulkRemoveRequest,
|
||||
BulkRemoveResponse,
|
||||
@@ -54,7 +54,7 @@ def list_team_members(
|
||||
request: Request,
|
||||
include_inactive: bool = False,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(
|
||||
current_user: UserContext = Depends(
|
||||
require_vendor_permission(VendorPermissions.TEAM_VIEW.value)
|
||||
),
|
||||
):
|
||||
@@ -96,7 +96,7 @@ def invite_team_member(
|
||||
invitation: TeamMemberInvite,
|
||||
request: Request,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(require_vendor_owner), # Owner only
|
||||
current_user: UserContext = Depends(require_vendor_owner), # Owner only
|
||||
):
|
||||
"""
|
||||
Invite a new team member to the vendor.
|
||||
@@ -220,7 +220,7 @@ def get_team_member(
|
||||
user_id: int,
|
||||
request: Request,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(
|
||||
current_user: UserContext = Depends(
|
||||
require_vendor_permission(VendorPermissions.TEAM_VIEW.value)
|
||||
),
|
||||
):
|
||||
@@ -250,7 +250,7 @@ def update_team_member(
|
||||
update_data: TeamMemberUpdate,
|
||||
request: Request,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(require_vendor_owner), # Owner only
|
||||
current_user: UserContext = Depends(require_vendor_owner), # Owner only
|
||||
):
|
||||
"""
|
||||
Update a team member's role or status.
|
||||
@@ -293,7 +293,7 @@ def remove_team_member(
|
||||
user_id: int,
|
||||
request: Request,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(require_vendor_owner), # Owner only
|
||||
current_user: UserContext = Depends(require_vendor_owner), # Owner only
|
||||
):
|
||||
"""
|
||||
Remove a team member from the vendor.
|
||||
@@ -325,7 +325,7 @@ def bulk_remove_team_members(
|
||||
bulk_remove: BulkRemoveRequest,
|
||||
request: Request,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(require_vendor_owner),
|
||||
current_user: UserContext = Depends(require_vendor_owner),
|
||||
):
|
||||
"""
|
||||
Remove multiple team members at once.
|
||||
@@ -369,7 +369,7 @@ def bulk_remove_team_members(
|
||||
def list_roles(
|
||||
request: Request,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(
|
||||
current_user: UserContext = Depends(
|
||||
require_vendor_permission(VendorPermissions.TEAM_VIEW.value)
|
||||
),
|
||||
):
|
||||
@@ -399,7 +399,7 @@ def list_roles(
|
||||
def get_my_permissions(
|
||||
request: Request,
|
||||
permissions: list[str] = Depends(get_user_permissions),
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
):
|
||||
"""
|
||||
Get current user's permissions in this vendor.
|
||||
@@ -438,7 +438,7 @@ def get_my_permissions(
|
||||
def get_team_statistics(
|
||||
request: Request,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(
|
||||
current_user: UserContext = Depends(
|
||||
require_vendor_permission(VendorPermissions.TEAM_VIEW.value)
|
||||
),
|
||||
):
|
||||
|
||||
6
app/api/v1/vendor/usage.py
vendored
6
app/api/v1/vendor/usage.py
vendored
@@ -17,7 +17,7 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.usage_service import usage_service
|
||||
from models.database.user import User
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
router = APIRouter(prefix="/usage")
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -91,7 +91,7 @@ class LimitCheckResponse(BaseModel):
|
||||
|
||||
@router.get("", response_model=UsageResponse)
|
||||
def get_usage(
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
@@ -146,7 +146,7 @@ def get_usage(
|
||||
@router.get("/check/{limit_type}", response_model=LimitCheckResponse)
|
||||
def check_limit(
|
||||
limit_type: str,
|
||||
current_user: User = Depends(get_current_vendor_api),
|
||||
current_user: UserContext = Depends(get_current_vendor_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user