2
2
Subscription API handling
3
3
"""
4
4
5
- from typing import Callable , Union
5
+ from typing import Callable , Union , Any
6
6
7
7
from fastapi import Depends , HTTPException , Request
8
8
@@ -36,7 +36,7 @@ def __init__(self, mdb, org_ops: OrgOps, user_manager: UserManager):
36
36
37
37
async def create_new_subscription (
38
38
self , create : SubscriptionCreate , user : User , request : Request
39
- ):
39
+ ) -> dict [ str , Any ] :
40
40
"""create org for new subscription"""
41
41
sub_data = SubscriptionData (
42
42
subId = create .subId , status = create .status , details = create .details
@@ -66,7 +66,7 @@ async def create_new_subscription(
66
66
67
67
return result
68
68
69
- async def update_subscription (self , update : SubscriptionUpdate ):
69
+ async def update_subscription (self , update : SubscriptionUpdate ) -> dict [ str , bool ] :
70
70
"""update subs"""
71
71
72
72
org = await self .org_ops .update_subscription_data (update )
@@ -76,15 +76,15 @@ async def update_subscription(self, update: SubscriptionUpdate):
76
76
status_code = 404 , detail = "org_for_subscription_not_found"
77
77
)
78
78
79
- print ("ORG SUB" , org .subData )
80
-
81
79
await self .add_sub_event (update )
82
80
return {"updated" : True }
83
81
84
- async def cancel_subscription (self , cancel : SubscriptionCancel ):
82
+ async def cancel_subscription (self , cancel : SubscriptionCancel ) -> dict [ str , bool ] :
85
83
"""delete subscription data, and if readOnlyOnCancel is true, the entire org"""
86
84
87
- org = await self .org_ops .cancel_subscription_data (cancel )
85
+ org = await self .org_ops .update_subscription_data (
86
+ SubscriptionUpdate (subId = cancel .subId , status = "canceled" )
87
+ )
88
88
89
89
if not org :
90
90
raise HTTPException (
@@ -125,7 +125,7 @@ def init_subs_api(
125
125
org_ops : OrgOps ,
126
126
user_manager : UserManager ,
127
127
user_or_shared_secret_dep : Callable ,
128
- ):
128
+ ) -> SubOps :
129
129
"""init subs API"""
130
130
ops = SubOps (mdb , org_ops , user_manager )
131
131
0 commit comments