File tree 4 files changed +54
-0
lines changed
4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -33,3 +33,7 @@ export const puzzleStatsSchema = z.array(puzzleItemStatSchema)
33
33
export const puzzleRevokeResponseSchema = z . object ( {
34
34
status : z . string ( ) . default ( 'OK' ) ,
35
35
} )
36
+
37
+ export const puzzleCouponRedeemResponseSchema = z . object ( {
38
+ status : z . string ( ) . default ( 'OK' ) ,
39
+ } )
Original file line number Diff line number Diff line change
1
+ Feature : Puzzle Coupon
2
+ Scenario : PUT /event/puzzle/coupon to redeem a puzzle coupon
3
+ Given there have some booths
4
+ | token | name | event_id |
5
+ | 1024914b -ee65 -4728 -b687 -8341f5affa89 | COSCUP | SITCON |
6
+ And there have some attendees
7
+ | token | event_id | display_name |
8
+ | f185f505 -d8c0 -43ce -9e7b -bb9e8909072d | SITCON | Aotoki |
9
+ When I make a PUT request to "/event/puzzle/coupon?token=1024914b-ee65-4728-b687-8341f5affa89&event_id=SITCON" :
10
+ """
11
+ {}
12
+ """
13
+ Then the response json should be:
14
+ """
15
+ {
16
+ "status": "OK"
17
+ }
18
+ """
19
+ And the response status should be 200
Original file line number Diff line number Diff line change @@ -7,3 +7,4 @@ export * from './puzzleDeliverer'
7
7
export * from './puzzleDelivery'
8
8
export * from './puzzleDashboard'
9
9
export * from './revokePuzzle'
10
+ export * from './useCoupon'
Original file line number Diff line number Diff line change
1
+ import { IRequest } from 'itty-router'
2
+ import { OpenAPIRoute , OpenAPIRouteSchema } from '@cloudflare/itty-router-openapi'
3
+ import { Put } from '@worker/router'
4
+ import { json } from '@worker/utils'
5
+ import * as schema from '@api/schema'
6
+
7
+ export type UseCouponRequest = IRequest
8
+
9
+ @Put ( '/event/puzzle/coupon' )
10
+ export class UseCoupon extends OpenAPIRoute {
11
+ static schema : OpenAPIRouteSchema = {
12
+ summary : "Use attendee's puzzle to redeem coupon" ,
13
+ tags : [ 'Puzzle' ] ,
14
+ requestBody : { } ,
15
+ parameters : {
16
+ event_id : schema . EventIdQuery ,
17
+ token : schema . OptionalAttendeeTokenQuery ,
18
+ } ,
19
+ responses : {
20
+ '200' : {
21
+ description : 'Result of coupon redemption' ,
22
+ schema : schema . puzzleCouponRedeemResponseSchema ,
23
+ } ,
24
+ } ,
25
+ }
26
+
27
+ async handle ( _request : UseCouponRequest , _env : unknown , _context : unknown ) {
28
+ return json ( { status : 'OK' } )
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments