String category = namespace.getString("category");
String subcategory = namespace.getString("subcategory");
Integer offset = namespace.getInt("offset");
Integer number = namespace.getInt("number");
ListResponse listResponse = service.list(category, subcategory, offset, number);
if (subcategory == null) {
System.out.println(SUBCATEGORIES_HEADER);
for (DocV2 child : listResponse.getDocList()) {
String formatted = new StringJoiner(DELIMETER).add(child.getDocid()).add(child.getTitle()).toString();
System.out.println(formatted);
}
} else {
System.out.println(LIST_HEADER);
for (DocV2 child : listResponse.getDoc(0).getChildList()) {
AppDetails appDetails = child.getDetails().getAppDetails();
String formatted = new StringJoiner(DELIMETER).add(child.getTitle()).add(appDetails.getPackageName())
.add(child.getCreator()).add(child.getOffer(0).getFormattedAmount())
.add(String.valueOf(appDetails.getInstallationSize())).add(appDetails.getNumDownloads())
.toString();