Skip to content

Commit

Permalink
feat(api): raise 403 on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DlieBG committed Mar 8, 2024
1 parent 2982e5d commit 0b646ac
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions api/src/main.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
from models import ResponseDto, BalanceRequestDto, BookingRequestDto
from atoss import get_balance, post_booking
from fastapi import FastAPI
from fastapi import FastAPI, HTTPException


app = FastAPI()

@app.post('/api/balance')
def balance(body: BalanceRequestDto) -> ResponseDto:
return get_balance(
personal_number=body.personal_number,
pin=body.pin,
)
try:
return get_balance(
personal_number=body.personal_number,
pin=body.pin,
)
except:
raise HTTPException(status_code=403)

@app.post('/api/booking')
def booking(body: BookingRequestDto) -> ResponseDto:
return post_booking(
personal_number=body.personal_number,
pin=body.pin,
action=body.action,
type=body.type,
)

try:
return post_booking(
personal_number=body.personal_number,
pin=body.pin,
action=body.action,
type=body.type,
)
except:
raise HTTPException(status_code=403)

0 comments on commit 0b646ac

Please sign in to comment.