|
4 | 4 | from datetime import UTC, datetime, timedelta |
5 | 5 |
|
6 | 6 | from aiohttp import web |
7 | | -from models_library.api_schemas_webserver import ( |
8 | | - licensed_items_purchases as webserver_licensed_items_purchases, |
| 7 | + |
| 8 | +# from models_library.api_schemas_webserver import ( |
| 9 | +# licensed_items_purchases as webserver_licensed_items_purchases, |
| 10 | +# ) |
| 11 | +from models_library.api_schemas_resource_usage_tracker.licensed_items_purchases import ( |
| 12 | + LicensedItemPurchaseGet, |
| 13 | +) |
| 14 | +from models_library.licenses import ( |
| 15 | + LicensedItem, |
| 16 | + LicensedItemID, |
| 17 | + LicensedItemKey, |
| 18 | + LicensedItemPage, |
| 19 | + LicensedItemVersion, |
9 | 20 | ) |
10 | | -from models_library.licenses import LicensedItem, LicensedItemID, LicensedItemPage |
11 | 21 | from models_library.products import ProductName |
12 | 22 | from models_library.resource_tracker_licensed_items_purchases import ( |
13 | 23 | LicensedItemsPurchasesCreate, |
|
34 | 44 | async def get_licensed_item( |
35 | 45 | app: web.Application, |
36 | 46 | *, |
37 | | - key: str, |
38 | | - version: str, |
| 47 | + key: LicensedItemKey, |
| 48 | + version: LicensedItemVersion, |
39 | 49 | product_name: ProductName, |
40 | 50 | ) -> LicensedItem: |
41 | 51 |
|
@@ -72,7 +82,7 @@ async def purchase_licensed_item( |
72 | 82 | user_id: UserID, |
73 | 83 | licensed_item_id: LicensedItemID, |
74 | 84 | body_params: LicensedItemsBodyParams, |
75 | | -) -> webserver_licensed_items_purchases.LicensedItemPurchaseGet: |
| 85 | +) -> LicensedItemPurchaseGet: |
76 | 86 | # Check user wallet permissions |
77 | 87 | wallet = await get_wallet_with_available_credits_by_user_and_wallet( |
78 | 88 | app, user_id=user_id, wallet_id=body_params.wallet_id, product_name=product_name |
@@ -128,23 +138,6 @@ async def purchase_licensed_item( |
128 | 138 | purchased_at=datetime.now(tz=UTC), |
129 | 139 | ) |
130 | 140 | rpc_client = get_rabbitmq_rpc_client(app) |
131 | | - purchased_item = await licensed_items_purchases.create_licensed_item_purchase( |
| 141 | + return await licensed_items_purchases.create_licensed_item_purchase( |
132 | 142 | rpc_client, data=_data |
133 | 143 | ) |
134 | | - return webserver_licensed_items_purchases.LicensedItemPurchaseGet( |
135 | | - licensed_item_purchase_id=purchased_item.licensed_item_purchase_id, |
136 | | - product_name=purchased_item.product_name, |
137 | | - licensed_item_id=purchased_item.licensed_item_id, |
138 | | - key=purchased_item.key, |
139 | | - version=purchased_item.version, |
140 | | - wallet_id=purchased_item.wallet_id, |
141 | | - pricing_unit_cost_id=purchased_item.pricing_unit_cost_id, |
142 | | - pricing_unit_cost=purchased_item.pricing_unit_cost, |
143 | | - start_at=purchased_item.start_at, |
144 | | - expire_at=purchased_item.expire_at, |
145 | | - num_of_seats=purchased_item.num_of_seats, |
146 | | - purchased_by_user=purchased_item.purchased_by_user, |
147 | | - user_email=purchased_item.user_email, |
148 | | - purchased_at=purchased_item.purchased_at, |
149 | | - modified_at=purchased_item.modified, |
150 | | - ) |
0 commit comments