Skip to content

felleslosninger/einnsyn-sdk-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eInnsyn

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.

Table of Contents

Installation

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>

Usage

Initialize the Client

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)
);

Build and save a Saksmappe

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",
//   }],
// }

Add a Journalpost to the Saksmappe

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"
// }

Delete a Saksmappe

Saksmappe deletedSaksmappe = client.saksmappe().delete(saksmappeResponse.getId());

Get a Saksmappe

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_..."],
// }

Get a Saksmappe with expanded Journalposts

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",
//   }],
// }

Iterate over paginated lists

PaginatedList<Saksmappe> saksmappeList= client.saksmappe().list();
Iterator<Saksmappe> saksmappeIterator = saksmappeList.iterator();
while (saksmappeIterator.hasNext()) {
  Saksmappe saksmappe = saksmappeIterator.next();
  System.out.println(saksmappe);
}

Search

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
  }
}

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

References

About

Java SDK for eInnsyn

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •  

Languages