summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2022-08-05 18:40:27 +0200
committercyBerta <cyberta@riseup.net>2022-08-05 18:40:27 +0200
commit598105bbaa383b27cadb682b76cdf00e5ad58369 (patch)
tree77effd84682014db0db950113cab239fa4370dc4 /app/src/main
parent689b6e9be05559b7e2cb1375e41e72c9d68b85d3 (diff)
add missing GatewayJson class
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/models/GatewayJson.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/GatewayJson.java b/app/src/main/java/se/leap/bitmaskclient/base/models/GatewayJson.java
new file mode 100644
index 00000000..8aca58c6
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/base/models/GatewayJson.java
@@ -0,0 +1,61 @@
+package se.leap.bitmaskclient.base.models;
+
+import androidx.annotation.NonNull;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.SerializedName;
+
+import org.json.JSONObject;
+
+public class GatewayJson {
+ private String location;
+ @SerializedName(value = "ip_address")
+ private String ipAddress;
+ @SerializedName(value = "ip_address6")
+ private String ipAddress6;
+ private String host;
+ private Capabilities capabilities;
+
+ public GatewayJson(String location, String ipAddress, String ipAddress6, String host, Capabilities capabilities) {
+ this.location = location;
+ this.ipAddress = ipAddress;
+ this.ipAddress6 = ipAddress6;
+ this.host = host;
+ this.capabilities = capabilities;
+ }
+
+ @NonNull
+ @Override
+ public String toString() {
+ return new Gson().toJson(this);
+ }
+
+ public static GatewayJson fromJson(JSONObject json) {
+ GsonBuilder builder = new GsonBuilder();
+ return builder.create().fromJson(json.toString(), GatewayJson.class);
+ }
+
+ public static class Capabilities {
+ private Boolean adblock;
+ @SerializedName(value = "filter_dns")
+ private Boolean filterDns;
+ private Boolean limited;
+ private Transport[] transport;
+ @SerializedName(value = "user_ips")
+ private Boolean userIps;
+
+ public Capabilities(Boolean adblock, Boolean filterDns, Boolean limited, Transport[] transport, Boolean userIps) {
+ this.adblock = adblock;
+ this.filterDns = filterDns;
+ this.limited = limited;
+ this.transport = transport;
+ this.userIps = userIps;
+ }
+ @NonNull
+ @Override
+ public String toString() {
+ return new Gson().toJson(this);
+ }
+ }
+}