<commit_before>package no.digipost.signature.client.docs;

import no.digipost.signature.client.ClientConfiguration;
import no.digipost.signature.client.core.PollingQueue;
import no.digipost.signature.client.core.Sender;
import no.digipost.signature.client.portal.Notifications;
import no.digipost.signature.client.portal.NotificationsUsingLookup;
import no.digipost.signature.client.portal.PortalClient;
import no.digipost.signature.client.portal.PortalDocument;
import no.digipost.signature.client.portal.PortalJob;
import no.digipost.signature.client.portal.PortalJobResponse;
import no.digipost.signature.client.portal.PortalJobStatus;
import no.digipost.signature.client.portal.PortalJobStatusChanged;
import no.digipost.signature.client.portal.PortalSigner;
import no.digipost.signature.client.portal.Signature;
import no.digipost.signature.client.portal.SignatureStatus;
import no.digipost.signature.client.portal.SignerIdentifier;

import java.io.InputStream;
import java.time.Instant;

@SuppressWarnings({"unused", "ConstantConditions", "StatementWithEmptyBody", "null"})
class PortalClientUseCases {

    static void create_and_send_signature_job() {
        ClientConfiguration clientConfiguration = null; // As initialized earlier
        PortalClient client = new PortalClient(clientConfiguration);

        byte[] documentBytes = null; // Loaded document bytes
        PortalDocument document = PortalDocument.builder("Subject", "document.pdf", documentBytes).build();

        PortalJob portalJob = PortalJob.builder(
                document,
                PortalSigner.identifiedByPersonalIdentificationNumber("12345678910",
                        NotificationsUsingLookup.EMAIL_ONLY).build(),
                PortalSigner.identifiedByPersonalIdentificationNumber("12345678911",
                        Notifications.builder().withEmailTo("<EMAIL>").build()).build(),
                PortalSigner.identifiedByEmail("<EMAIL>").build()
        ).build();

        PortalJobResponse portalJobResponse = client.create(portalJob);
    }

    static void get_status_changes() {
        PortalClient client = null; // As initialized earlier

        PortalJobStatusChanged statusChange = client.getStatusChange();

        if (statusChange.is(PortalJobStatus.NO_CHANGES)) {
            // Queue is empty. Must wait before polling again
            Instant nextPermittedPollTime = statusChange.getNextPermittedPollTime();
        } else {
            // Recieved status update, act according to status
            PortalJobStatus signatureJobStatus = statusChange.getStatus();
            Instant nextPermittedPollTime = statusChange.getNextPermittedPollTime();
        }

    }

    static void get_signer_status() {
        PortalJobStatusChanged statusChange = null; // As returned when polling for status changes

        Signature signature = statusChange.getSignatureFrom(
                SignerIdentifier.identifiedByPersonalIdentificationNumber("12345678910")
        );
    }

    static void get_signed_documents() {
        PortalClient client = null; // As initialized earlier
        PortalJobStatusChanged statusChange = null; // As returned when polling for status changes

        // Retrieve PAdES:
        if (statusChange.isPAdESAvailable()) {
            InputStream pAdESStream = client.getPAdES(statusChange.getpAdESUrl());
        }

        // Retrieve XAdES for all signers:
        for (Signature signature : statusChange.getSignatures()) {
            if (signature.is(SignatureStatus.SIGNED)) {
                InputStream xAdESStream = client.getXAdES(signature.getxAdESUrl());
            }
        }

        // … or for one specific signer:
        Signature signature = statusChange.getSignatureFrom(
                SignerIdentifier.identifiedByPersonalIdentificationNumber("12345678910"));
        if (signature.is(SignatureStatus.SIGNED)) {
            InputStream xAdESStream = client.getXAdES(signature.getxAdESUrl());
        }
    }

    static void confirm_processed_signature_job() {
        PortalClient client = null; // As initialized earlier
        PortalJobStatusChanged statusChange = null; // As returned when polling for status changes

        client.confirm(statusChange);
    }

    static void specifying_queues() {
        ClientConfiguration clientConfiguration = null; // As initialized earlier
        PortalClient client = new PortalClient(clientConfiguration);

        Sender sender = new Sender("000000000", PollingQueue.of("CustomPollingQueue"));<commit_msg>Flytter confirm av kvittering<commit_after>package no.digipost.signature.client.docs;

import no.digipost.signature.client.ClientConfiguration;
import no.digipost.signature.client.core.PollingQueue;
import no.digipost.signature.client.core.Sender;
import no.digipost.signature.client.portal.Notifications;
import no.digipost.signature.client.portal.NotificationsUsingLookup;
import no.digipost.signature.client.portal.PortalClient;
import no.digipost.signature.client.portal.PortalDocument;
import no.digipost.signature.client.portal.PortalJob;
import no.digipost.signature.client.portal.PortalJobResponse;
import no.digipost.signature.client.portal.PortalJobStatus;
import no.digipost.signature.client.portal.PortalJobStatusChanged;
import no.digipost.signature.client.portal.PortalSigner;
import no.digipost.signature.client.portal.Signature;
import no.digipost.signature.client.portal.SignatureStatus;
import no.digipost.signature.client.portal.SignerIdentifier;

import java.io.InputStream;
import java.time.Instant;

@SuppressWarnings({"unused", "ConstantConditions", "StatementWithEmptyBody", "null"})
class PortalClientUseCases {

    static void create_and_send_signature_job() {
        ClientConfiguration clientConfiguration = null; // As initialized earlier
        PortalClient client = new PortalClient(clientConfiguration);

        byte[] documentBytes = null; // Loaded document bytes
        PortalDocument document = PortalDocument.builder("Subject", "document.pdf", documentBytes).build();

        PortalJob portalJob = PortalJob.builder(
                document,
                PortalSigner.identifiedByPersonalIdentificationNumber("12345678910",
                        NotificationsUsingLookup.EMAIL_ONLY).build(),
                PortalSigner.identifiedByPersonalIdentificationNumber("12345678911",
                        Notifications.builder().withEmailTo("<EMAIL>").build()).build(),
                PortalSigner.identifiedByEmail("<EMAIL>").build()
        ).build();

        PortalJobResponse portalJobResponse = client.create(portalJob);
    }

    static void get_status_changes() {
        PortalClient client = null; // As initialized earlier

        PortalJobStatusChanged statusChange = client.getStatusChange();

        if (statusChange.is(PortalJobStatus.NO_CHANGES)) {
            // Queue is empty. Must wait before polling again
            Instant nextPermittedPollTime = statusChange.getNextPermittedPollTime();
        } else {
            // Received status update, act according to status
            PortalJobStatus signatureJobStatus = statusChange.getStatus();
            Instant nextPermittedPollTime = statusChange.getNextPermittedPollTime();
        }

        //Confirm the receipt to remove it from the queue
        client.confirm(statusChange);
    }

    static void get_signer_status() {
        PortalJobStatusChanged statusChange = null; // As returned when polling for status changes

        Signature signature = statusChange.getSignatureFrom(
                SignerIdentifier.identifiedByPersonalIdentificationNumber("12345678910")
        );
    }

    static void get_signed_documents() {
        PortalClient client = null; // As initialized earlier
        PortalJobStatusChanged statusChange = null; // As returned when polling for status changes

        // Retrieve PAdES:
        if (statusChange.isPAdESAvailable()) {
            InputStream pAdESStream = client.getPAdES(statusChange.getpAdESUrl());
        }

        // Retrieve XAdES for all signers:
        for (Signature signature : statusChange.getSignatures()) {
            if (signature.is(SignatureStatus.SIGNED)) {
                InputStream xAdESStream = client.getXAdES(signature.getxAdESUrl());
            }
        }

        // … or for one specific signer:
        Signature signature = statusChange.getSignatureFrom(
                SignerIdentifier.identifiedByPersonalIdentificationNumber("12345678910"));
        if (signature.is(SignatureStatus.SIGNED)) {
            InputStream xAdESStream = client.getXAdES(signature.getxAdESUrl());
        }
    }

    static void specifying_queues() {
        ClientConfiguration clientConfiguration = null; // As initialized earlier
        PortalClient client = new PortalClient(clientConfiguration);

        Sender sender = new Sender("000000000", PollingQueue.of("CustomPollingQueue"));
{'fraction_non_alphanumeric': 0.08835071196322458, 'fraction_numerical': 0.01188474044175356, 'mean_word_length': 3.3597262952101663, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3752889', 'n_tokens_mistral': 2398, 'n_tokens_neox': 2279, 'n_words': 448}