diff --git a/dialpad/resources/number.py b/dialpad/resources/number.py index 1f7bde4..695cbff 100644 --- a/dialpad/resources/number.py +++ b/dialpad/resources/number.py @@ -68,3 +68,19 @@ def assign(self, number, target_id, target_type, primary=True): 'target_type': target_type, 'primary': primary }) + + def format(self, number, country_code=None): + """Converts local number to E.164 or E.164 to local format. + + Args: + number (str, required): The phone number in local or E.164 format. + country_code (str, optional): Country code in ISO 3166-1 alpha-2 format such as "US". + Required when sending a local formatted phone number. + + See Also: + https://developers.dialpad.com/reference#formatapi_formatnumber + """ + return self.request(['format'], method='POST', data={ + 'number': number, + 'country_code': country_code + }) diff --git a/test/test_resource_sanity.py b/test/test_resource_sanity.py index e7b3f9f..7489d31 100644 --- a/test/test_resource_sanity.py +++ b/test/test_resource_sanity.py @@ -266,6 +266,10 @@ class TestResourceSanity: 'target_id': '123', 'target_type': 'office', }, + 'format': { + 'country_code': 'gb', + 'number': '020 3048 4377', + }, }, 'OfficeResource': { 'list': {},