Giter Site home page Giter Site logo

a2d2's Introduction

a2d2 is a lightweight Android Library to asynchronously access DHIS2 through OAuth2 and retrieve DHIS2 Tracker metadata.

This is our own implementation, and we thought we could share it. For the official implementation please refer to the DHIS2 Android SDK project. However, we replicate the a2d2 object model from the objects retrieved through the DHIS2 API. It is also lightweight, meaning we do not intend to use this library for data retrieval, it is primarily for metadata synchronisation.

To use it one would need to have some knowledge of asynchronous coding using RXJava, dependency injection using Dagger, JSON 'standard', Retrofit and DHIS2. While some components are not fully abstracted, we aim for a good architecture which works and can be continuously improved, and best, which can be understandable and is small. Consequently, we will concentrate on having only generic features to be within this API so it can be reused across as many projects.

How to set up your project to use the library

You can simply create an instance of the library in your project by passing in your instance of okhttpclient and url of your instance to the a2d2 Builder class. E.g

a2d2API api = new a2d2.Builder() .serverUrl(HttpUrl.parse(resourceProvider.getString(R.string.primary_url))) .okHttpClient(okHttpClient) .build();

From that point on you will be able to access the dhis2 api using the methods defined in the API. For instance, to log in you would simply call

api.userTaskBuilder().authenticate(username, password);

You will get the User object from the api which you can store in a local database. We do not recommend storage of the password and rather we encourage password based authentication only at initial login in, from which point we have created other 'Task' objects to initialise and retrieve access tokens. We are in beta state with limited documentation. Currently there is an OAuth2 client that can be created at login, and should be used for subsequent calls.

Using this API, it is possible to retrieve metadata on programs and events and also to retrieve tracked entity instances. It is easily extensible and is open source. We have not versioned the api calls and it is currently working with 2.30, and 2.31. We have also not seen an incompatibility issues with 2.29. Either way, the simple architecture makes it possibe for others to use and adapt.

This is the first in a series of libraries which we hope will be useful to the community. We currently continue to actively develop the library. On how we implement it in our projects, we encourage a dependency injection framework such as dagger.

To use the compiled library in a project you can add the following dependency: repository - currently in snapshot with beta coming soon.

    maven {
        url("https://oss.sonatype.org/content/repositories/snapshots")
    }

Gradle:

implementation "com.itinordic:a2d2:${version}"

Happy coding!

a2d2's People

Contributors

regnatpopulus avatar tendai14 avatar anesuu avatar cliffordhc avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

mobiemr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.