mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-26 20:22:22 +00:00
Docs
This commit is contained in:
parent
3edc57296d
commit
9d0d40fc15
@ -18,6 +18,19 @@ from synapse.api.errors import SynapseError
|
|||||||
|
|
||||||
|
|
||||||
def phone_number_to_msisdn(country, number):
|
def phone_number_to_msisdn(country, number):
|
||||||
|
"""
|
||||||
|
Takes an ISO-3166-1 2 letter country code and phone number and
|
||||||
|
returns an msisdn representing the canonical version of that
|
||||||
|
phone number.
|
||||||
|
Args:
|
||||||
|
country (str): ISO-3166-1 2 letter country code
|
||||||
|
number (str): Phone number in a national or international format
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
(str) The canonical form of the phone number, as an msisdn
|
||||||
|
Raises:
|
||||||
|
SynapseError if the number could not be parsed.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
phoneNumber = phonenumbers.parse(number, country)
|
phoneNumber = phonenumbers.parse(number, country)
|
||||||
except phonenumbers.NumberParseException:
|
except phonenumbers.NumberParseException:
|
||||||
|
Loading…
Reference in New Issue
Block a user