Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhoneCode API #47 #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/routes/geo/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,16 @@ async def get_country_subdivisions(data: CountryCodeModel = Depends()):
return ok_200(res)
except Exception as e:
raise internal_error_500()

@country_router.get("/phonecodes")
async def get_country_phonecodes(data: CountryCodeModel = Depends()):
try:
res = co.code_to_phone_code(data.code)
if res:
return ok_200(res)
else:
return not_found_404("Phone code not found for the given country code.")
except KeyError:
return bad_request_400("Invalid country code provided.")
except Exception as e:
return internal_error_500(str(e))