The SDK is broken up into multiple libraries:
Component | Description |
---|---|
core | Core objects. Required. |
api | API requests. |
rxjava | RxJava objects. |
auth | OAuth2 helper objects. |
android | Android-specific objects. |
python-bridge | Allows core/api usage from python. |
See our wiki on instructions for adding the libraries to your application using gradle or maven. sbt and leinigen build configuration is also supported.
Use the PercolateApi
class to access an API endpoint by name. For example, PercolateApi#terms
is used to access
our v5/terms
endpoint. You can then call get()
, create()
, update()
, or delete()
on the returned object.
new PercolateApi(API_KEY)
.terms()
.get(params);
PercolateApi percolateApi = new PercolateApi(API_KEY);
TermsParams params = new TermsParams()
.scopeId("license:12345")
.search("abc");
Call<Terms> call = percolateApi.terms().get(params);
Terms terms = call.execute().body();
...
The returned Call
objects can be used in 1 of 2 ways:
Synchronously
Terms terms = call.execute().body();
Asynchronously
call.enqueue(new Callback<Terms>() {
@Override
public void onResponse(Call<Terms> call, Response<Terms> response) {
Terms terms = response.body();
...
}
@Override
public void onFailure(Call<Terms> call, Throwable t) { }
});
If you want to do reactive programming using RxJava then you can use the PercolateApiRx
class. The class provides methods that return an Observable
for an API endpoint. For example, PercolateApiRx#termsRx
returns an object
on which get()
, create()
and update()
methods can be invoked to get an Observable. Subscribing to this Observable will you allow to interact with the Terms API.
PercolateApiRx percolateApi = new PercolateApiRx(API_KEY);
TermsParams params = new TermsParams()
.scopeId("license:12345")
.search("abc");
Observable<Terms> observable = percolateApiRx.termsRx().get(params);
observable.subscribe(new Action1<Terms>() {
@Override
public void call(Terms terms) {
...
}
});
...
This library supports API_KEY authentication or OAuth2 authentication. See the auth module README file and the wiki page for details.
This is an experimental feature. See python-bridge for details.
Distributed under the BSD 3 license. See LICENSE for details.