<?xml version="1.0" encoding="UTF-8"?>
<schema
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:commonv4="http://minameddelanden.gov.se/schema/Common/v4"
    xmlns:recipientv4="http://minameddelanden.gov.se/schema/Recipient/v4"
    xmlns:authorityv4="http://minameddelanden.gov.se/schema/Authority/v4"
    targetNamespace="http://minameddelanden.gov.se/messagedefinition/Recipient/v4"
    elementFormDefault="qualified"
    version="4.0">

    <import namespace="http://minameddelanden.gov.se/schema/Common/v4" schemaLocation="../schema/v4/Common.xsd"/>
    <import namespace="http://minameddelanden.gov.se/schema/Recipient/v4"
            schemaLocation="../schema/v4/Recipient.xsd"/>
    <import namespace="http://minameddelanden.gov.se/schema/Authority/v4"
            schemaLocation="../schema/v4/Authority.xsd"/>

    <!-- Service operation message elements -->
    <element name="getAccountPreferences">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Inloggad användares identitetsnyckel.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="getAccountPreferencesResponse">
        <complexType>
            <sequence>
                <element ref="recipientv4:accountPreferences">
                    <annotation>
                        <documentation xml:lang="en">A total list of the senders, with an accompanying flag that states
                            the recipients wish to either block or accept said sender.
                        </documentation>
                        <documentation xml:lang="sv">Inställningar avseende en mottagares
                            godkända avsändare, med en flagga som anger (sant) om mottagaren accepterar meddelanden
                            från avsändaren.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="isReachable">
        <complexType>
            <sequence>
                <element ref="commonv4:swedishOrganizationId">
                    <annotation>
                        <documentation xml:lang="sv">Avsändarens organisationsnummer</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:recipientId" maxOccurs="1000">
                    <annotation>
                        <documentation xml:lang="sv">Lista med mottagare ID, Personnummer, eller Organisationsnummer.
                            Max 1000 mottagare/fråga.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="isReachableResponse">
        <complexType>
            <sequence>
                <element name="return" type="recipientv4:reachabilityStatusType" minOccurs="0" maxOccurs="1000">
                    <annotation>
                        <documentation xml:lang="sv">Anger om mottagaren(na) har ett konto i FAR om avsändaren
                            och/eller förmedlaren är godkänd samt adressen till mottagarens brevlådeoperatör.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="isReachableWithDispatcher">
        <complexType>
            <sequence>
                <element ref="commonv4:senderId">
                    <annotation>
                        <documentation xml:lang="sv">Avsändarens organisationsnummer</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:dispatcherId">
                    <annotation>
                        <documentation xml:lang="sv">Förmedlarens organisationsnummer</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:recipientId" maxOccurs="1000">
                    <annotation>
                        <documentation xml:lang="sv">Lista med mottagare ID, Personnummer, eller Organisationsnummer.
                            Max 1000 mottagare/fråga.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="isRegistered">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId" maxOccurs="1000">
                    <annotation>
                        <documentation xml:lang="sv">Lista med mottagare ID, Personnummer, eller
                            Organisationsnummer. Max 1000 mottagare/fråga.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="isRegisteredResponse">
        <complexType>
            <sequence>
                <element name="return" type="recipientv4:accountStatusType" minOccurs="0" maxOccurs="1000">
                    <annotation>
                        <documentation xml:lang="sv">Anger om mottagaren har ett konto registrerat i FAR
                            samt adressen till mottagarens brevlådeoperatör.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="register">
        <complexType>
            <sequence>
                <element ref="recipientv4:accountRequest">
                    <annotation>
                        <documentation xml:lang="sv">Registrering (kallades förut ansökan) av konto. En ev.
                            pågående registrering kan hämtas via operationen getPendingAccountRequest.
                        </documentation>
                    </annotation>
                </element>
                <element name="accountType" type="recipientv4:accountType">
                    <annotation>
                        <documentation xml:lang="sv">Kontotyp.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:signatureData" maxOccurs="unbounded">
                    <annotation>
                        <documentation xml:lang="sv">Signering av registreringen skapad med användarens
                            privata nyckel på e-legitimationen. Om registreringen avser ett konto med
                            flera firmatecknare (för en företagsbrevlåda) måste samtliga firmatecknares
                            signaturer enligt firmateckningsregler, anges innan registreringen godkänns.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="registerResponse">
        <complexType>
            <sequence>
                <element ref="authorityv4:signatureAuthorizationResult">
                    <annotation>
                        <documentation xml:lang="sv">Resultat av signerad registrering.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="deregister">
        <complexType>
            <sequence>
                <!-- This was named deregisterAccount earlier, but it should be implied what the request is about in the operation name -->
                <element ref="recipientv4:accountRequest">
                    <annotation>
                        <documentation xml:lang="sv">Avregistrering av mottagarkonto.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:signatureData" maxOccurs="unbounded">
                    <annotation>
                        <documentation xml:lang="sv">Signering av registreringen skapad med användarens
                            privata nyckel på e-legitimationen. Om registreringen avser ett konto med
                            flera firmatecknare (för en företagsbrevlåda) måste samtliga firmatecknares
                            signaturer enligt firmateckningsregler, anges innan registreringen godkänns.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="deregisterResponse">
        <complexType>
            <sequence>
                <element ref="authorityv4:signatureAuthorizationResult">
                    <annotation>
                        <documentation xml:lang="sv">Resultat av signerad avregistrering.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="getPendingAccountRequest">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId" maxOccurs="1000">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet(er) på den/de pågående ansökningen/arna.
                        </documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Inloggad användares identitet, i de fall operationen gäller en
                            privat brevlåda är detta samma som mottagaridentitet.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="getPendingAccountRequestResponse">
        <complexType>
            <sequence>
                <element ref="recipientv4:pendingAccountRequest" minOccurs="0" maxOccurs="unbounded">
                    <annotation>
                        <documentation xml:lang="sv">Påbörjad registrering av konto (kallades
                            förut ansökan) om påbörjad registrering finns annars tomt i listan.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="deletePendingAccountRequest">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet, identitet för brevlådan.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Inloggad användares identitet, i de fall operationen
                            gäller en privat brevlåda är detta samma som mottagaridentitet
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="deletePendingAccountRequestResponse">
        <annotation>
            <documentation xml:lang="en"></documentation>
            <documentation xml:lang="sv">Retursvaret är tomt. Om fel uppstod så returneras ett fault,
                annars betyder detta att operationen lyckades.</documentation>
        </annotation>
        <complexType>
            <sequence/>
        </complexType>
    </element>

    <!-- Re-versioned -->

    <element name="getPendingAccountPreferences">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottararidentitet.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Inloggad användares identitet, i de fall operationen gäller
                            en privat brevlåda är detta samma som mottagaridentitet.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="getPendingAccountPreferencesResponse">
        <complexType>
            <sequence>
                <element ref="recipientv4:pendingAccountPreferences">
                    <annotation>
                        <documentation xml:lang="sv">Information om påbörjad ändring av
                            mottagarkonto.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="deletePendingAccountPreferences">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet, identitet för brevlådan.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Inloggad användares identitet, i de fall operationen gäller en
                            privat brevlåda är detta samma som mottagaridentitet.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="deletePendingAccountPreferencesResponse">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet, identitet för brevlådan.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="storeAccountPreferences">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottararidentitet.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Inloggad användares identitet, i de fall operationen gäller en
                            privat brevlåda är detta samma som mottagaridentitet.
                        </documentation>
                    </annotation>
                </element>
                <element ref="recipientv4:accountPreferences">
                    <!-- Note! This is a major change, with this, we can store a list just the changes
                    rather than a total list with just one or a few changes -->
                    <annotation>
                        <documentation xml:lang="en">A list of the changes to the account preferences,
                            i.e. a list of senders that the user which to change the accepted/blocked setting for.
                            To be clear, only the changed senders should be included, this is a major difference
                            to how the API used to work in earlier versions (v3 and earlier).
                        </documentation>
                        <documentation xml:lang="sv">En lista på förändringar i kontoinställningar dvs,
                            en lista på avsändare DE som en mottagare önskar avblockera/blockera för avsändning.
                            Endast de förändringar mot tidigare kontoinställningar är nödvändiga, oförändrade
                            inställningar behöver inte sändas. Detta är en betydande skillnad mot tidigare
                            API-versioner (v3 och tidigare).
                        </documentation>
                    </annotation>
                </element>
                <element name="agreementText" type="string">
                    <annotation>
                        <documentation xml:lang="sv">Avtalstext, det som signeras.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:signatureData" maxOccurs="unbounded">
                    <annotation>
                        <documentation xml:lang="sv">Lista med en eller flera signatärer.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="storeAccountPreferencesResponse">
        <complexType>
            <sequence>
                <element ref="authorityv4:signatureAuthorizationResult">
                    <annotation>
                        <documentation xml:lang="sv">Resultat av signerad ansökan.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="changeServiceSupplier">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Inloggad användares identitetsnyckel.</documentation>
                    </annotation>
                </element>
                <element name="serviceSupplier" type="string">
                    <annotation>
                        <documentation xml:lang="en">The internet domain of the chosen service supplier.</documentation>
                        <documentation xml:lang="sv">Internetdomänen för den valda brevlådeoperatören.</documentation>
                    </annotation>
                </element>
                <element name="agreementText" type="string">
                    <annotation>
                        <documentation xml:lang="sv">Avtalstext, det som signeras.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:signatureData" maxOccurs="unbounded">
                    <annotation>
                        <documentation xml:lang="en"></documentation>
                        <documentation xml:lang="sv">Signerat datatinnehåll.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="changeServiceSupplierResponse">
        <complexType>
            <sequence>
                <element ref="authorityv4:signatureAuthorizationResult">
                    <annotation>
                        <documentation xml:lang="sv">Resultat av signerad ansökan.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="getPendingChangeServiceSupplier">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Inloggad användares identitet, i de fall operationen gäller en
                            privat brevlåda är detta samma som mottagaridentitet.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="getPendingChangeServiceSupplierResponse">
        <complexType>
            <sequence>
                <element ref="recipientv4:pendingChangeServiceSupplier">
                    <annotation>
                        <documentation xml:lang="sv">Information om påbörjat byte av brevlådeoperatör
                            om det finns ett sådant. Annars tomt i listan.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="deletePendingChangeServiceSupplier">
        <complexType>
            <sequence>
                <element ref="commonv4:recipientId">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="en"></documentation>
                        <documentation xml:lang="sv">Inloggad användares identitet, i de fall operationen gäller en
                            privat brevlåda är detta samma som mottagaridentitet.
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="deletePendingChangeServiceSupplierResponse">
        <complexType>
            <sequence>
                <element ref="commonv4:serviceSupplierId">
                    <annotation>
                        <documentation xml:lang="sv">Brevlådeoperatör som operationen gäller.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="isAuthorizedSigner">
        <complexType>
            <sequence>
                <element ref="commonv4:organizationId">
                    <annotation>
                        <documentation xml:lang="sv">Mottagaridentitet för företagsbrevlåda.</documentation>
                    </annotation>
                </element>
                <element ref="commonv4:userId">
                    <annotation>
                        <documentation xml:lang="sv">Identitet för en autenticerad användare. Behöver inte
                            nödvändigtvis representera användare med egen brevlåda (kan vara användare som inte
                            är mottagare).
                        </documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>
    <element name="isAuthorizedSignerResponse">
        <complexType>
            <sequence>
                <element ref="recipientv4:authorizedAccount">
                    <annotation>
                        <documentation xml:lang="sv">Information om signatär.</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </element>

</schema>
