Notifications
Clear all

[Solved] Found out the number of Address Component Needed for A country

2 Posts
3 Users
1 Reactions
1,088 Views
0
Topic starter

Is there a way in the code to find out the number of address component is needed for a particular country code?

For example, for US, it needs 4 and for UK, it needs 3.

Thanks.

2 Answers
1

Country Codes under new Devnet resources:

https://devnet.onenetwork.com/oms/apps/DeveloperNetwork/www/docs/api/javadoc/com/onenetwork/platform/common/address/CountryCodes.html

0

On the server (using private APIs):

AddressStructureHelper addrStructHelper = AddressConfigCacheManager.getAddressStructureHelper(CountryCodes.fromValue("US"));
AddressStructure addrStructure = addrStructHelper.getAddressStructure();

The resulting AddressStructure is a JAXB object that corresponds to the element in server/cfg/address/META-INF/AddressConfig.xml.

On the client:

You can use One.AddressStructureCache.getAddressStructure() to fetch the same structure in Javascript. The class is marked private in the documentation but the API is old and unlikely to change. If you're trying to access this information on the client, let me know and I can improve the documentation.