-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added API for getting API information
- Loading branch information
1 parent
a4a4855
commit c344749
Showing
3 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/com/github/freebox/api/model/data/ApiInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |