diff --git a/src/main/java/synapticloop/linode/api/response/AccountEstimateInvoiceResponse.java b/src/main/java/synapticloop/linode/api/response/AccountEstimateInvoiceResponse.java index d4a0fda..6e2a560 100644 --- a/src/main/java/synapticloop/linode/api/response/AccountEstimateInvoiceResponse.java +++ b/src/main/java/synapticloop/linode/api/response/AccountEstimateInvoiceResponse.java @@ -36,11 +36,8 @@ public AccountEstimateInvoiceResponse(JSONObject jsonObject) throws ApiException if(!hasErrors()) { JSONObject dataObject = jsonObject.getJSONObject(JSON_KEY_DATA); - this.invoiceTo = ResponseHelper.convertDate(dataObject.getString(JSON_KEY_INVOICE_TO)); - dataObject.remove(JSON_KEY_INVOICE_TO); - - this.amount = dataObject.getDouble(JSON_KEY_AMOUNT); - dataObject.remove(JSON_KEY_AMOUNT); + this.invoiceTo = readDate(dataObject, JSON_KEY_INVOICE_TO); + this.amount = readDouble(dataObject, JSON_KEY_AMOUNT); ResponseHelper.warnOnMissedKeys(LOGGER, dataObject); } diff --git a/src/main/java/synapticloop/linode/api/response/AccountInfoResponse.java b/src/main/java/synapticloop/linode/api/response/AccountInfoResponse.java index fc7c4e5..18d47ad 100644 --- a/src/main/java/synapticloop/linode/api/response/AccountInfoResponse.java +++ b/src/main/java/synapticloop/linode/api/response/AccountInfoResponse.java @@ -54,20 +54,14 @@ public AccountInfoResponse(JSONObject jsonObject) throws ApiException { if(!hasErrors()) { JSONObject dataObject = jsonObject.getJSONObject(JSON_KEY_DATA); - this.activeSince = ResponseHelper.convertDate(dataObject.getString("ACTIVE_SINCE")); - dataObject.remove("ACTIVE_SINCE"); - this.transferPool = dataObject.getLong("TRANSFER_POOL"); - dataObject.remove("TRANSFER_POOL"); - this.transferUsed = dataObject.getLong("TRANSFER_USED"); - dataObject.remove("TRANSFER_USED"); - this.transferBillable = dataObject.getLong("TRANSFER_BILLABLE"); - dataObject.remove("TRANSFER_BILLABLE"); - this.isManaged = dataObject.getBoolean("MANAGED"); - dataObject.remove("MANAGED"); - this.billingMethod = dataObject.getString("BILLING_METHOD"); - dataObject.remove("BILLING_METHOD"); - this.balance = dataObject.getLong("BALANCE"); - dataObject.remove("BALANCE"); + + this.activeSince = readDate(dataObject, JSON_KEY_ACTIVE_SINCE); + this.transferPool = readLong(dataObject, JSON_KEY_TRANSFER_POOL); + this.transferUsed = readLong(dataObject, JSON_KEY_TRANSFER_USED); + this.transferBillable = readLong(dataObject, JSON_KEY_TRANSFER_BILLABLE); + this.isManaged = readBoolean(dataObject, JSON_KEY_MANAGED); + this.billingMethod = readString(dataObject, JSON_KEY_BILLING_METHOD); + this.balance = readLong(dataObject, JSON_KEY_BALANCE); ResponseHelper.warnOnMissedKeys(LOGGER, dataObject); } diff --git a/src/main/java/synapticloop/linode/api/response/ApiSpecResponse.java b/src/main/java/synapticloop/linode/api/response/ApiSpecResponse.java index ac4ecb5..f1ebc4a 100644 --- a/src/main/java/synapticloop/linode/api/response/ApiSpecResponse.java +++ b/src/main/java/synapticloop/linode/api/response/ApiSpecResponse.java @@ -78,8 +78,8 @@ public ApiSpecResponse(JSONObject jsonObject) { jsonObject.remove(JSON_KEY_DATA); ResponseHelper.warnOnMissedKeys(LOGGER, jsonObject); - } + public List getMethods() { return this.methods; } diff --git a/src/main/java/synapticloop/linode/api/response/BaseResponse.java b/src/main/java/synapticloop/linode/api/response/BaseResponse.java index 3a32a1d..04d20a6 100644 --- a/src/main/java/synapticloop/linode/api/response/BaseResponse.java +++ b/src/main/java/synapticloop/linode/api/response/BaseResponse.java @@ -37,6 +37,14 @@ public abstract class BaseResponse extends BaseJsonReader { protected static final String JSON_KEY_METHODS = "METHODS"; protected static final String JSON_KEY_INVOICE_TO = "INVOICE_TO"; protected static final String JSON_KEY_AMOUNT = "AMOUNT"; + protected static final String JSON_KEY_BALANCE = "BALANCE"; + protected static final String JSON_KEY_BILLING_METHOD = "BILLING_METHOD"; + protected static final String JSON_KEY_MANAGED = "MANAGED"; + protected static final String JSON_KEY_TRANSFER_BILLABLE = "TRANSFER_BILLABLE"; + protected static final String JSON_KEY_TRANSFER_USED = "TRANSFER_USED"; + protected static final String JSON_KEY_TRANSFER_POOL = "TRANSFER_POOL"; + protected static final String JSON_KEY_ACTIVE_SINCE = "ACTIVE_SINCE"; + private final JSONObject jsonObject;