@@ -76,19 +76,32 @@ type Song = {
76
76
title: string ;
77
77
};
78
78
79
+ type ChargeStatus = {
80
+ status: " charged" | " declined" ;
81
+ };
82
+
83
+ type AccessStatus = {
84
+ status: " unlocked" | " locked" ;
85
+ };
86
+
87
+ type Status = {
88
+ charge: ChargeStatus ;
89
+ access: AccessStatus ;
90
+ };
91
+
79
92
// Purchase song event handler
80
- async function purchase(ctx : Context , user : User , song : Song ): Promise <{ charge : any ; access : any } > {
93
+ async function purchase(ctx : Context , user : User , song : Song ): Promise <Status > {
81
94
const charge = await ctx .run (chargeCreditCard , user , song );
82
95
const access = await ctx .run (unlockUserAccess , user , song );
83
96
return { charge , access };
84
97
}
85
98
86
- async function chargeCreditCard(ctx : Context , user : User , song : Song ): Promise <any > {
99
+ async function chargeCreditCard(ctx : Context , user : User , song : Song ): Promise <ChargeStatus > {
87
100
console .log (" Charging credit card..." );
88
101
return { status: " charged" };
89
102
}
90
103
91
- async function unlockUserAccess(ctx : Context , user : User , song : Song ): Promise <any > {
104
+ async function unlockUserAccess(ctx : Context , user : User , song : Song ): Promise <AccessStatus > {
92
105
console .log (" Unlocking user access..." );
93
106
return { status: " unlocked" };
94
107
}
0 commit comments