Commit f5be9d34 authored by Ivan Del Pino's avatar Ivan Del Pino Committed by Rafael Jesus Hernández Vasquez
Browse files

feat: improve interface callback response


Signed-off-by: default avatarIvan Del Pino <idelpino@teclib.com>
parent 8efdffcf
...@@ -44,6 +44,7 @@ import com.orhanobut.logger.PrettyFormatStrategy; ...@@ -44,6 +44,7 @@ import com.orhanobut.logger.PrettyFormatStrategy;
import org.glpi.api.GLPI; import org.glpi.api.GLPI;
import org.glpi.api.itemType; import org.glpi.api.itemType;
import org.glpi.api.response.FullSessionModel;
import org.glpi.api.response.InitSession; import org.glpi.api.response.InitSession;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -123,7 +124,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -123,7 +124,7 @@ public class MainActivity extends AppCompatActivity {
private void btnKill() { private void btnKill() {
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
resultList.clear(); resultList.clear();
glpi.killSession(new GLPI.VoidCallback() { glpi.killSession(new GLPI.ResponseHandle<String, String>() {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
FlyveLog.i("killSession: %s", response.toString()); FlyveLog.i("killSession: %s", response.toString());
...@@ -145,7 +146,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -145,7 +146,7 @@ public class MainActivity extends AppCompatActivity {
private void btnInit() { private void btnInit() {
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
resultList.clear(); resultList.clear();
glpi.initSessionByUserToken(data.getUserToken(), new GLPI.InitSessionCallback() { glpi.initSessionByUserToken(data.getUserToken(), new GLPI.ResponseHandle<InitSession, String>() {
@Override @Override
public void onResponse(InitSession response) { public void onResponse(InitSession response) {
updateAdapter("Success: Init Session User Token"); updateAdapter("Success: Init Session User Token");
...@@ -153,32 +154,48 @@ public class MainActivity extends AppCompatActivity { ...@@ -153,32 +154,48 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void onFailure(String errorMessage) { public void onFailure(String errorMessage) {
updateAdapter("Error: Init Session User Token"); updateAdapter("Error: Init Session User Token" + errorMessage);
} }
}); });
glpi.initSessionByCredentials(BuildConfig.GLPI_USER, BuildConfig.GLPI_PASSWORD, new GLPI.InitSessionCallback() { String token = glpi.initSessionByCredentialsSync(BuildConfig.GLPI_USER, BuildConfig.GLPI_PASSWORD);
FlyveLog.i("initSession: %s", token);
updateAdapter("Success: Init Session Credentials");
glpi.fullSession(new GLPI.ResponseHandle<FullSessionModel, String>() {
@Override
public void onResponse(FullSessionModel response) {
FlyveLog.i("Full Session: %s", response.toString());
updateAdapter("Success: Full Session");
}
@Override
public void onFailure(String errorMessage) {
FlyveLog.i("Full Session: %s", errorMessage);
updateAdapter("Error: Full Session");
}
});
GLPI.ResponseHandle<InitSession, String> handle = new GLPI.ResponseHandle<InitSession, String>() {
@Override @Override
public void onResponse(InitSession response) { public void onResponse(InitSession response) {
FlyveLog.i("initSession: %s", response.getSessionToken()); FlyveLog.i("initSession: %s", response.getSessionToken());
updateAdapter("Success: Init Session Credentials"); updateAdapter("Success: Init Session Credentials");
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.VISIBLE);
} }
@Override @Override
public void onFailure(String errorMessage) { public void onFailure(String errorMessage) {
updateAdapter("Error: Init Session Credentials"); updateAdapter("Error: Init Session Credentials" + errorMessage);
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.VISIBLE);
} }
}); };
glpi.initSessionByCredentials(BuildConfig.GLPI_USER, BuildConfig.GLPI_PASSWORD, handle);
} }
private void btnCall() { private void btnCall() {
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
resultList.clear(); resultList.clear();
glpi.getMyProfiles(new GLPI.JsonObjectCallback() { glpi.getMyProfiles(new GLPI.ResponseHandle<JsonObject, String>() {
@Override @Override
public void onResponse(JsonObject response) { public void onResponse(JsonObject response) {
FlyveLog.i("getMyProfiles: %s", response.toString()); FlyveLog.i("getMyProfiles: %s", response.toString());
...@@ -192,7 +209,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -192,7 +209,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.getActiveProfile(new GLPI.JsonObjectCallback() { glpi.getActiveProfile(new GLPI.ResponseHandle<JsonObject, String>() {
@Override @Override
public void onResponse(JsonObject response) { public void onResponse(JsonObject response) {
FlyveLog.i("getActiveProfile: %s", response.toString()); FlyveLog.i("getActiveProfile: %s", response.toString());
...@@ -206,7 +223,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -206,7 +223,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.getMyEntities(new GLPI.JsonObjectCallback() { glpi.getMyEntities(new GLPI.ResponseHandle<JsonObject, String>() {
@Override @Override
public void onResponse(JsonObject response) { public void onResponse(JsonObject response) {
FlyveLog.i("getMyEntities: %s", response.toString()); FlyveLog.i("getMyEntities: %s", response.toString());
...@@ -220,7 +237,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -220,7 +237,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.getActiveEntities(new GLPI.JsonObjectCallback() { glpi.getActiveEntities(new GLPI.ResponseHandle<JsonObject, String>() {
@Override @Override
public void onResponse(JsonObject response) { public void onResponse(JsonObject response) {
FlyveLog.i("getActiveEntities: %s", response.toString()); FlyveLog.i("getActiveEntities: %s", response.toString());
...@@ -234,7 +251,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -234,7 +251,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.getFullSession(new GLPI.JsonObjectCallback() { glpi.getFullSession(new GLPI.ResponseHandle<JsonObject, String>() {
@Override @Override
public void onResponse(JsonObject response) { public void onResponse(JsonObject response) {
FlyveLog.i("getFullSession: %s", response.toString()); FlyveLog.i("getFullSession: %s", response.toString());
...@@ -248,7 +265,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -248,7 +265,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.getGlpiConfig(new GLPI.JsonObjectCallback() { glpi.getGlpiConfig(new GLPI.ResponseHandle<JsonObject, String>() {
@Override @Override
public void onResponse(JsonObject response) { public void onResponse(JsonObject response) {
FlyveLog.i("getGlpiConfig: %s", response.toString()); FlyveLog.i("getGlpiConfig: %s", response.toString());
...@@ -262,7 +279,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -262,7 +279,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.getAllItems(itemType.Computer, new GLPI.JsonArrayCallback() { glpi.getAllItems(itemType.Computer, new GLPI.ResponseHandle<JsonArray, String>() {
@Override @Override
public void onResponse(JsonArray response) { public void onResponse(JsonArray response) {
FlyveLog.i("getAllItems: %s", response.toString()); FlyveLog.i("getAllItems: %s", response.toString());
...@@ -276,7 +293,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -276,7 +293,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.getItem(itemType.Computer, "110", new GLPI.JsonObjectCallback() { glpi.getItem(itemType.Computer, "110", new GLPI.ResponseHandle<JsonObject, String>() {
@Override @Override
public void onResponse(JsonObject response) { public void onResponse(JsonObject response) {
FlyveLog.i("getAnItem: %s", response.toString()); FlyveLog.i("getAnItem: %s", response.toString());
...@@ -290,7 +307,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -290,7 +307,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.getSubItems(itemType.Computer, "2", itemType.ComputerType, new GLPI.JsonObjectCallback() { GLPI.ResponseHandle<JsonObject, String> responseHandle = new GLPI.ResponseHandle<JsonObject, String>() {
@Override @Override
public void onResponse(JsonObject response) { public void onResponse(JsonObject response) {
FlyveLog.i("getSubItems", response.toString()); FlyveLog.i("getSubItems", response.toString());
...@@ -302,9 +319,10 @@ public class MainActivity extends AppCompatActivity { ...@@ -302,9 +319,10 @@ public class MainActivity extends AppCompatActivity {
FlyveLog.e("getSubItems: %s", errorMessage); FlyveLog.e("getSubItems: %s", errorMessage);
updateAdapter("Error: sub items"); updateAdapter("Error: sub items");
} }
}); };
glpi.getSubItems(itemType.Computer, "2", itemType.ComputerType, responseHandle);
glpi.changeActiveProfile("9", new GLPI.VoidCallback() { glpi.changeActiveProfile("9", new GLPI.ResponseHandle<String, String>() {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
FlyveLog.i("changeActiveProfile: %s", response); FlyveLog.i("changeActiveProfile: %s", response);
...@@ -318,7 +336,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -318,7 +336,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.changeActiveEntities("1", false, new GLPI.VoidCallback() { glpi.changeActiveEntities("1", false, new GLPI.ResponseHandle<String, String>() {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
FlyveLog.i("changeActiveEntities: %s", response); FlyveLog.i("changeActiveEntities: %s", response);
...@@ -343,21 +361,18 @@ public class MainActivity extends AppCompatActivity { ...@@ -343,21 +361,18 @@ public class MainActivity extends AppCompatActivity {
addItemExamplePayload obj = new addItemExamplePayload(list); addItemExamplePayload obj = new addItemExamplePayload(list);
glpi.addItems(itemType.Computer, obj, new GLPI.JsonArrayCallback() { glpi.addItems(itemType.Computer, obj, new GLPI.ResponseHandle<JsonArray, String>() {
@Override @Override
public void onResponse(JsonArray response) { public void onResponse(JsonArray response) {
FlyveLog.i("addItems: %s", response.toString());
updateAdapter("Success: add items");
} }
@Override @Override
public void onFailure(String errorMessage) { public void onFailure(String errorMessage) {
FlyveLog.e("addItems: %s", errorMessage);
updateAdapter("Error: add items");
} }
}); });
glpi.updateItems(itemType.Computer, "10", obj, new GLPI.ResponseHandle<JsonArray, String>() {
glpi.updateItems(itemType.Computer, "10", obj, new GLPI.JsonArrayCallback() {
@Override @Override
public void onResponse(JsonArray response) { public void onResponse(JsonArray response) {
FlyveLog.i("updateItems: %s", response.toString()); FlyveLog.i("updateItems: %s", response.toString());
...@@ -371,7 +386,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -371,7 +386,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.deleteItems(itemType.Computer, "10", new GLPI.JsonArrayCallback() { glpi.deleteItems(itemType.Computer, "10", new GLPI.ResponseHandle<JsonArray, String>() {
@Override @Override
public void onResponse(JsonArray response) { public void onResponse(JsonArray response) {
FlyveLog.i("deleteItems: %s", response.toString()); FlyveLog.i("deleteItems: %s", response.toString());
...@@ -396,7 +411,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -396,7 +411,7 @@ public class MainActivity extends AppCompatActivity {
deleteItemExamplePayload deleteObj = new deleteItemExamplePayload(deleteList); deleteItemExamplePayload deleteObj = new deleteItemExamplePayload(deleteList);
glpi.deleteItems(itemType.Computer, deleteObj, new GLPI.JsonArrayCallback() { glpi.deleteItems(itemType.Computer, deleteObj, new GLPI.ResponseHandle<JsonArray, String>() {
@Override @Override
public void onResponse(JsonArray response) { public void onResponse(JsonArray response) {
FlyveLog.i("deleteItems: %s", response.toString()); FlyveLog.i("deleteItems: %s", response.toString());
...@@ -410,7 +425,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -410,7 +425,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.recoveryPassword("youremail@yourdomain.com", new GLPI.VoidCallback() { glpi.recoveryPassword("youremail@yourdomain.com", new GLPI.ResponseHandle<String, String>() {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
FlyveLog.i("lostPassword: %s", response); FlyveLog.i("lostPassword: %s", response);
...@@ -424,7 +439,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -424,7 +439,7 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
glpi.resetPassword("youremail@yourdomain.com", "asdfasdfafsASDFd333A", "1234", new GLPI.VoidCallback() { GLPI.ResponseHandle<String, String> callback = new GLPI.ResponseHandle<String, String>() {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
FlyveLog.i("recoveryPassword: %s", response); FlyveLog.i("recoveryPassword: %s", response);
...@@ -440,7 +455,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -440,7 +455,8 @@ public class MainActivity extends AppCompatActivity {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.VISIBLE);
} }
}); };
glpi.resetPassword("youremail@yourdomain.com", "asdfasdfafsASDFd333A", "1234", callback);
} }
private void updateAdapter(String message) { private void updateAdapter(String message) {
......
...@@ -27,7 +27,7 @@ public class GLPITest { ...@@ -27,7 +27,7 @@ public class GLPITest {
public void initSessionTest() throws Exception { public void initSessionTest() throws Exception {
if (!BuildConfig.GLPI_URL.equals("")) { if (!BuildConfig.GLPI_URL.equals("")) {
GLPI glpi = new GLPI(appContext, BuildConfig.GLPI_URL); GLPI glpi = new GLPI(appContext, BuildConfig.GLPI_URL);
glpi.initSessionByCredentials(BuildConfig.GLPI_USER, BuildConfig.GLPI_PASSWORD, new GLPI.InitSessionCallback() { glpi.initSessionByCredentials(BuildConfig.GLPI_USER, BuildConfig.GLPI_PASSWORD, new GLPI.ResponseHandle<InitSession, String>() {
@Override @Override
public void onResponse(InitSession response) { public void onResponse(InitSession response) {
String sessionToken = response.getSessionToken(); String sessionToken = response.getSessionToken();
......
...@@ -39,6 +39,7 @@ import org.glpi.api.request.ChangeActiveEntitiesRequest; ...@@ -39,6 +39,7 @@ import org.glpi.api.request.ChangeActiveEntitiesRequest;
import org.glpi.api.request.ChangeActiveProfileRequest; import org.glpi.api.request.ChangeActiveProfileRequest;
import org.glpi.api.request.RecoveryPasswordRequest; import org.glpi.api.request.RecoveryPasswordRequest;
import org.glpi.api.request.ResetPasswordRequest; import org.glpi.api.request.ResetPasswordRequest;
import org.glpi.api.response.FullSessionModel;
import org.glpi.api.response.InitSession; import org.glpi.api.response.InitSession;
import org.glpi.api.utils.Helpers; import org.glpi.api.utils.Helpers;
...@@ -74,7 +75,7 @@ public class GLPI extends ServiceGenerator { ...@@ -74,7 +75,7 @@ public class GLPI extends ServiceGenerator {
* @param userToken defined in User Preference (See 'Remote access key' on GLPI) * @param userToken defined in User Preference (See 'Remote access key' on GLPI)
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void initSessionByUserToken(String userToken, final InitSessionCallback callback) { public void initSessionByUserToken(String userToken, final ResponseHandle<InitSession, String> callback) {
Call<InitSession> call = interfaces.initSessionByUserToken(userToken, userToken); Call<InitSession> call = interfaces.initSessionByUserToken(userToken, userToken);
responseInitSession(callback, call); responseInitSession(callback, call);
} }
...@@ -106,24 +107,55 @@ public class GLPI extends ServiceGenerator { ...@@ -106,24 +107,55 @@ public class GLPI extends ServiceGenerator {
* @param password valid password on GLPI * @param password valid password on GLPI
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void initSessionByCredentials(String user, String password, final InitSessionCallback callback) { public void initSessionByCredentials(String user, String password, final ResponseHandle<InitSession, String> callback) {
this.appToken = null; this.appToken = null;
String authorization = Helpers.base64encode(user + ":" + password); String authorization = Helpers.base64encode(user + ":" + password);
responseInitSession(callback, interfaces.initSessionByCredentials("Basic " + authorization.trim())); responseInitSession(callback, interfaces.initSessionByCredentials("Basic " + authorization.trim()));
} }
public void fullSession(final ResponseHandle<FullSessionModel, String> callback) {
HashMap<String, String> header = new HashMap<>();
header.put("Session-Token", sessionToken);
header.put("Accept", "application/json");
header.put("Content-Type", "application/json" + ";" + "charset=UTF-8");
header.put("User-Agent", "Flyve MDM");
header.put("Referer", "/getFullSession");
interfaces.fullSession(header).enqueue(new Callback<FullSessionModel>() {
@Override
public void onResponse(@NonNull Call<FullSessionModel> call, @NonNull Response<FullSessionModel> response) {
if (response.isSuccessful()) {
callback.onResponse(response.body());
} else {
String errorMessage;
try {
assert response.errorBody() != null;
errorMessage = response.errorBody().string();
} catch (Exception ex) {
errorMessage = context.getResources().getString(R.string.error_generic);
}
callback.onFailure(errorMessage);
}
}
@Override
public void onFailure(@NonNull Call<FullSessionModel> call, @NonNull Throwable t) {
callback.onFailure(t.getMessage());
}
});
}
/** /**
* This endpoint allows to request password reset * This endpoint allows to request password reset
* *
* @param email email address of the user to recover * @param email email address of the user to recover
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void recoveryPassword(String email, final VoidCallback callback) { public void recoveryPassword(String email, final ResponseHandle<String, String> callback) {
RecoveryPasswordRequest requestPost = new RecoveryPasswordRequest(email); RecoveryPasswordRequest requestPost = new RecoveryPasswordRequest(email);
responseInitSession(callback, interfaces.lostPassword(requestPost), R.string.lost_password_success); responseInitSession(callback, interfaces.lostPassword(requestPost), R.string.lost_password_success);
} }
private void responseInitSession(final InitSessionCallback callback, Call<InitSession> responseCall) { private void responseInitSession(final ResponseHandle<InitSession, String> callback, Call<InitSession> responseCall) {
responseCall.enqueue(new Callback<InitSession>() { responseCall.enqueue(new Callback<InitSession>() {
@Override @Override
public void onResponse(@NonNull Call<InitSession> call, @NonNull Response<InitSession> response) { public void onResponse(@NonNull Call<InitSession> call, @NonNull Response<InitSession> response) {
...@@ -157,7 +189,7 @@ public class GLPI extends ServiceGenerator { ...@@ -157,7 +189,7 @@ public class GLPI extends ServiceGenerator {
* *
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getMyProfiles(final JsonObjectCallback callback) { public void getMyProfiles(final ResponseHandle<JsonObject, String> callback) {
responseJsonObject(callback, interfaces.getMyProfiles(getHeader())); responseJsonObject(callback, interfaces.getMyProfiles(getHeader()));
} }
...@@ -166,7 +198,7 @@ public class GLPI extends ServiceGenerator { ...@@ -166,7 +198,7 @@ public class GLPI extends ServiceGenerator {
* *
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getActiveProfile(final JsonObjectCallback callback) { public void getActiveProfile(final ResponseHandle<JsonObject, String> callback) {
responseJsonObject(callback, interfaces.getActiveProfile(getHeader())); responseJsonObject(callback, interfaces.getActiveProfile(getHeader()));
} }
...@@ -175,7 +207,7 @@ public class GLPI extends ServiceGenerator { ...@@ -175,7 +207,7 @@ public class GLPI extends ServiceGenerator {
* *
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getMyEntities(final JsonObjectCallback callback) { public void getMyEntities(final ResponseHandle<JsonObject, String> callback) {
responseJsonObject(callback, interfaces.getMyEntities(getHeader())); responseJsonObject(callback, interfaces.getMyEntities(getHeader()));
} }
...@@ -184,7 +216,7 @@ public class GLPI extends ServiceGenerator { ...@@ -184,7 +216,7 @@ public class GLPI extends ServiceGenerator {
* *
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getActiveEntities(final JsonObjectCallback callback) { public void getActiveEntities(final ResponseHandle<JsonObject, String> callback) {
responseJsonObject(callback, interfaces.getActiveEntities(getHeader())); responseJsonObject(callback, interfaces.getActiveEntities(getHeader()));
} }
...@@ -193,7 +225,7 @@ public class GLPI extends ServiceGenerator { ...@@ -193,7 +225,7 @@ public class GLPI extends ServiceGenerator {
* *
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getFullSession(final JsonObjectCallback callback) { public void getFullSession(final ResponseHandle<JsonObject, String> callback) {
responseJsonObject(callback, interfaces.getFullSession(getHeader())); responseJsonObject(callback, interfaces.getFullSession(getHeader()));
} }
...@@ -202,7 +234,7 @@ public class GLPI extends ServiceGenerator { ...@@ -202,7 +234,7 @@ public class GLPI extends ServiceGenerator {
* *
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getGlpiConfig(final JsonObjectCallback callback) { public void getGlpiConfig(final ResponseHandle<JsonObject, String> callback) {
responseJsonObject(callback, interfaces.getGlpiConfig(getHeader())); responseJsonObject(callback, interfaces.getGlpiConfig(getHeader()));
} }
...@@ -213,7 +245,7 @@ public class GLPI extends ServiceGenerator { ...@@ -213,7 +245,7 @@ public class GLPI extends ServiceGenerator {
* @param id unique identifier of the itemtype * @param id unique identifier of the itemtype
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getItem(itemType itemType, String id, final JsonObjectCallback callback) { public void getItem(itemType itemType, String id, final ResponseHandle<JsonObject, String> callback) {
Map<String, String> options = new GetAnItemQuery().getQuery(); Map<String, String> options = new GetAnItemQuery().getQuery();
responseJsonObject(callback, interfaces.getAnItem(getHeader(), itemType.name(), id, options)); responseJsonObject(callback, interfaces.getAnItem(getHeader(), itemType.name(), id, options));
} }
...@@ -226,7 +258,7 @@ public class GLPI extends ServiceGenerator { ...@@ -226,7 +258,7 @@ public class GLPI extends ServiceGenerator {
* @param subItemType These are the item type available on GLPI * @param subItemType These are the item type available on GLPI
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getSubItems(String itemType, String id, String subItemType, final JsonObjectCallback callback) { public void getSubItems(String itemType, String id, String subItemType, final ResponseHandle<JsonObject, String> callback) {
Map<String, String> options = new GetSubItemQuery(this.context).getQuery(); Map<String, String> options = new GetSubItemQuery(this.context).getQuery();
responseJsonObject(callback, interfaces.getSubItem(getHeader(), itemType, id, subItemType, options)); responseJsonObject(callback, interfaces.getSubItem(getHeader(), itemType, id, subItemType, options));
} }
...@@ -239,12 +271,12 @@ public class GLPI extends ServiceGenerator { ...@@ -239,12 +271,12 @@ public class GLPI extends ServiceGenerator {
* @param subItemType These are the item type available on GLPI * @param subItemType These are the item type available on GLPI
* @param callback here you are going to get the asynchronous response * @param callback here you are going to get the asynchronous response
*/ */
public void getSubItems(itemType itemType, String id, itemType subItemType, final JsonObjectCallback callback) {