Skip to content

Commit

Permalink
Adds format number endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dp-rufus committed Jul 7, 2021
1 parent 3878e27 commit 4564a74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dialpad/resources/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
4 changes: 4 additions & 0 deletions test/test_resource_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ class TestResourceSanity:
'target_id': '123',
'target_type': 'office',
},
'format': {
'country_code': 'gb',
'number': '020 3048 4377',
},
},
'OfficeResource': {
'list': {},
Expand Down

0 comments on commit 4564a74

Please sign in to comment.