diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..95ca8e9
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,6 @@
+version: 2
+updates:
+ - package-ecosystem: maven
+ directory: "/"
+ schedule:
+ interval: "daily"
\ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..45d0c9d
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,45 @@
+name: CI
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+ schedule:
+ - cron: '0 0 * * *'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-java@v2
+ with:
+ java-version: '11'
+ distribution: 'adopt'
+ cache: maven
+ - run: mvn -B package --file pom.xml
+
+ deploy:
+ needs: build
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
+ runs-on: ubuntu-latest
+ environment: main
+ env:
+ OSSRH_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
+ OSSRH_PASSWORD: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
+ GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
+ GPG_SECRET_KEYS: ${{ secrets.GPG_SECRET_KEYS }}
+ GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-java@v2
+ with:
+ java-version: '11'
+ distribution: 'adopt'
+ cache: maven
+ - run: |
+ echo $GPG_SECRET_KEYS | base64 --decode | gpg --import --no-tty --batch --yes
+ echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust
+ mvn deploy --settings .mvn/settings.xml -Dgpg.skip=false -DskipTests=true -B
\ No newline at end of file
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 0000000..182d7e2
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,56 @@
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+ schedule:
+ - cron: '17 12 * * 0'
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'java' ]
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v1
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v1
+
+ # ℹ️ Command-line programs to run using the OS shell.
+ # 📚 https://git.io/JvXDl
+
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
+ # and modify them (or add more) to build your code if your project
+ # uses a compiled language
+
+ #- run: |
+ # make bootstrap
+ # make release
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v1
diff --git a/.gitignore b/.gitignore
index 0e13eeb..cdfe4eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,22 @@
-target/
-pom.xml.tag
-pom.xml.releaseBackup
-pom.xml.versionsBackup
-pom.xml.next
-release.properties
-dependency-reduced-pom.xml
-buildNumber.properties
-.mvn/timing.properties
-# https://github.com/takari/maven-wrapper#usage-without-binary-jar
-.mvn/wrapper/maven-wrapper.jar
+*.class
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+
+# exclude jar for gradle wrapper
+!gradle/wrapper/*.jar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+# build files
+**/target
+target
+.gradle
+build
+.idea/
\ No newline at end of file
diff --git a/.mvn/settings.xml b/.mvn/settings.xml
new file mode 100644
index 0000000..2088155
--- /dev/null
+++ b/.mvn/settings.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+ ossrh
+ ${env.OSSRH_USERNAME}
+ ${env.OSSRH_PASSWORD}
+
+
+
+
+
+ ossrh
+
+ true
+
+
+ gpg
+ ${env.GPG_PASSPHRASE}
+
+
+
+
\ No newline at end of file
diff --git a/DHISFormatter.xml b/DHISFormatter.xml
new file mode 100644
index 0000000..415e4c4
--- /dev/null
+++ b/DHISFormatter.xml
@@ -0,0 +1,316 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bee4899
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2004-2022, University of Oslo
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of the HISP project nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/license-header b/license-header
new file mode 100644
index 0000000..bdc118b
--- /dev/null
+++ b/license-header
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2004-$YEAR, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..6af11bc
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,199 @@
+
+
+ 4.0.0
+
+ org.example
+ dhis2-java-sdk
+ 1.0.0-SNAPSHOT
+
+
+ 11
+ 11
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.0.0
+
+
+ generate-sources
+
+ java
+
+
+
+
+ true
+ org.hisp.dhis.integration.jsonschemagen.Dhis2JsonSchemaGenerator
+ target/generated-resources/schemas
+
+
+
+ org.hisp.dhis.integration
+ dhis2-json-schema-generator
+ 1.0.0-SNAPSHOT
+
+
+ com.github.dhis2.dhis2-core
+ dhis-api
+ 2.37.4
+
+
+ com.github.dhis2.dhis2-core
+ dhis-service-dxf2
+ 2.37.4
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.36
+
+
+ junit
+ junit
+ 4.13.2
+
+
+
+
+ org.jsonschema2pojo
+ jsonschema2pojo-maven-plugin
+ 1.1.1
+
+ ${project.build.directory}/generated-resources/schemas
+ org.hisp.dhis.api.v2_37_4.model
+ true
+ true
+ true
+ true
+ true
+ true
+ false
+
+
+
+
+ generate
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M5
+
+ false
+
+
+
+ io.committed
+ speedy-spotless-maven-plugin
+ 0.1.3
+
+
+ install-formatter-hook
+
+ install-hooks
+
+
+
+
+
+
+ DHISFormatter.xml
+ 4.9.0
+
+
+
+
+
+ java,javax,org,com
+
+
+
+ license-header
+
+
+ UNIX
+
+
+
+
+
+
+
+
+
+ org.testcontainers
+ testcontainers-bom
+ 1.16.3
+ pom
+ import
+
+
+
+
+
+
+ com.squareup.okhttp3
+ okhttp
+ 4.9.3
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.13.2
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jdk8
+ 2.13.2
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.8.2
+ test
+
+
+ org.testcontainers
+ postgresql
+ test
+
+
+ io.rest-assured
+ rest-assured
+ 4.5.1
+ test
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ 2.17.2
+ test
+
+
+
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+ oss.sonatype.org
+ https://oss.sonatype.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
+
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/Dhis2Client.java b/src/main/java/org/hisp/dhis/integration/sdk/Dhis2Client.java
new file mode 100644
index 0000000..1208672
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/Dhis2Client.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk;
+
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.ConnectionPool;
+import okhttp3.Credentials;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+
+import org.hisp.dhis.integration.sdk.api.converter.ConverterFactory;
+import org.hisp.dhis.integration.sdk.api.operation.DeleteOperation;
+import org.hisp.dhis.integration.sdk.api.operation.GetOperation;
+import org.hisp.dhis.integration.sdk.api.operation.PatchOperation;
+import org.hisp.dhis.integration.sdk.api.operation.PostOperation;
+import org.hisp.dhis.integration.sdk.api.operation.PutOperation;
+import org.hisp.dhis.integration.sdk.internal.operation.DefaultDeleteOperation;
+import org.hisp.dhis.integration.sdk.internal.operation.DefaultGetOperation;
+import org.hisp.dhis.integration.sdk.internal.operation.DefaultPostOperation;
+import org.hisp.dhis.integration.sdk.internal.operation.DefaultPutOperation;
+
+public class Dhis2Client
+{
+ private final OkHttpClient httpClient;
+
+ private final String apiUrl;
+
+ private final ConverterFactory converterFactory;
+
+ Dhis2Client( String apiUrl, String username, String password, ConverterFactory converterFactory )
+ {
+ this.apiUrl = apiUrl;
+ OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder()
+ .connectionPool( new ConnectionPool( 1, 5, TimeUnit.MINUTES ) );
+ String credentials = Credentials.basic( username, password );
+ httpClient = httpClientBuilder.addInterceptor( chain -> {
+ Request request = chain.request().newBuilder()
+ .header( "Authorization", credentials )
+ .build();
+
+ return chain.proceed( request );
+ } ).build();
+ this.converterFactory = converterFactory;
+ }
+
+ public PostOperation post( String path, String... pathParams )
+ {
+ return new DefaultPostOperation( apiUrl, path, httpClient, converterFactory, pathParams );
+ }
+
+ public PutOperation put( String path, String... pathParams )
+ {
+ return new DefaultPutOperation( apiUrl, path, httpClient, converterFactory, pathParams );
+ }
+
+ public GetOperation get( String path, String... pathParams )
+ {
+ return new DefaultGetOperation( apiUrl, path, httpClient, converterFactory, pathParams );
+ }
+
+ public PatchOperation patch( String path, String... pathParams )
+ {
+ throw new UnsupportedOperationException();
+ // return new DefaultPatchOperation( apiUrl + path, httpClient,
+ // converterFactory );
+ }
+
+ public DeleteOperation delete( String path, String... pathParams )
+ {
+ return new DefaultDeleteOperation( apiUrl, path, httpClient, converterFactory );
+ }
+
+ public OkHttpClient getHttpClient()
+ {
+ return httpClient;
+ }
+}
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/Dhis2ClientBuilder.java b/src/main/java/org/hisp/dhis/integration/sdk/Dhis2ClientBuilder.java
new file mode 100644
index 0000000..33e13f7
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/Dhis2ClientBuilder.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk;
+
+import org.hisp.dhis.integration.sdk.api.converter.ConverterFactory;
+import org.hisp.dhis.integration.sdk.internal.converter.JacksonConverterFactory;
+
+public class Dhis2ClientBuilder
+{
+ private final String username;
+
+ private final String password;
+
+ private final String baseApiUrl;
+
+ private ConverterFactory converterFactory = new JacksonConverterFactory();
+
+ public static Dhis2ClientBuilder newClient( String baseApiUrl, String username, String password )
+ {
+ return new Dhis2ClientBuilder( baseApiUrl, username, password );
+ }
+
+ private Dhis2ClientBuilder( String baseApiUrl, String username, String password )
+ {
+ this.baseApiUrl = baseApiUrl.trim();
+ this.username = username;
+ this.password = password;
+ }
+
+ public Dhis2ClientBuilder withConverterFactory( ConverterFactory converterFactory )
+ {
+ this.converterFactory = converterFactory;
+ return this;
+ }
+
+ public Dhis2Client build()
+ {
+ StringBuilder apiPathStringBuilder = new StringBuilder();
+ apiPathStringBuilder.append( baseApiUrl );
+ if ( !baseApiUrl.endsWith( "/" ) )
+ {
+ apiPathStringBuilder.append( "/" );
+ }
+ return new Dhis2Client( apiPathStringBuilder.toString(), username, password, converterFactory );
+ }
+}
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/Page.java b/src/main/java/org/hisp/dhis/integration/sdk/Page.java
new file mode 100644
index 0000000..432b60f
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/Page.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hisp.dhis.api.v2_37_4.model.Pager;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@JsonIgnoreProperties( ignoreUnknown = true )
+public class Page
+{
+ private Pager pager;
+
+ @JsonIgnore
+ private final Map additionalProperties = new HashMap<>();
+
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
+ @JsonAnyGetter
+ public Map getAdditionalProperties()
+ {
+ return additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty( String name, Object value )
+ {
+ this.additionalProperties.put( name, value );
+ }
+
+}
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/api/Dhis2ClientException.java b/src/main/java/org/hisp/dhis/integration/sdk/api/Dhis2ClientException.java
new file mode 100644
index 0000000..7c1aae3
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/api/Dhis2ClientException.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk.api;
+
+public class Dhis2ClientException extends RuntimeException
+{
+ public Dhis2ClientException()
+ {
+ super();
+ }
+
+ public Dhis2ClientException( String message )
+ {
+ super( message );
+ }
+
+ public Dhis2ClientException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public Dhis2ClientException( Throwable cause )
+ {
+ super( cause );
+ }
+
+ protected Dhis2ClientException( String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace )
+ {
+ super( message, cause, enableSuppression, writableStackTrace );
+ }
+}
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/api/Dhis2Response.java b/src/main/java/org/hisp/dhis/integration/sdk/api/Dhis2Response.java
new file mode 100644
index 0000000..ba655c9
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/api/Dhis2Response.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk.api;
+
+import java.io.InputStream;
+
+public interface Dhis2Response
+{
+ T returnAs( Class responseType );
+
+ InputStream read();
+
+}
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/api/IterableDhis2Response.java b/src/main/java/org/hisp/dhis/integration/sdk/api/IterableDhis2Response.java
new file mode 100644
index 0000000..b928872
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/api/IterableDhis2Response.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk.api;
+
+public interface IterableDhis2Response
+{
+ Iterable returnAs( Class responseType, String collectionName );
+}
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/api/converter/ConverterFactory.java b/src/main/java/org/hisp/dhis/integration/sdk/api/converter/ConverterFactory.java
new file mode 100644
index 0000000..eea1247
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/api/converter/ConverterFactory.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk.api.converter;
+
+public interface ConverterFactory
+{
+ RequestConverter createRequestConverter( Object requestType );
+
+ ResponseConverter createResponseConverter( Class responseType );
+}
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/api/converter/RequestConverter.java b/src/main/java/org/hisp/dhis/integration/sdk/api/converter/RequestConverter.java
new file mode 100644
index 0000000..c4a5e68
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/api/converter/RequestConverter.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk.api.converter;
+
+public interface RequestConverter
+{
+ String convert( Object requestBody );
+}
diff --git a/src/main/java/org/hisp/dhis/integration/sdk/api/converter/ResponseConverter.java b/src/main/java/org/hisp/dhis/integration/sdk/api/converter/ResponseConverter.java
new file mode 100644
index 0000000..eab04a4
--- /dev/null
+++ b/src/main/java/org/hisp/dhis/integration/sdk/api/converter/ResponseConverter.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004-2022, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.integration.sdk.api.converter;
+
+import java.util.List;
+import java.util.Map;
+
+import okhttp3.ResponseBody;
+
+public interface ResponseConverter
+{
+ T convert( ResponseBody responseBody );
+
+ T convert( List