diff --git a/pom.xml b/pom.xml index 7f0a055..04253af 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.freebox freebox-java-helper jar - 1.1.8 + 1.1.9 FreeBox Java Helper diff --git a/src/main/java/com/github/freebox/api/FreeBoxHelper.java b/src/main/java/com/github/freebox/api/FreeBoxHelper.java index 2c41750..5e916b1 100644 --- a/src/main/java/com/github/freebox/api/FreeBoxHelper.java +++ b/src/main/java/com/github/freebox/api/FreeBoxHelper.java @@ -29,6 +29,7 @@ import com.github.freebox.api.model.LogoutApiResponse; import com.github.freebox.api.model.ServerApiVersionApiResponse; import com.github.freebox.api.model.ServerAuthorizeStatusApiResponse; +import com.github.freebox.api.model.data.ApiInformation; import com.github.freebox.api.model.data.ApplicationDefinition; import com.github.freebox.api.model.data.CallEntry; import com.github.freebox.api.model.data.L2Identification; @@ -300,6 +301,19 @@ public List getCallLog() { return null; } + + /** + *

Returns technical information about the Freebox server API + *

+ * @return The Freebox Server API information + */ + public ApiInformation getApiInformation() { + + HttpResponse response = Unirest.get(serverApiMetadata.getApiEndpoint()+"/api_version/") + .asObject(ApiInformation.class); + + return response.getBody(); + } /** *

Returns technical information about the Freebox server (version, CPU temperature, model...) diff --git a/src/main/java/com/github/freebox/api/model/data/ApiInformation.java b/src/main/java/com/github/freebox/api/model/data/ApiInformation.java new file mode 100644 index 0000000..76a292a --- /dev/null +++ b/src/main/java/com/github/freebox/api/model/data/ApiInformation.java @@ -0,0 +1,80 @@ +package com.github.freebox.api.model.data; + +public class ApiInformation { + private String box_model_name; + private String api_base_url; + private String https_port; + private String device_name; + private String https_available; + private String box_model; + private String api_domain; + private String uid; + private String api_version; + private String device_type; + + public String getBoxModelName() { + return box_model_name; + } + public String getApiBaseUrl() { + return api_base_url; + } + public String getHttpsPort() { + return https_port; + } + public String getDeviceName() { + return device_name; + } + public boolean isHttpsAvailable() { + if("true".contentEquals(https_available)) + return true; + return false; + } + public String getBoxModel() { + return box_model; + } + public String getApiDomain() { + return api_domain; + } + public String getUid() { + return uid; + } + public String getApiVersion() { + return api_version; + } + public String getDeviceType() { + return device_type; + } + + public String getApiEndpoint() { + StringBuffer buf = new StringBuffer(); + + if(isHttpsAvailable()) + buf.append("https://"); + else + buf.append("http://"); + buf.append(getApiDomain()); + buf.append(":"); + buf.append(getHttpsPort()); + buf.append(getApiBaseUrl()); + buf.append("v"); + buf.append(getApiVersion().substring(0,1)); + + + return buf.toString(); + } + + public String toString() { + StringBuffer buf = new StringBuffer(); + + buf.append(getDeviceName()); + buf.append(" "+getUid()); + buf.append(" ("); + buf.append(getDeviceType()); + buf.append("), "); + + buf.append("API URL: "); + buf.append(getApiEndpoint()); + + return buf.toString(); + } +}