def fetch(self, country_code=values.unset, type=values.unset, add_ons=values.unset, add_ons_data=values.unset): """ Fetch a PhoneNumberInstance :param unicode country_code: The ISO country code of the phone number :param unicode type: The type of information to return :param unicode add_ons: The unique_name of an Add-on you would like to invoke :param dict add_ons_data: Data specific to the add-on you would like to invoke :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance """ params = values.of({ 'CountryCode': country_code, 'Type': serialize.map(type, lambda e: e), 'AddOns': serialize.map(add_ons, lambda e: e), }) params.update( serialize.prefixed_collapsible_map(add_ons_data, 'AddOns')) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance( self._version, payload, phone_number=self._solution['phone_number'], )
def fetch(self, country_code=values.unset, type=values.unset, add_ons=values.unset, add_ons_data=values.unset): """ Fetch a PhoneNumberInstance :param unicode country_code: The ISO country code of the phone number :param unicode type: The type of information to return :param unicode add_ons: The unique_name of an Add-on you would like to invoke :param dict add_ons_data: Data specific to the add-on you would like to invoke :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance """ params = values.of({ 'CountryCode': country_code, 'Type': serialize.map(type, lambda e: e), 'AddOns': serialize.map(add_ons, lambda e: e), }) params.update(serialize.prefixed_collapsible_map(add_ons_data, 'AddOns')) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance(self._version, payload, phone_number=self._solution['phone_number'], )
def fetch(self, country_code=values.unset, type=values.unset, add_ons=values.unset, add_ons_data=values.unset): """ Fetch a PhoneNumberInstance :param unicode country_code: The country_code :param unicode type: The type :param unicode add_ons: The add_ons :param dict add_ons_data: The add_ons_data :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance """ params = values.of({ 'CountryCode': country_code, 'Type': serialize.map(type, lambda e: e), 'AddOns': serialize.map(add_ons, lambda e: e), }) params.update(serialize.prefixed_collapsible_map(add_ons_data, 'AddOns')) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance(self._version, payload, phone_number=self._solution['phone_number'], )
def test_list(self): value = [ 'foo', 'bar' ] actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({}, actual)
def fetch(self, country_code=values.unset, type=values.unset, add_ons=values.unset, add_ons_data=values.unset): """ Fetch a PhoneNumberInstance :param unicode country_code: Optional ISO country code of the phone number. :param unicode type: Indicates the type of information you would like returned with your request. :param unicode add_ons: Indicates the particular Add-on you would like to use to get more information. :param dict add_ons_data: The add_ons_data :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance """ params = values.of({ 'CountryCode': country_code, 'Type': serialize.map(type, lambda e: e), 'AddOns': serialize.map(add_ons, lambda e: e), }) params.update(serialize.prefixed_collapsible_map(add_ons_data, 'AddOns')) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance(self._version, payload, phone_number=self._solution['phone_number'], )
def test_single_key(self): value = { 'foo': 'bar' } actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({ 'Prefix.foo': 'bar' }, actual)
def test_multiple_keys(self): value = {'watson': {'language': 'en', 'alice': 'bob'}, 'foo': 'bar'} actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual( { 'Prefix.watson.language': 'en', 'Prefix.watson.alice': 'bob', 'Prefix.foo': 'bar' }, actual)
def test_nested_key(self): value = { 'foo': { 'bar': 'baz' } } actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({ 'Prefix.foo.bar': 'baz' }, actual)
def test_multiple_keys(self): value = { 'watson': { 'language': 'en', 'alice': 'bob' }, 'foo': 'bar' } actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({ 'Prefix.watson.language': 'en', 'Prefix.watson.alice': 'bob', 'Prefix.foo': 'bar' }, actual)
def test_unset(self): value = values.unset actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({}, actual)