class ClientProcessor {

    public Map<String, String> getClientAddressAsMap(JSONObject client) {
        Map<String, String> addressMap = new HashMap<String, String>();
        try {
            String addressFieldsKey = "addressFields";
            String addressesKey = "addresses";

            if (client.has(addressesKey)) {
                JSONArray addressJsonArray = client.getJSONArray(addressesKey);

                if (addressJsonArray != null && addressJsonArray.length() > 0) {
                    JSONObject addressJson = addressJsonArray.getJSONObject(0);

                    // Need to handle multiple addresses as well
                    if (addressJson.has(addressFieldsKey)) {
                        JSONObject addressFields = addressJson.getJSONObject(addressFieldsKey);
                        Iterator<String> it = addressFields.keys();

                        while (it.hasNext()) {
                            String key = it.next();
                            String value = addressFields.getString(key);
                            addressMap.put(key, value);
                        }
                    }

                    //retrieve the other fields as well
                    Iterator<String> it = addressJson.keys();

                    while (it.hasNext()) {
                        String key = it.next();
                        boolean shouldSkipNode =
                                addressJson.get(key) instanceof JSONArray || addressJson
                                        .get(key) instanceof JSONObject;

                        if (!shouldSkipNode) {
                            String value = addressJson.getString(key);
                            addressMap.put(key, value);
                        }
                    }
                }
            }

        } catch (Exception e) {
            Timber.e(e);
        }
        return addressMap;
    }

    public  ClientProcessor(Context context);

}