com.starksign.utils.Rest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk Show documentation
Show all versions of sdk Show documentation
Welcome to the Stark Sign Java SDK! This tool is made for Java developers who want to easily integrate with our API. This SDK version is compatible with the Stark Sign API v2.
The newest version!
package com.starksign.utils;
import com.google.gson.*;
import java.lang.reflect.Type;
import java.util.*;
public final class Rest {
public static T getId(Resource.ClassData resource, String id, Map query) throws Exception {
String content = Response.fetch(Api.endpoint(resource, id), "GET", null, query).content();
Gson gson = GsonEvent.getInstance();
JsonObject contentJson = gson.fromJson(content, JsonObject.class);
JsonObject jsonObject = contentJson.get(Api.getLastName(resource)).getAsJsonObject();
return gson.fromJson(jsonObject, (Type) resource.cls);
}
public static T postSubResource(Resource.ClassData resource, String id, SubResource.ClassData subResource, SubResource entity) throws Exception {
JsonObject payload = (JsonObject) new Gson().toJsonTree((entity));
String content = Response.fetch(
Api.endpoint(resource, id) + Api.endpoint(subResource),
"POST",
payload,
new HashMap<>()
).content();
JsonObject contentJson = new Gson().fromJson(content, JsonObject.class);
JsonObject jsonObject = contentJson.get(Api.getLastName(subResource)).getAsJsonObject();
return GsonEvent.getInstance().fromJson(jsonObject, (Type) subResource.cls);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy