feat: add subscription and transaction repositories
- Implemented SubscriptionRepository with methods to get, create, and update subscriptions. - Added BalanceTXRepository for creating and retrieving balance transactions. - Introduced a test script for simulating Pally webhook for local testing.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from db.models.bills import Bill, BillStatus
|
||||
from db.models.bills import Bill, DepositStatus
|
||||
|
||||
|
||||
class BillsRepository:
|
||||
@@ -17,9 +17,15 @@ class BillsRepository:
|
||||
*,
|
||||
creator_id: int,
|
||||
amount: int,
|
||||
status: BillStatus | None = BillStatus.NEW,
|
||||
status: DepositStatus | None = DepositStatus.PENDING,
|
||||
) -> Bill:
|
||||
bill = Bill(creator_id=creator_id, amount=amount, status=status)
|
||||
session.add(bill)
|
||||
await session.commit()
|
||||
return bill
|
||||
|
||||
async def update_bill_status(self, session: AsyncSession, bill_id: int, status: DepositStatus):
|
||||
stmt = update(Bill).where(Bill.id == bill_id).values(status=status).returning(Bill)
|
||||
result = await session.execute(stmt)
|
||||
await session.commit()
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
Reference in New Issue
Block a user