private JSONObject buildServiceUsage (String orgId, String spaceId, String appId, String planId)
LocalDateTime now = LocalDateTime.now();
Timestamp timestamp = Timestamp.valueOf(now);
JSONObject jsonObjectUsage = new JSONObject ();
jsonObjectUsage.put ("start", timestamp.getTime());
jsonObjectUsage.put ("end", timestamp.getTime());
jsonObjectUsage.put ("organization_id", orgId);
jsonObjectUsage.put ("space_id", spaceId);
jsonObjectUsage.put ("consumer_id", "app:" + appId);
jsonObjectUsage.put ("resource_id", RESOURCE_ID);
jsonObjectUsage.put ("plan_id", planId);
jsonObjectUsage.put ("resource_instance_id", appId);
JSONArray measuredUsageArr = new JSONArray ();
JSONObject measuredUsage1 = new JSONObject ();
JSONObject measuredUsage2 = new JSONObject ();
JSONObject measuredUsage3 = new JSONObject ();
if (STANDARD_PLAN_ID.equals(planId)) {
quantity = PLAN_STANDARD_QUANTITY;
} else if (EXTRA_PLAN_ID.equals(planId)) {
quantity = PLAN_EXTRA_QUANTITY;
measuredUsage1.put ("measure", MEASURE_1);
measuredUsage1.put ("quantity", quantity);
measuredUsageArr.put(measuredUsage1);
measuredUsage2.put ("measure", MEASURE_2);
measuredUsage2.put ("quantity", 1);
measuredUsageArr.put(measuredUsage2);
measuredUsage3.put ("measure", MEASURE_3);
measuredUsage3.put ("quantity", 0);
measuredUsageArr.put(measuredUsage3);
jsonObjectUsage.put ("measured_usage", measuredUsageArr);