Java SDK for the eInnsyn API
This repository contains the Java SDK for the eInnsyn API, which allows developers to interact with the eInnsyn service programmatically.
To use the SDK, add the following dependency to your pom.xml
:
<dependency>
<groupId>no.einnsyn</groupId>
<artifactId>sdk</artifactId>
<version>1.0.0</version>
</dependency>
import no.einnsyn.sdk.EInnsynClient;
// Initialize the client with an optional base URL and your API key
EInnsynClient client = new EInnsynClient("https://api.einnsyn.no", "secret...");
// Advanced initialization
EInnsynClient advancedClient = new EInnsynClient(b -> b
.baseUrl("http://localhost:8080")
.actingAs("enh_...")
.appInfo("My eInnsyn App")
.apiKey("https://api.test.einnsyn.no/api/v1")
// .username("eInnsynUser@example.com")
// .password(password)
// .jwt(jwt)
);
Using pre-built objects:
// Add Arkiv
ArkivRequest arkivRequest = ArkivRequest.builder().tittel("Arkiv title").build();
Arkiv arkiv = client.arkiv().add(arkivRequest);
// Add Arkivdel
ArkivdelRequest arkivdelRequest = ArkivdelRequest.builder().tittel("Arkivdel title").build();
Arkivdel arkivdel = client.arkiv().addArkivdel(arkiv.getId(), arkivdelRequest);
// Create JournalpostRequest
JournalpostRequest journalpostRequest =
JournalpostRequest.builder()
.offentligTittel("Journalpost title")
.offentligTittelSensitiv("Journalpost title with sensitive info")
.journalaar(2025)
.journaldato("2025-01-01")
.journalpostnummer(1)
.journalsekvensnummer(1)
.journalposttype(JournalposttypeEnum.INNGAAENDE_DOKUMENT)
.build();
// Create SaksmappeReqeust
SaksmappeRequest saksmappeRequest =
SaksmappeRequest.builder()
.offentligTittel("Saksmappe title")
.offentligTittelSensitiv("Saksmappe title with sensitive info")
.sakssekvensnummer(1)
.saksaar(2024)
.addJournalpost(journalpostRequest)
.build();
Saksmappe saksmappe = client.arkivdel().addSaksmappe(arkivdel.getId(), saksmappeRequest);
System.out.println(saksmappe);
// Example output:
// {
// "entity": "Saksmappe",
// "id": "sm_...",
// "offentligTittel": "Saksmappe title",
// "offentligTittelSensitiv": "Saksmappe title with sensitive info",
// "sakssekvensnummer": 1,
// "saksaar": 2025,
// "journalpost": [{
// "entity": "Journalpost",
// "id": "jp_..",
// "offentligTittel": "Journalpost title",
// "offentligTittelSensitiv": "Journalpost title with sensitive info",
// "journalaar": 2025,
// "journaldato": "2025-01-01",
// "journalpostnummer": 1,
// "journalsekvensnummer": 1,
// "journalposttype": "inngående",
// }],
// }
Using lambda-functions:
// Add Arkiv
Arkiv arkiv = client.arkiv().add(builder -> builder.tittel("Arkiv title"));
// Add Arkivdel
Arkivdel arkivdel = client.arkiv().addArkivdel(arkiv.getId(), builder -> builder.tittel("Arkivdel title"));
// Add Saksmappe with journalpost
Saksmappe saksmappe = client.arkivdel().addSaksmappe(arkivdel.getId(), builder -> builder
.offentligTittel("Saksmappe title")
.offentligTittelSensitiv("Saksmappe title with sensitive info")
.sakssekvensnummer(1)
.saksaar(2024)
.addJournalpost(jpbuilder -> jpbuilder
.offentligTittel("Journalpost title")
.offentligTittelSensitiv("Journalpost title with sensitive info")
.journalaar(2025)
.journaldato("2025-01-01")
.journalpostnummer(1)
.journalsekvensnummer(1)
.journalposttype(JournalposttypeEnum.INNGAAENDE_DOKUMENT)));
System.out.println(saksmappe);
// Example output:
// {
// "entity": "Saksmappe",
// "id": "sm_...",
// "offentligTittel": "Saksmappe title",
// "offentligTittelSensitiv": "Saksmappe title with sensitive info",
// "sakssekvensnummer": 1,
// "saksaar": 2025,
// "journalpost": [{
// "entity": "Journalpost",
// "id": "jp_..",
// "offentligTittel": "Journalpost title",
// "offentligTittelSensitiv": "Journalpost title with sensitive info",
// "journalaar": 2025,
// "journaldato": "2025-01-01",
// "journalpostnummer": 1,
// "journalsekvensnummer": 1,
// "journalposttype": "inngående",
// }],
// }
Journalpost journalpost = client.saksmappe().addJournalpost(
saksmappe.getId(),
jpBuilder -> jpBuilder
.offentligTittel("Journalpost title")
.offentligTittelSensitiv("Journalpost title with sensitive info")
.journalpostnummer(1)
.journaldato("2025-01-01")
.journalaar(2025)
.journalsekvensnummer(1)
.journalposttype(JournalposttypeEnum.INNGAAENDE_DOKUMENT));
System.out.println(journalpost);
// Example output:
// {
// "entity": "Journalpost",
// "id": "jp_...",
// "offentligTittel": "Journalpost title",
// "offentligTittelSensitiv": "Journalpost title with sensitive info",
// "journalpostnummer": 1,
// "journaldato": "2025-01-01",
// "journalaar": 2025,
// "journalsekvensnummer: 1,
// "journalposttype": "inngående"
// }
Saksmappe deletedSaksmappe = client.saksmappe().delete(saksmappeResponse.getId());
Saksmappe saksmappe = client.saksmappe().get(saksmappeId);
System.out.println(saksmappe);
// Example output:
// {
// "entity": "Saksmappe",
// "id": "sm_...",
// "offentligTittel": "Saksmappe title",
// "offentligTittelSensitiv": "Saksmappe title with sensitive info",
// "sakssekvensnummer": 1,
// "saksaar": 2025,
// "journalpost": ["jp_..."],
// }
Saksmappe saksmappe = client.saksmappe().getWithExpandedJournalposts(saksmappeId);
System.out.println(saksmappe);
// Example output:
// {
// "entity": "Saksmappe",
// "id": "sm_...",
// "offentligTittel": "Saksmappe title",
// "offentligTittelSensitiv": "Saksmappe title with sensitive info",
// "sakssekvensnummer": 1,
// "saksaar": 2025,
// "journalpost": [{
// "entity": "Journalpost",
// "id": "jp_...",
// "offentligTittel": "Journalpost title",
// "offentligTittelSensitiv": "Journalpost title with sensitive info",
// "journalaar": 2025,
// "journaldato": "2025-01-01",
// "journalpostnummer": 1,
// "journalsekvensnummer": 1,
// "journalposttype": "inngående",
// }],
// }
PaginatedList<Saksmappe> saksmappeList= client.saksmappe().list();
Iterator<Saksmappe> saksmappeIterator = saksmappeList.iterator();
while (saksmappeIterator.hasNext()) {
Saksmappe saksmappe = saksmappeIterator.next();
System.out.println(saksmappe);
}
PaginatedList<Base> searchResultList = client.search().search(b -> b
.query("Search query")
.publisertDatoAfter("2025-01-01")
);
Iterator<Base> searchIterator = searchResultList.iterator();
while (searchIterator.hasNext()) {
// Search results can be one of Saksmappe, Journalpost, Moetemappe, Moetesak
Base searchResult = searchIterator.next();
if (searchResult instanceof Saksmappe saksmappe) {
// Handle Saksmappe
} else if (searchResult instanceof Journalpost journalpost) {
// Handle Journalpost
} else if (searchResult instanceof Moetemappe moetemappe) {
// Handle Moetemappe
} else if (searchResult instanceof Moetesak moetesak) {
// Handle Moetesak
}
}
This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.