SDK to connect you Android app to Giganter API.
Add this in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
And this in you app build.gradle:
dependencies {
implementation 'com.github.gigantier:android-sdk:1.0.2'
}
To get started, instantiate a new Gigantier client with your credentials.
Note: This requires a Gigantier account.
Config config = new Config();
config.clientId = "XXX";
config.clientSecret = "XXX";
config.scope = "XXX";
config.host = "somehost.com";
config.application = "My App Name";
Gigantier gigantier = new Gigantier(context, config);
Check out the API reference to learn more about authenticating and the available endpoints.
Here is an example of api call:
gigantier.call("/Category/list", new ResponseListener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// ...
}
}, new ErrorListener() {
@Override
public void onError(int code, String msg) {
// ...
}
});
Some endpoints need the user to be authenticated, once they are obtained, the authenticate()
method must be called:
gigantier.authenticate("foo@test.com", "1111111", new ResponseListener<Credential>() {
@Override
public void onResponse(Credential response) {
// ...
}
}, new ErrorListener() {
@Override
public void onError(int code, String msg) {
// ...
}
});
Here is an example of and authenticated api call. Keep in mind that the method authenticate()
must be executed first:
gigantier.authenticatedCall("/User/me", new ResponseListener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// ...
}
}, new ErrorListener() {
@Override
public void onError(int code, String msg) {
// ...
}
});
To perform data post you need to pass a map with that data to call()
method:
Map<String, Object> data = new HashMap<>();
data.put("name", "John");
data.put("surname", "Doe");
gigantier.call("/User/me", data, new ResponseListener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// ...
}
}, new ErrorListener() {
@Override
public void onError(int code, String msg) {
// ...
}
});
Thank you for considering contributing to Gigantier Android SDK.